Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mock_model(XXX).as_null_object.unknown_method returns self

- Fixes #488.
  • Loading branch information...
commit 7fa15c41572b91d5deba2f4b28ae93bff4cd610e 1 parent c9b47d6
@dchelimsky dchelimsky authored
View
7 Changelog.md
@@ -1,3 +1,10 @@
+### dev
+
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.8.1...master)
+
+Bug fixes
+* mock_model(XXX).as_null_object.unknown_method returns self again
+
### 2.8.1 / 2012-01-04
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.8.0...v2.8.1)
View
2  lib/rspec/rails/mocks.rb
@@ -132,7 +132,7 @@ def @object.respond_to?(method_name, include_private=false)
end unless #{stubs.has_key?(:respond_to?)}
def @object.method_missing(m, *a, &b)
- respond_to?(m) ? nil : super
+ respond_to?(m) ? null_object? ? self : nil : super
end
def @object.class
View
5 spec/rspec/rails/mocks/mock_model_spec.rb
@@ -234,6 +234,11 @@
it "says it will not respond_to?(xxx_before_type_cast)" do
@model.as_null_object.respond_to?("title_before_type_cast").should be(false)
end
+ it "returns self for any unprepared message" do
+ @model.as_null_object.tap do |x|
+ x.non_existant_message.should be(@model)
+ end
+ end
end
end

3 comments on commit 7fa15c4

@pisaruk

Hello David,

Do you have plans to release a new version including this bug fix?
I will downgrade from 2.8.1 to 2.7 because my rspec has became unsable due to this small bug.
Tks.

@dchelimsky
Owner

@pisaruk not sure when the next release is going to be, but you can point your Gemfile at git in the mean time:

gem "rspec-rails", :git => "https://github.com/rspec/rspec-rails.git"
@pisaruk

Thank you. I appreciate your prompt reply.

Please sign in to comment.
Something went wrong with that request. Please try again.