Your code may look like this:
1 # user.rb
2
3 self.name = name
4 self.login = login
5 self.password = password
6 save!
7 end
8
9 # user_spec.rb
10 it "should run my methods in #change_my_attributes in the correct order" do
11 @user = User.new
12 @user.should_receive(:name=) do
13 @user.should_receive(:login=) do
14 @user.should_receive(:password=) do
15 @user.should_receive(:save!)
16 end
17 end
18 end
19 @user.change_my_attributes('foo','bar','foobar')
20 end
Looks kind of ugly but it works...
2 comments:
Absolutely, ugly, but as long as it works ;-)
Perhaps it's time to write a matcher... :)
Post a Comment