Routing rspec with nested routes

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


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:


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

Solution adapted from here

minitest assert_routing with method included in path

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


When trying to use the minitest assert_routing with the first parameter representing the path as a hash that includes both the path and the method, and run the tests rails complains about SyntaxErrors.

When trying to use it as suggested in the ‘Rails 4 Test Prescriptions’ Pragmatic Programmers book (p. 172 – Minitest and Routing) which is:

the error is:

even when trying to have the second parameter as a hash:

the error is similar:


Seems that you need to pass the parameters enclosed in brackets, so the following would work:

Book Review: BDD in Action by John Ferguson Smart (Manning)

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

As the subtitle of the book ‘Behavior-driven development for the whole software lifecycle’ suggests, this is a book describing Behaviour Driven Development for the different phases of software development.

It starts with a very general description of BDD, the problems that it addresses, the general principles and the origins of it, as well as the pros and cons in different organisations and team scenarios. Throughout this general description there are plenty of references and links for anyone wishing to have more details.

This is followed by a real life project, that goes through the phases of requirement analysis, creation of the features, stories and examples and the distinction and differences between each of them. There are various techniques described, including Feature Injection for identifying business goals and supporting features, Impact Mapping for high-level requirement visualisation, Purpose-Based Alignment Model for judging how much effort you should put into different features, and the identification of stakeholders and their roles. There is also a description about Real Options and Deliberate Discovery principles.

There are more detailed examples to automating scenario steps, described in different languages (Java, Python, .NET, Javascript) and diffent tools (JBehave, Cucumber-JVM, Behave, SpecFlow and Cucumber-JS). These are used to go from executable specifications to automated acceptance tests. There two separate chapters following that, describing the two different ways for automating the acceptance criteria depending on whether they are for the UI layer or the non-UI requirements.

Last but not least, there is a chapter dedicated to explaining the relationship between BDD, TDD and Unit Testing, another one describing the idea of living documentation, as well as reporting and project management, and finally the role of BDD in continuous integration (CI) and continuous delivery.

Throughout the text there are a lot of diagrams to help explain the ideas better, as well as a lot of references for more detail. Even though most of the examples are based in Java, the principles, ideas and techniques are easily applied to other languages and tools.

So, in summary this is a very useful book for anyone wanting to learn how Behaviour Driven Development can be used in practise. There are different sections that are targeted to different roles from business stakeholders, to testers and to developers. Hopefully when your whole team reads this book, the whole idea of BDD can be understood better, and used to build the software right as well as build the right software.

Disclaimer: This book was reviewd under the Manning reviewers program.