require File.dirname(__FILE__) + '/../../spec_helper' describe "/cups/show.rhtml" do before do @cup = mock_model(Cup) @cup.stub!(:name).and_return("MyString") assigns[:cup] = @cup end it "should display the chart" do #given @cup.stub!(:rounds).and_return( [ stub("round 1", :matches => [ stub("match 1", :first_team_name => "team 1", :second_team_name => "team 2" ), stub("match 2", :first_team_name => "team 3", :second_team_name => "team 4" ) ]), stub("round 2", :matches => [ stub("match 3", :first_team_name => "team 5", :second_team_name => "team 6" ) ]) ] ) @cup.stub!(:winning_team_name).and_return("team 7") @cup.stub!(:max_teams).and_return(4) template.should_receive(:colspan_for_round).with(1).and_return(1,1,1,1) template.should_receive(:colspan_for_round).with(2).and_return(2,2) #when render "/cups/show.rhtml" #then response.should have_tag("table") do with_tag("tr") do with_tag("td", "team 1") with_tag("td", "team 2") with_tag("td", "team 3") with_tag("td", "team 4") end with_tag("tr") do with_tag("td[colspan=2]", "team 5") with_tag("td[colspan=2]", "team 6") end with_tag("tr") do with_tag("td[colspan=4]", "team 7") end end end end