Routing rspec with nested routes

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You would like to add a routing rspec test in your rails application that tests for a nested route.
So while you have something like the following in your config/routes.rb file:

you want to add the following test for your route:

but you are getting an error like the following:

Solution

You will need to change your rspec to the following using any number for the user_id:

Solution adapted from here

make the unpermitted parameters errors in Ruby on Rails more obvious

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

When you are adding new attributes to your model after the initial creation, they are not by default included in the permitted parameters list. Sometimes the error is not so obvious to see when testing, unless you look at the test log files.

Solution

To make the error more obvious, there is the following configuration option that you can set up in config/environments/test.rb (tip taken from Rails 4 In Action):

Cucumber testing and ssl

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

Your application is ussing force_ssl to redirect all calls to ‘https’, but when you try to use your cucumber tests they fail.

Solution

By using the suggestion here, you can add a file in your initializers to bypass the ssl in development and test environment as follows:

Could not open library ‘libgtkmm-2.4.so’: libgtkmm-2.4.so: cannot open shared object file: No such file or directory.

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

If you have setup guard with your Rails project and you are trying to run it in an (K)Ubuntu installation you get the following message:

Solution

Install the missing library with the following:

assert_difference and Rails 2.1.0

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
Trying to use the assert_difference with Rails 2.1.0 produces errors if trying to use it with the syntax of another rails version.

Solution
The correct syntax for using assert_difference with rails 2.1.0 is: