spec/requests/main_spec.rb in merb-admin-0.7.6 vs spec/requests/main_spec.rb in merb-admin-0.8.0
- old
+ new
@@ -6,10 +6,14 @@
given "a draft exists" do
@draft = MerbAdmin::AbstractModel.new("Draft").create(:player_id => rand(99999), :team_id => rand(99999), :date => Date.today, :round => rand(50), :pick => rand(30), :overall => rand(1500))
end
+given "a league exists" do
+ @league = MerbAdmin::AbstractModel.new("League").create(:name => "League 1")
+end
+
given "two players exist" do
@players = []
(1..2).each do |number|
@players << MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => number, :name => "Player #{number}")
end
@@ -20,39 +24,17 @@
(1..3).each do |number|
@teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{number}", :manager => "Manager #{number}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
end
end
-given "a player exists and a draft exists" do
- @player = MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 1, :name => "Player 1")
- @draft = MerbAdmin::AbstractModel.new("Draft").create(:player_id => rand(99999), :team_id => rand(99999), :date => Date.today, :round => rand(50), :pick => rand(30), :overall => rand(1500))
-end
-
-given "a player exists and three teams exist" do
- @player = MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 1, :name => "Player 1")
+given "three teams with no name exist" do
@teams = []
(1..3).each do |number|
- @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{number}", :manager => "Manager #{number}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
- end
-end
-
-given "a player exists and three teams with no name exist" do
- @player = MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 1, :name => "Player 1")
- @teams = []
- (1..3).each do |number|
@teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :manager => "Manager #{number}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
end
end
-given "a league exists and three teams exist" do
- @league = MerbAdmin::AbstractModel.new("League").create(:name => "League 1")
- @teams = []
- (1..3).each do |number|
- @teams << MerbAdmin::AbstractModel.new("Team").create(:league_id => rand(99999), :division_id => rand(99999), :name => "Team #{number}", :manager => "Manager #{number}", :founded => 1869 + rand(130), :wins => (wins = rand(163)), :losses => 162 - wins, :win_percentage => ("%.3f" % (wins.to_f / 162)).to_f)
- end
-end
-
given "twenty players exist" do
@players = []
(1..20).each do |number|
@players << MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => number, :name => "Player #{number}")
end
@@ -369,11 +351,11 @@
it "should show associated objects" do
@response.body.should contain(/TeamTeam 1Team 2Team 3/)
end
end
- describe "new with missing label", :given => "a player exists and three teams with no name exist" do
+ describe "new with missing label", :given => ["a player exists", "three teams with no name exist"] do
before(:each) do
@response = visit(url(:merb_admin_new, :model_name => "player"))
end
it "should respond sucessfully" do
@@ -531,11 +513,11 @@
@response.body.should contain(/Draft\n\s*Optional/)
@response.body.should contain(/Team\n\s*Optional/)
end
end
- describe "edit with has-one association", :given => "a player exists and a draft exists" do
+ describe "edit with has-one association", :given => ["a player exists", "a draft exists"] do
before(:each) do
@response = visit(url(:merb_admin_edit, :model_name => "player", :id => @player.id))
end
it "should respond sucessfully" do
@@ -545,11 +527,11 @@
it "should show associated objects" do
@response.body.should contain(/DraftDraft #\d+/)
end
end
- describe "edit with has-many association", :given => "a player exists and three teams exist" do
+ describe "edit with has-many association", :given => ["a player exists", "three teams exist"] do
before(:each) do
@response = visit(url(:merb_admin_edit, :model_name => "player", :id => @player.id))
end
it "should respond sucessfully" do
@@ -569,11 +551,11 @@
it "should raise NotFound" do
@response.status.should equal(404)
end
end
- describe "edit with missing label", :given => "a player exists and three teams with no name exist" do
+ describe "edit with missing label", :given => ["a player exists", "three teams with no name exist"] do
before(:each) do
@response = visit(url(:merb_admin_edit, :model_name => "player", :id => @player.id))
end
it "should respond sucessfully" do
@@ -642,11 +624,11 @@
@player.number.should eql(42)
@player.position.should eql("Second baseman")
end
end
- describe "update with has-one association", :given => "a player exists and a draft exists" do
+ describe "update with has-one association", :given => ["a player exists", "a draft exists"] do
before(:each) do
visit(url(:merb_admin_edit, :model_name => "player", :id => @player.id))
fill_in "Name", :with => "Jackie Robinson"
fill_in "Number", :with => "42"
fill_in "Position", :with => "Second baseman"
@@ -666,10 +648,10 @@
@draft.reload
@player.draft.should eql(@draft)
end
end
- describe "update with has-many association", :given => "a league exists and three teams exist" do
+ describe "update with has-many association", :given => ["a league exists", "three teams exist"] do
before(:each) do
visit(url(:merb_admin_edit, :model_name => "league", :id => @league.id))
fill_in "Name", :with => "National League"
fill_in "Teams", :with => @teams[0].id.to_s
@response = click_button "Save"