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

More from: | HackerNoon |

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 »

About | HackerNoon | hackers start their afternoons....

»Twitter: @hackernoon »Facebook: @hackernoon