Assigns in Ruby on Rails — How you can test instance variables in views and controllers

More from: | HackerNoon |
0

Ruby on Rails has special helper methods that allow you to test instance variables in your app’s views and controllers. These are assign and assigns, which stores a hash of the instance variables you can access in your RSpec tests.

This tutorial will guide you through how to write a simple controller and view with corresponding tests. These will cover assigning instance variables depending on whether certain conditions are met.

How assign and assigns works

If you want to set a

(...)

Read full article » https://hackernoon.com/assigns-in-ruby-on-rails-how-you-can-test-instance-variables-in-views-and-controllers-13450a6b2472?source=rss----3a8144eabfe3---4


About | HackerNoon |

...how hackers start their afternoons....

»Twitter: @hackernoon »Facebook: @hackernoon