Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Can't use ERBUtil methods in helper specs #597

Closed
ngan opened this Issue · 3 comments

2 participants

@ngan

I can't seem to use ERBUtils methods like h or html_escape inside my helper specs.

For exampe....

helper.link_to_custom("<b>hello</b>").should == link_to(html_escape("<b>hello</b>"))

This will raise undefined method for html_escape.

@dchelimsky
Owner

RSpec's helper specs wrap Rails' helper tests. This would make more sense to fix there, so please submit this to the Rails issue tracker.

FYI if you do - Rails' helper specs work a bit differently - instead of exposing a helper object, they include the helper module right in the test so your example would look like this:

assert_equal link_to(html_escape("<b>hello</b>")), link_to_custom("<b>hello</b>")
@dchelimsky dchelimsky closed this
@ngan

Thanks David!

rails/rails#7330

@ngan

Hey David, rails doesn't include it into TestCase--as for the reason, I'm not really clear. And I'm not sure if they even consider it a bug.

In any case, now that I think about it, perhaps rspec should fix this "issue.". Rspec takes the extra mile and does the right thing by giving you a helper method that encapsulates the helper scope. To the rspec user, there's no knowledge that the helper inherits from rails TestCase, and they shouldn't. Rspec-rails promises the entire helper context inside helper and it should fix what rails TestCase lacks.

Just my opinion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.