Having spent hours writing cucumber tests and finding out that it all doesn't work with Rails 3.1 RC5 is frustrating. It disrupts the flow of things. In my mind all I wanted was to move on to focus on new features. Not being able to write tests for the new features because of incompatibility issues is just hell. That's the only reason why I started using Steak yesterday for acceptance tests.

But now I found at least 2 more reasons why I shouldn't be using cucumber:

1) We communicate ideas and stories in the language and order we want to. By that I mean we speak usual conversational English. There is no reason to read specific user stories that use a lot of "and" and "then." This is something my clients simply DON'T appreciate.

2) Steak is a lot more simple. Less verbose and therefore some time should be saved.

3) If I work for myself and I am a programmer, why should I ever want to read cucumber stories? I see no need for it.

Getting a Rails 3 .1 app working with Steak is fairly simple if you follow the docs on github. Just update rspec.rake to make sure "rake spec:acceptance" works.

Click here to check the update.

Updated spec/acceptance/acceptance_helper.rb

require 'spec_helper'
require 'email_spec'

# Put your acceptance spec helpers inside spec/acceptance/support
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

Updated spec/acceptance/support/helpers.rb

My RSpec config file looks a bit like this:

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
  config.include Warden::Test::Helpers, :type => :acceptance
  config.after(:each, :type => :acceptance) { Warden.test_reset! }
  config.include EmailSpec::Helpers
  config.include EmailSpec::Matchers

Here's how to reset password feature (Devise defaults have not changed). I've removed other tests relevant to password reset and just kept one which shows how to test emails.

require 'acceptance/acceptance_helper'

feature 'Password Reset' do

  background do
    @user = Factory(:user, email: "[email protected]") 

  scenario 'user should receive an email and successfully reset password' do


    visit '/new_password'
    fill_in "user[email]",  with:  @user.email
    click_button "Submit"

    unread_emails_for(@user.email).size.should >= parse_email_count(1)
    email_should_have_body("Someone has requested a link to change your password, and you can do this through the link below.")

    within('body') do
      page.should have_content('Change Your Password')

    fill_in "user[password]", with: "password"
    fill_in "user[password_confirmation]",  with:  "password"
    click_button "Change Password"

    within('body') do
      page.should have_content('Your password was changed successfully.')


comments powered byDisqus

Hello! I am Kat. I've been a developer for several years. When I'm not sitting down, reading and working for long hours, I am traveling to some place of interest.
If you want to reach out, you can send me an email or add me up on Google Plus.