Our Blog

Fix for annoying bug in EmailSpec

EmailSpec with Cucumber is a great combo. How else could you get such nice BDD syntax such as;

Scenario Outline: Register new user
Given I am on the signup page
And I fill in "Email" with ""
And I fill in "Password" with ""
And I press "Create My Account"
Then I should
And I should receive an email
When I open the email
Then I should see "Please activate your new account" in the subject
When I click the first link in the email

And if you happen to be using EmailSpec 0.3.5 and you're getting an error like this, I may have a solution for you;

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include? (NoMethodError)
/Users/glennroberts/.gem/ruby/1.8/gems/glennr-email_spec-0.3.5/lib/email_spec/deliveries.rb:45:in `mailbox_for'
/Users/glennroberts/.gem/ruby/1.8/gems/glennr-email_spec-0.3.5/lib/email_spec/deliveries.rb:45:in `select'
/Users/glennroberts/.gem/ruby/1.8/gems/glennr-email_spec-0.3.5/lib/email_spec/deliveries.rb:45:in `mailbox_for'
/Users/glennroberts/.gem/ruby/1.8/gems/glennr-email_spec-0.3.5/lib/email_spec/helpers.rb:138:in `mailbox_for'
/Users/glennroberts/.gem/ruby/1.8/gems/glennr-email_spec-0.3.5/lib/email_spec/helpers.rb:48:in `unread_emails_for'
./features/step_definitions/email_steps.rb:52

I fixed the offending bug - grab the code either at Gemcutter

gem install glennr-email-spec

or via GitHub

http://github.com/glennr/email-spec

If you're reading this Mr Mabey, please include in the next email-spec patch :-)

Loading mentions Retweet
Posted by Glenn Roberts 

Comments (1)

Feb 01, 2010
Chris Small said...
Hey - I'm getting a similar error with email_spec 0.4. Do you know if your modifications were committed since 0.3.5?

Also, I tried using your gem but have had some problems getting it recognized. I did

config.gem 'glennr-email_spec', :lib => 'glennr-email_spec'

in my cuke config file and then neither requiring "email_spec/cucumber" nor "glennr-email_spec/cucumber" in my env.rb file worked for me. Tried a few other variations as well but only got errors to the effect that the gem glennr-email_spec is missing, even though I can see it in gem list.

Could pass along a little extra help?

Chris

Leave a comment...

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     twitter