Skip to content

Commit

Permalink
Rails 3.0.1 and up uses view_assigns instead of _assigns. This commit
Browse files Browse the repository at this point in the history
supports both.
  • Loading branch information
dchelimsky committed Oct 2, 2010
1 parent f5ba00e commit 7de6d05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rspec/rails/example/helper_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module InstanceMethods
# Returns an instance of ActionView::Base with the helper being specified
# mixed in, along with any of the built-in rails helpers.
def helper
_view.tap {|v| v.assign(_assigns)}
_view.tap {|v| v.assign(view_assigns)}
end

private
Expand Down
10 changes: 8 additions & 2 deletions lib/rspec/rails/view_assigns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ def assign(key, value)

private

def _encapsulated_assigns
@_encapsulated_assigns ||= {}
# === Rails-3.0.1 and up calls down to this
def view_assigns
super.merge(_encapsulated_assigns)
end

# === Rails-3.0.0 calls down to this
def _assigns
super.merge(_encapsulated_assigns)
end

def _encapsulated_assigns
@_encapsulated_assigns ||= {}
end
end
end
end
Expand Down

2 comments on commit 7de6d05

@solnic
Copy link
Contributor

@solnic solnic commented on 7de6d05 Oct 2, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@dchelimsky
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.0.1 will support both with a deprecation warning on _assigns.

Please sign in to comment.