Translating cucumber to rspec

How to write the following feature in rspec?

Feature: Signing in; In order to use the site as a user, I want to be able to sign in

  Scenario: Signing in via confirmation
    Given there are the following users:
      |email            |password|
      | |password|
    And "" opens the mail with subject
      "Confirmation instructions"
    And they click the first link in the email
    Then I should see "Your account was successfully confirmed"
    And I should see "Signed in as"


This looks like the feature from the first edition of Rails 3 in Action, which I'm currently re-writing into a second edition. The second edition's feature goes like this:

feature 'Signing in' do
  before do
    Factory(:user, :email => "")

  scenario 'Signing in via confirmation' do
    open_email "", :with_subject => /Confirmation/
    page.should have_content("Your account was successfully confirmed")
    page.should have_content("Signed in as")

This is using Capybara's new feature syntax, which for all intents and purposes is the same as RSpec's context blocks. By using a before you set up a user that you can use inside this feature. Inside the scenario, you use the open_email method (provided by the email_spec gem) to open the email, and the click_first_link_in_email method also provided by that gem to perform those two steps.

That then takes you to a page where you should be able to see the two messages as so desired.

Give turnip gem a try.

Turnip is a Gherkin extension for RSpec. It allows you to write tests in Gherkin and run them through your RSpec environment. Basically you can write cucumber features in RSpec.

Need Your Help

Abusing soversion minor revision to support optional dependencies

c++ plugins shared-libraries versioning dependency-management

I am writing a C++ package with a number of optional dependencies. It is important to be able to use the package without any of these dependencies and then be able to add dependencies without recom...

how to solve a eqaution of a parabola that passes through 3 points?


how do you find a equation of a parabola that passes through theses points: ( .0344,.9285), ( .4014, 1.4672), (1.002, -0.313).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.