Created
September 25, 2008 11:39
-
-
Save mattwynne/12805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'spec' | |
class Team | |
def initialize(game) | |
@game = game | |
end | |
def do_substitution | |
@game.num_subs -= 1 | |
end | |
end | |
class Game | |
attr_accessor :num_subs | |
def initialize | |
@num_subs = 0 | |
end | |
end | |
describe Team do | |
describe "integrated with a real Game instance" do | |
before(:each) do | |
@game = Game.new | |
@team = Team.new(@game) | |
end | |
describe "when a substitution is performed" do | |
it "should decrement the num_subs on the game" do | |
# @game.should_receive(:num_subs) | |
@team.do_substitution | |
@game.num_subs.should == -1 | |
end | |
end | |
end | |
describe "using a mock Game" do | |
before(:each) do | |
@game = mock(Game) | |
@team = Team.new(@game) | |
end | |
describe "when a substitution is performed" do | |
it "should decrement the num_subs on the game" do | |
@game.stub!(:num_subs).and_return(5) | |
@game.should_receive("num_subs=").with(4) | |
@team.do_substitution | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment