How Do I Test Helpers In Rails?
I'm trying to build some unit tests for testing my Rails helpers, but I can never remember how to access them. Annoying. Suggestions?
In rails 3 you can do this (and in fact it's what the generator creates):
require 'test_helper' class YourHelperTest < ActionView::TestCase test "should work" do assert_equal "result", your_helper_method end end
And of course the rspec variant by Matt Darby works in rails 3 too
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?