Skip to content

Instantly share code, notes, and snippets.

@mjansen401
Created May 9, 2011 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjansen401/963646 to your computer and use it in GitHub Desktop.
Save mjansen401/963646 to your computer and use it in GitHub Desktop.
_square.html.erb_spec.rb
require 'spec_helper'
describe "games/_square.html.erb" do
before(:each) do
@ttt = mock(TicTacToe)
end
it "displays a filled square" do
@ttt.stub!(:square_empty?).and_return false
@ttt.stub!(:get_square_value).and_return "X"
@ttt.stub!(:in_progress?).and_return true
render :partial => 'games/square', :locals => {:location => '3'}
rendered.should =~ /X/
end
it "displays an empty square" do
@ttt.stub!(:square_empty?).and_return true
@ttt.stub!(:in_progress?).and_return true
render :partial => 'games/square', :locals => {:location => '3'}
assert_select "input", :name => "location", :value => "3"
end
it "displays empty square if game over" do
@ttt.stub!(:square_empty?).and_return true
@ttt.stub!(:in_progress?).and_return false
rendered.should =~ //
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment