public
Rubygem
Description: RSpec extension library for Ruby on Rails
Homepage:
Clone URL: git://github.com/dchelimsky/rspec-rails.git
don't mutate hash passed to mock_model
jerryvos (author)
Thu Jun 12 22:31:03 -0700 2008
pat-maddox (committer)
Mon Aug 11 15:00:03 -0700 2008
commit  705355b75b7555940a1d49442ffe5ef5ccccd7a7
tree    a890fb741b61c79dfd33ee8c95a64dd96c277932
parent  2b25c672537fa3e4ce0341263e890aaa052a8b3e
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@ module Spec
0
       # add_stubs) if +stubs+ is passed.
0
       def mock_model(model_class, options_and_stubs = {})
0
         id = options_and_stubs[:id] || next_id
0
-        options_and_stubs.reverse_merge!({
0
+        options_and_stubs = options_and_stubs.reverse_merge({
0
           :id => id,
0
           :to_param => id.to_s,
0
           :new_record? => false,
...
25
26
27
 
 
 
 
 
 
 
 
28
29
30
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
0
@@ -25,6 +25,14 @@ describe "mock_model" do
0
   end
0
 end
0
 
0
+describe "mock_mode with params" do
0
+  it "should not mutate its parameters" do
0
+    params = {:a => 'b'}
0
+    model = mock_model(MockableModel, params)
0
+    params.should == {:a => 'b'}
0
+  end
0
+end
0
+
0
 describe "mock_model with stubbed id", :type => :view do
0
   before(:each) do
0
     @model = mock_model(MockableModel, :id => 1)

Comments