David Chelimsky: Integration Testing With Rspec’s Story Runner

Most of you know RSpec’s, the Rails plugin used for generating Unit test intuitive and elegant, through Story Runner RSpec it makes its avenue triumphant in the world of Integration Test.

Introduction:

This is a tool that integrates with BDD (Behaviour-driven-development), which is programming describing what the program expects from us. Dan North wrote JBehave, which inspired Story Runner. the BDD take part of the second generation expanding of agile technology.

RSpec started from a post from Dan Astels and is programmed from Steven Baker. It has started two years ago and is passed to David Chelimsky.

The prime mover that it is based on is the Feature Injection (Christ Matts): extracting the story from the functionality of the application and dividing this anecdote in the background.

How do they create this story? Using the methodology of why? Here is an precedent; let suppose that we want to originate a Rails application that manages the registry of people to the RailsConf and we apply to this the why methodology process:

“I scarceness the people to register” why? “I want to measure the influence at the conference.”

At this point it is necessary to create a narrative that describes in some way the extend of the abet affirmation.

Some Definitions:

Integration Testing: Make it in a way that the components function being in favor together (in reality David confirms that the are many different definitions of Integration Testing mete this is the one that is accepted from the Rails Community)

BDD: Before the code exists: Write what you expect from the code when the collection of laws is written: checking that the expectations are respected.

RSpec StoryTelling:

RSpec Story Telling is in essence a passage of describing the story that tells a particular run on the inside of our application. similar stories are mapped through DSL to the blocks of collection of laws. Following similar blocks you can determine if the application is additional or less coherent with the story described.

Here is an case in point:

  Story: Project As a user I fall short in to create projects In order to start planning Scenario: Create the first project as Account Admin Given demo_account_admin for the reason that current_user by password xxx And through all the projects archived When click on /accountadmin/projects/new And choose the project context And set name being of the kind which 'My first proof project' And set vision as 'The magnificent creation of RSpec' And post to /accountadmin/projects Then flash must contain 'Project successfully created' as info  

Each story is formated with: title, summary, and many scenarios that did not merit functionally but must follow a predefined structure (what is the objective? who is using the system? What is the action?

The scenario can use the following verbs: Give, When, Then that describe the initial conditions, actions and final conditions (anticipated).

The phrases formatted in the scenarios with these 3 verbs are then “linked” to blocks of code, some of the phrases can be imagined in a variable.

Some possible implementations:

Rails StoryTelling gives the possibility to access all the methods of Rails to all the methods of RSpec.

Webrat (Bryan Helmkamp), serves to manipulate the dom simulating the server-side navigation on the inside of the page.

In broad way of the Webrat you can use Selenium-RC, this option has its advantages (javascript support) and from confidence to the clients but pays its price in terms of slowness.

Annalisa