re-namespacing a touch
This commit is contained in:
39
map-mash/spec/blueprints.rb
Normal file
39
map-mash/spec/blueprints.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require 'machinist/active_record'
|
||||
require 'sham'
|
||||
require 'faker'
|
||||
|
||||
|
||||
Sham.location do
|
||||
"#{Faker::Address.city}, #{Faker::Address.uk_country}"
|
||||
end
|
||||
|
||||
|
||||
Map.blueprint do
|
||||
name { Sham.location }
|
||||
end
|
||||
|
||||
|
||||
Mash.blueprint do
|
||||
|
||||
end
|
||||
|
||||
|
||||
MashTournament.blueprint do
|
||||
|
||||
end
|
||||
|
||||
|
||||
MashTournamentRound.blueprint do
|
||||
|
||||
end
|
||||
|
||||
|
||||
Requester.blueprint do
|
||||
ip do
|
||||
parts = []
|
||||
4.times do
|
||||
parts << (rand * 100).to_i.to_s
|
||||
end
|
||||
parts.join('.')
|
||||
end
|
||||
end
|
16
map-mash/spec/controllers/maps_controller_spec.rb
Normal file
16
map-mash/spec/controllers/maps_controller_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MapsController do
|
||||
|
||||
describe "GET index" do
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
end
|
||||
end
|
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashTournamentsController do
|
||||
describe "GET index" do
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
end
|
||||
end
|
4
map-mash/spec/controllers/mashes_controller_spec.rb
Normal file
4
map-mash/spec/controllers/mashes_controller_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesController do
|
||||
end
|
7
map-mash/spec/fixtures/maps.yml
vendored
Normal file
7
map-mash/spec/fixtures/maps.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
7
map-mash/spec/fixtures/mash_tournaments.yml
vendored
Normal file
7
map-mash/spec/fixtures/mash_tournaments.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
requester_id: 1
|
||||
|
||||
two:
|
||||
requester_id: 1
|
13
map-mash/spec/fixtures/mashes.yml
vendored
Normal file
13
map-mash/spec/fixtures/mashes.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
requester: MyString
|
||||
map_a: 1
|
||||
map_b: 1
|
||||
winner: 1
|
||||
|
||||
two:
|
||||
requester: MyString
|
||||
map_a: 1
|
||||
map_b: 1
|
||||
winner: 1
|
7
map-mash/spec/fixtures/requesters.yml
vendored
Normal file
7
map-mash/spec/fixtures/requesters.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
ip: MyString
|
||||
|
||||
two:
|
||||
ip: MyString
|
11
map-mash/spec/helpers/maps_helper_spec.rb
Normal file
11
map-mash/spec/helpers/maps_helper_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MapsHelper do
|
||||
|
||||
#Delete this example and add some real ones or delete this file
|
||||
it "is included in the helper object" do
|
||||
included_modules = (class << helper; self; end).send :included_modules
|
||||
included_modules.should include(MapsHelper)
|
||||
end
|
||||
|
||||
end
|
11
map-mash/spec/helpers/mash_tournaments_helper_spec.rb
Normal file
11
map-mash/spec/helpers/mash_tournaments_helper_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashTournamentsHelper do
|
||||
|
||||
#Delete this example and add some real ones or delete this file
|
||||
it "is included in the helper object" do
|
||||
included_modules = (class << helper; self; end).send :included_modules
|
||||
included_modules.should include(MashTournamentsHelper)
|
||||
end
|
||||
|
||||
end
|
11
map-mash/spec/helpers/mashes_helper_spec.rb
Normal file
11
map-mash/spec/helpers/mashes_helper_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesHelper do
|
||||
|
||||
#Delete this example and add some real ones or delete this file
|
||||
it "is included in the helper object" do
|
||||
included_modules = (class << helper; self; end).send :included_modules
|
||||
included_modules.should include(MashesHelper)
|
||||
end
|
||||
|
||||
end
|
4
map-mash/spec/integration/maps_spec.rb
Normal file
4
map-mash/spec/integration/maps_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Maps" do
|
||||
end
|
4
map-mash/spec/integration/mash_tournaments_spec.rb
Normal file
4
map-mash/spec/integration/mash_tournaments_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "MashTournaments" do
|
||||
end
|
4
map-mash/spec/integration/mashes_spec.rb
Normal file
4
map-mash/spec/integration/mashes_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Mashes" do
|
||||
end
|
64
map-mash/spec/lib/mash_tournament_builder_spec.rb
Normal file
64
map-mash/spec/lib/mash_tournament_builder_spec.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashTournamentBuilder do
|
||||
let(ENV['MOCK'].nil? ? :subject : :real_subject) do
|
||||
MashTournamentBuilder.new(
|
||||
MashTournament.make(:requester => Requester.make),
|
||||
MashTournament, MashTournamentRound, Map, Mash
|
||||
)
|
||||
end
|
||||
|
||||
let(ENV['MOCK'].nil? ? :mock_subject : :subject) do
|
||||
@tournament = mock(Object)
|
||||
@tournament_model = mock(Object)
|
||||
@round_model = mock(Object)
|
||||
@map_model = mock(Object)
|
||||
@mash_model = mock(Object)
|
||||
|
||||
MashTournamentBuilder.new(
|
||||
@tournament, @tournament_model,
|
||||
@round_model, @map_model, @mash_model
|
||||
)
|
||||
end
|
||||
|
||||
before(:all) do
|
||||
subject.map_model.destroy_all
|
||||
40.times do
|
||||
subject.map_model.make.save
|
||||
end
|
||||
end
|
||||
|
||||
context 'creating rounds' do
|
||||
it 'should reject invalid numbers of contenders' do
|
||||
[11, 24, 40].each do |n|
|
||||
expect do
|
||||
subject.create_rounds_for_contenders(n)
|
||||
end.to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
[[8, 3], [16, 4], [32, 5]].each do |n_contenders,n_rounds|
|
||||
context "for #{n_contenders} total contenders" do
|
||||
it "should create #{n_rounds} rounds" do
|
||||
subject.create_rounds_for_contenders(n_contenders)
|
||||
subject.tournament.total_rounds.should == n_rounds
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'filling in rounds' do
|
||||
before(:each) do
|
||||
subject.tournament.id.should_not be_nil
|
||||
subject.create_rounds_for_contenders(8)
|
||||
end
|
||||
|
||||
it 'should fill in every map for every mash in a given round' do
|
||||
subject.fill_in_next_round
|
||||
subject.tournament.round(1).mashes.each do |mash|
|
||||
mash.map_a.should_not be_nil
|
||||
mash.map_b.should_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
map-mash/spec/models/map_spec.rb
Normal file
13
map-mash/spec/models/map_spec.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Map do
|
||||
before(:each) do
|
||||
@valid_attributes = {
|
||||
:name => "value for name"
|
||||
}
|
||||
end
|
||||
|
||||
it "should create a new instance given valid attributes" do
|
||||
Map.create!(@valid_attributes)
|
||||
end
|
||||
end
|
11
map-mash/spec/models/mash_tournament_spec.rb
Normal file
11
map-mash/spec/models/mash_tournament_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashTournament do
|
||||
before(:each) do
|
||||
@valid_attributes = {:requester_id => 1}
|
||||
end
|
||||
|
||||
it "should create a new instance given valid attributes" do
|
||||
MashTournament.create!(@valid_attributes)
|
||||
end
|
||||
end
|
13
map-mash/spec/models/requester_spec.rb
Normal file
13
map-mash/spec/models/requester_spec.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Requester do
|
||||
before(:each) do
|
||||
@valid_attributes = {
|
||||
:ip => "value for ip"
|
||||
}
|
||||
end
|
||||
|
||||
it "should create a new instance given valid attributes" do
|
||||
Requester.create!(@valid_attributes)
|
||||
end
|
||||
end
|
2
map-mash/spec/rcov.opts
Normal file
2
map-mash/spec/rcov.opts
Normal file
@@ -0,0 +1,2 @@
|
||||
--exclude "spec/*,gems/*"
|
||||
--rails
|
33
map-mash/spec/routing/maps_routing_spec.rb
Normal file
33
map-mash/spec/routing/maps_routing_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MapsController do
|
||||
describe "routing" do
|
||||
it "recognizes and generates #index" do
|
||||
{ :get => "/maps" }.should route_to(:controller => "maps", :action => "index")
|
||||
end
|
||||
|
||||
it "recognizes and generates #new" do
|
||||
{ :get => "/maps/new" }.should route_to(:controller => "maps", :action => "new")
|
||||
end
|
||||
|
||||
it "recognizes and generates #show" do
|
||||
{ :get => "/maps/1" }.should route_to(:controller => "maps", :action => "show", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #edit" do
|
||||
{ :get => "/maps/1/edit" }.should route_to(:controller => "maps", :action => "edit", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #create" do
|
||||
{ :post => "/maps" }.should route_to(:controller => "maps", :action => "create")
|
||||
end
|
||||
|
||||
it "recognizes and generates #update" do
|
||||
{ :put => "/maps/1" }.should route_to(:controller => "maps", :action => "update", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #destroy" do
|
||||
{ :delete => "/maps/1" }.should route_to(:controller => "maps", :action => "destroy", :id => "1")
|
||||
end
|
||||
end
|
||||
end
|
33
map-mash/spec/routing/mash_tournaments_routing_spec.rb
Normal file
33
map-mash/spec/routing/mash_tournaments_routing_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashTournamentsController do
|
||||
describe "routing" do
|
||||
it "recognizes and generates #index" do
|
||||
{ :get => "/mash_tournaments" }.should route_to(:controller => "mash_tournaments", :action => "index")
|
||||
end
|
||||
|
||||
it "recognizes and generates #new" do
|
||||
{ :get => "/mash_tournaments/new" }.should route_to(:controller => "mash_tournaments", :action => "new")
|
||||
end
|
||||
|
||||
it "recognizes and generates #show" do
|
||||
{ :get => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "show", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #edit" do
|
||||
{ :get => "/mash_tournaments/1/edit" }.should route_to(:controller => "mash_tournaments", :action => "edit", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #create" do
|
||||
{ :post => "/mash_tournaments" }.should route_to(:controller => "mash_tournaments", :action => "create")
|
||||
end
|
||||
|
||||
it "recognizes and generates #update" do
|
||||
{ :put => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "update", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #destroy" do
|
||||
{ :delete => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "destroy", :id => "1")
|
||||
end
|
||||
end
|
||||
end
|
33
map-mash/spec/routing/mashes_routing_spec.rb
Normal file
33
map-mash/spec/routing/mashes_routing_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesController do
|
||||
describe "routing" do
|
||||
it "recognizes and generates #index" do
|
||||
{ :get => "/mashes" }.should route_to(:controller => "mashes", :action => "index")
|
||||
end
|
||||
|
||||
it "recognizes and generates #new" do
|
||||
{ :get => "/mashes/new" }.should route_to(:controller => "mashes", :action => "new")
|
||||
end
|
||||
|
||||
it "recognizes and generates #show" do
|
||||
{ :get => "/mashes/1" }.should route_to(:controller => "mashes", :action => "show", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #edit" do
|
||||
{ :get => "/mashes/1/edit" }.should route_to(:controller => "mashes", :action => "edit", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #create" do
|
||||
{ :post => "/mashes" }.should route_to(:controller => "mashes", :action => "create")
|
||||
end
|
||||
|
||||
it "recognizes and generates #update" do
|
||||
{ :put => "/mashes/1" }.should route_to(:controller => "mashes", :action => "update", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #destroy" do
|
||||
{ :delete => "/mashes/1" }.should route_to(:controller => "mashes", :action => "destroy", :id => "1")
|
||||
end
|
||||
end
|
||||
end
|
4
map-mash/spec/spec.opts
Normal file
4
map-mash/spec/spec.opts
Normal file
@@ -0,0 +1,4 @@
|
||||
--colour
|
||||
--format progress
|
||||
--loadby mtime
|
||||
--reverse
|
18
map-mash/spec/spec_helper.rb
Normal file
18
map-mash/spec/spec_helper.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment'))
|
||||
require 'spec/autorun'
|
||||
require 'spec/rails'
|
||||
|
||||
SPEC_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(SPEC_ROOT)
|
||||
ENV['SPEC_ROOT'] ||= SPEC_ROOT
|
||||
|
||||
require File.join(SPEC_ROOT, 'blueprints')
|
||||
|
||||
Dir[File.join(SPEC_ROOT,'support','**','*.rb')].each {|f| require f}
|
||||
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.use_transactional_fixtures = true
|
||||
config.use_instantiated_fixtures = false
|
||||
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
||||
end
|
20
map-mash/spec/views/maps/edit.html.erb_spec.rb
Normal file
20
map-mash/spec/views/maps/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/maps/edit.html.erb" do
|
||||
include MapsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:map] = @map = stub_model(Map,
|
||||
:new_record? => false,
|
||||
:name => "value for name"
|
||||
)
|
||||
end
|
||||
|
||||
it "renders the edit map form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=#{map_path(@map)}][method=post]") do
|
||||
with_tag('input#map_name[name=?]', "map[name]")
|
||||
end
|
||||
end
|
||||
end
|
21
map-mash/spec/views/maps/index.html.erb_spec.rb
Normal file
21
map-mash/spec/views/maps/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/maps/index.html.erb" do
|
||||
include MapsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:maps] = [
|
||||
stub_model(Map,
|
||||
:name => "value for name"
|
||||
),
|
||||
stub_model(Map,
|
||||
:name => "value for name"
|
||||
)
|
||||
]
|
||||
end
|
||||
|
||||
it "renders a list of maps" do
|
||||
render
|
||||
response.should have_tag("tr>td", "value for name".to_s, 2)
|
||||
end
|
||||
end
|
20
map-mash/spec/views/maps/new.html.erb_spec.rb
Normal file
20
map-mash/spec/views/maps/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/maps/new.html.erb" do
|
||||
include MapsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:map] = stub_model(Map,
|
||||
:new_record? => true,
|
||||
:name => "value for name"
|
||||
)
|
||||
end
|
||||
|
||||
it "renders new map form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=?][method=post]", maps_path) do
|
||||
with_tag("input#map_name[name=?]", "map[name]")
|
||||
end
|
||||
end
|
||||
end
|
15
map-mash/spec/views/maps/show.html.erb_spec.rb
Normal file
15
map-mash/spec/views/maps/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/maps/show.html.erb" do
|
||||
include MapsHelper
|
||||
before(:each) do
|
||||
assigns[:map] = @map = stub_model(Map,
|
||||
:name => "value for name"
|
||||
)
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
response.should have_text(/value\ for\ name/)
|
||||
end
|
||||
end
|
18
map-mash/spec/views/mash_tournaments/edit.html.erb_spec.rb
Normal file
18
map-mash/spec/views/mash_tournaments/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mash_tournaments/edit.html.erb" do
|
||||
include MashTournamentsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mash_tournament] = @mash_tournament = stub_model(MashTournament,
|
||||
:new_record? => false
|
||||
)
|
||||
end
|
||||
|
||||
it "renders the edit mash_tournament form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=#{mash_tournament_path(@mash_tournament)}][method=post]") do
|
||||
end
|
||||
end
|
||||
end
|
16
map-mash/spec/views/mash_tournaments/index.html.erb_spec.rb
Normal file
16
map-mash/spec/views/mash_tournaments/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mash_tournaments/index.html.erb" do
|
||||
include MashTournamentsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mash_tournaments] = [
|
||||
stub_model(MashTournament),
|
||||
stub_model(MashTournament)
|
||||
]
|
||||
end
|
||||
|
||||
it "renders a list of mash_tournaments" do
|
||||
render
|
||||
end
|
||||
end
|
18
map-mash/spec/views/mash_tournaments/new.html.erb_spec.rb
Normal file
18
map-mash/spec/views/mash_tournaments/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mash_tournaments/new.html.erb" do
|
||||
include MashTournamentsHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mash_tournament] = stub_model(MashTournament,
|
||||
:new_record? => true
|
||||
)
|
||||
end
|
||||
|
||||
it "renders new mash_tournament form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=?][method=post]", mash_tournaments_path) do
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user