Created
April 22, 2013 01:46
-
-
Save takkanm/5431923 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
#検証したいUserクラス | |
class User < ActiveRecord::Base | |
belongs_to :room | |
def wait(room) | |
room.wait | |
self.room = room | |
end | |
end | |
describe User do | |
let(:user) { User.new } | |
describe '#wait' do | |
#beforeで呼ぶとshould_receiveが検証できず困る | |
#before { subject.wait(room) } | |
let(:room){ mock_model(Room) } | |
let(:wait_action) { user.wait(room) } | |
it "引数のroomのwaitが呼ばれること" do | |
room.should_receive(:wait) | |
user.wait(room) | |
end | |
it 'roomがセットされること' do | |
expect { | |
user.wait(room) | |
}.to chage(user, :room).to(room) | |
end | |
describe 'room' do | |
before { user.wait } | |
subject { user.room } | |
it { should eq room } | |
end | |
#afterで呼ぶとsubject.roomが設定されているかがわからず困る | |
#after { subject.wait(room) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment