Skip to content

Commit

Permalink
Simplify stub_model so it just sets the stubs you set.
Browse files Browse the repository at this point in the history
- There is really no benefit from the attribute/non-attribute
  distinction when setting stubs.
- This helps to make stub_model usable with non-ActiveRecord models

Closes rspec#108.
  • Loading branch information
dchelimsky committed Jul 4, 2010
1 parent 72e60f4 commit 072286d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/rspec/rails/mocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,7 @@ def stub_model(model_class, stubs={})
returning model_class.new do |m|
m.id = stubs.delete(:id)
m.extend ModelStubber
stubs.each do |k,v|
if m.has_attribute?(k)
m[k] = stubs.delete(k)
end
end
m.stub!(stubs)
m.stub(stubs)
yield m if block_given?
end
end
Expand Down

0 comments on commit 072286d

Please sign in to comment.