Since launching Ruby Science we’ve written and released five new chapters. If you’ve previously purchased the book, you can log into GitHub to download the latest version.
Here’s what we’ve added:
The book is a work in progress, and we’ve now got around 60 pages of content. The purchase also includes an example application and support for any Ruby, Rails, and Refactoring questions you have. You can get access now for an early purchase price of $39. This will increase to $49 on January 31, 2013.
Download a free sample of Ruby Science today.
One way to make tests faster is to avoid loading and submitting the sign in form during the setup phase.
This back door inserts Rack middleware into a Rails app that uses Clearance:
# config/environments/test.rb class ClearanceBackDoor def initialize(app) @app = app end def call(env) @env = env sign_in_through_the_back_door @app.call(@env) end private def sign_in_through_the_back_door if user_id = params['as'] user = User.find(user_id) @env[:clearance].sign_in(user) end end def params Rack::Utils.parse_query(@env['QUERY_STRING']) end end MyRailsApp::Application.configure do # ... config.middleware.use ClearanceBackDoor # ... end
Then, include a user in an
as parameter in integration tests:
visit root_path(as: user)
It works for any URL:
visit new_feedback_path(as: giver)
This is similar to Mislav’s approach except the Rack middleware works with Rails routing constraints.
On one project using this technique, the total test suite time was reduced 23%.
Written by Dan Croak.
We’ve just opened registration for our new online Test-Driven Rails workshop, which starts Monday, November 26th, 2012.
The course is taught by Josh Clayton, the maintainer of FactoryGirl, shoulda contributor, and experienced Rails developer. Over the course of a month you will code two Rails applications alongside Josh, working directly with him to learn TDD or improving your TDD practice. This isn’t just a series of videos; it’s an online workshop where you work directly with Josh getting one-on-one and group support.
Because the workshop takes place over the course of an entire month, it strikes a nice balance between making a ton of progress and working at a pace that will work around your schedule. There will also be additional time throughout the week to explore the nooks and crannies of TDD, helped along by Josh and the rest of the thoughtbot team.
Furthermore, when you take an online workshop with thoughtbot, it doesn’t just stop after the initial month. You get ongoing support for any testing questions you may have in the future, from Josh and the rest of the thoughtbot team.
We’d love to have you take this course. You can sign up now and the course begins Monday, November 26th, 2012.