Skip to content
This repository
Browse code

Rails 3.0.1 and up uses view_assigns instead of _assigns. This commit

supports both.
  • Loading branch information...
commit 7de6d053c2ad442517ad9906cd64ec04a752675e 1 parent f5ba00e
David Chelimsky dchelimsky authored
2  lib/rspec/rails/example/helper_example_group.rb
@@ -49,7 +49,7 @@ module InstanceMethods
49 49 # Returns an instance of ActionView::Base with the helper being specified
50 50 # mixed in, along with any of the built-in rails helpers.
51 51 def helper
52   - _view.tap {|v| v.assign(_assigns)}
  52 + _view.tap {|v| v.assign(view_assigns)}
53 53 end
54 54
55 55 private
10 lib/rspec/rails/view_assigns.rb
@@ -15,13 +15,19 @@ def assign(key, value)
15 15
16 16 private
17 17
18   - def _encapsulated_assigns
19   - @_encapsulated_assigns ||= {}
  18 + # === Rails-3.0.1 and up calls down to this
  19 + def view_assigns
  20 + super.merge(_encapsulated_assigns)
20 21 end
21 22
  23 + # === Rails-3.0.0 calls down to this
22 24 def _assigns
23 25 super.merge(_encapsulated_assigns)
24 26 end
  27 +
  28 + def _encapsulated_assigns
  29 + @_encapsulated_assigns ||= {}
  30 + end
25 31 end
26 32 end
27 33 end

2 comments on commit 7de6d05

Piotr Solnica

Are you saying they've changed the public API in a minor version upgrade?

David Chelimsky
Owner

3.0.1 will support both with a deprecation warning on _assigns.

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