require File.join(File.dirname(__FILE__), *%w[helper]) Story "Plan cup", %{ As a cup organizer I want to declare how many teams are in the cup So that I can lay out the chart }, :type => RailsStory do Scenario "set up a 4 team cup structure" do Given "a new cup with max teams of", 4 do |max_teams| post "/cups", :cup => {:name => "RailsConf EU" , :max_teams => max_teams} response.should be_redirect @cup = Cup.find_by_name "RailsConf EU" end When "I ask to see it" do get "/cups/#{@cup.id}" end Then "It should a row count of", 3 do |row_count| response.should have_tag("table") do with_tag("tr", row_count) end end Then "The round 1 row should have a column count of", 4 do |col_count| response.should have_tag("tr#round1") do with_tag("td", col_count) end end Then "The round 2 row should have a column count of", 2 do |col_count| response.should have_tag("tr#round2") do with_tag("td", col_count) end end Then "The winner row should have a column count of", 1 do |col_count| response.should have_tag("tr#winner") do with_tag("td", col_count) end end end Scenario "set up an 8 team cup structure" do Given "a new cup with max teams of", 8 When "I ask to see it" Then "It should a row count of", 4 Then "The round 1 row should have a column count of", 8 Then "The round 2 row should have a column count of", 4 Then "The round 3 row should have a column count of", 2 do |col_count| response.should have_tag("tr#round3") do with_tag("td", col_count) end end Then "The winner row should have a column count of", 1 end end