If you are writing you own mix-in modules in Rails3 and haven’t taken a look at ActiveSupport::Concern yet, I recommend checking out this blog posting for an outline of why you should be using it:
If you are already using this then good for you and you can continue on.
Here’s a little “stumbling block” with ActiveSupport::Concern that I found the other day that I wanted to share with people. If you have the following code:
You might expect the puts to write out “Baz” but it writes out nil instead. Why is that? It has to do with the order in which ActiveSupport::Concern tacks all of the module code into the class including the module. If you
change “attr_accessor” to attr_writer” all works as planned.
So yes you might be saying “why do you have attr_accessor when you define a getter method for baz?” and my response is “because it worked ok before I factored the code out into a module for reuse”.
The has_css? method call will wait until the element shows up and if it doesn’t show up before the Capybara timeout expires then it will return false.
For some reason the Universe keeps sending great Cucumber related stories to me via Twitter.
Here is another great one from the folks at Square on how to test Resque based functionality via Cucumber:
I found this article to be quite enlightening about the use of Cucumber , and more specifically the “verbiage” of Cucumber features.
Make sure you read down through the comments as there are some interesting replies from both the people behing Cucumber and Pickle.
I’ve always gotten that “not so fresh” feeling when including CSS selectors in my Cucumber features and now I have a reason why.
This article becomes really important if you start to have your clients define their Tracker stories as Cucumber features, something I am toying with right now. Just think of how much development time you could save if all you needed to do was copy/paste a feature from Tracker into a feature file. Sure it may never happen 100% of the time but even if it only 10% of the time it is still more than 0%.
Try adding the following to your Gemfile:
gem 'thin', :group => :test
and see what happens.
The other day I was looking to test some rescue_from functionality in a subclass of ApplicationController and found an easy way to set this up, the controller() method.
Note: Testing of ApplicationController subclasses is a new addition and not available in a released beta of rspec-rails2 as of the writing of this post.