Ensuring Exclusive Current_User Access in Rails
Here’s our scenario. We have Users who can create and manage a list of stores like Kmart and Kroger’s. Store is a nested resource of Users with a path of /users/:user_id/stores Our objective is to...
View ArticleHandling Rails Date Selects in Capybara and RSpec
There are multiple ways to present dates in a Rails form. The default approach when scaffolding an object is to present the date as 3 dropdowns for date year, month and day. How to generate a test...
View ArticleTesting for Non-Routes in Rails
Here’s the setup. We have a Store Controller which allows all actions except Edit, so we want to ensure that Store#Edit is not a valid route. Another way of stating our intention is that we’re testing...
View ArticleAdding Custom Options to Rails Select Controls
Rails makes creating an HTML Select Control easy, but what about when you want to add custom options to the selection list? Also easy. Let’s look at an example of a Select list with not one but two...
View ArticleGood Stuff from The RSpec Book
David Chelimsky’s The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends (The Facets of Ruby Series) covers one of my favorite areas of Rails development. I thought I’d share...
View ArticleBook Highlights: Learning Rails 3
Learning Rails 3 by Simon St. Laurent and company is available from O’Reilly with a 4.3 out of 5 star rating. It’s a good book for beginners and anyone else who wants to relax reading about rails. Here...
View ArticleRSpec Testing for Filtered Selections
Here’s our scenario. We have a list of stores and a list of coupons by store. We’re going to use checkboxes on our list of stores and display only those store coupons. Our RSpec test is going to...
View ArticleTriggering Rails Flash Message on Empty Selection List
This post describes how to trigger a Rails Flash Message on the page based on certain criteria. Our criteria is that the user has to select as least one of the stores in the checkbox list. If he clicks...
View ArticleAccommodating Empty Selection Logic in RSpec
My controller RSpec tests were running great! The user selected items from a checkbox list, clicked a button and sent a PUT to the controller method. A record was created and the user was redirected to...
View ArticleCapybara Save and Open Page Thwarted by Test Failures
The Capybara Save_and_Open_Page function, displaying the state of the page as RSpec sees it can be really helpful. So when it’s not working it could cause a productivity hit. Here’s a little tip I...
View Article
More Pages to Explore .....