README.rdoc

Path: README.rdoc
Last Update: Sun Oct 18 22:53:25 -0500 2009

Spectie

Spectie (rhymes with "necktie") is a pure Ruby BDD integration testing framework for RSpec.

Spectie was written with the following beliefs:

  • Business stakeholders or analysts are often not writing comprehensive (or any) acceptance criteria.
  • Business stakeholders or analysts are usually unwilling or unable to follow a strict format for writing the acceptance criteria that they are writing.
  • On many projects, the communication with the business stakeholders or analysts are accessible enough that written acceptance criteria is not necessary, but discussed requirements still need to be implemented, and therefore need to be tested.
  • Good developers recognize the benefits of top-down, BDD-style integration testing in helping to ensure that the code that is written to implement a feature directly satisfies business requirements, and doesn‘t get over-engineered or over-complicated.
  • Good developers love Ruby.

Spectie tries to strike the proper balance between writing readable tests, and just getting your work done in the most efficient way possible. It does this by providing a consistent structure for writing your integration test code in a BDD fashion, with the breakdown of features, scenarios, and their given/when/then statements. However, a little bit of syntactic sugar goes a long way to aid in the understanding of code, while too much can add unnecessary complexity and actually decrease maintainability. So, Spectie keeps things pretty close to the underlying technology at all times, since most of the time, it‘s a developer that‘s really writing the tests.

With these ideas in mind, what Spectie provides is:

  • A small number of methods on top of RSpec for making your integration tests readable. This isn‘t much more than "Given/When/Then".
  • A configuration and mapping layer for different integration testing code, such as what‘s provided by ActionController‘s integration.rb, or the Ruby client for Selenium.
  • Common functionality for supported integration testing solutions, such as the option to restart the Selenium browser between tests, or simply clear the cookies.

Advantages of having your integration tests written with Spectie:

  • It‘s Ruby.
  • If you‘re familiar with RSpec already, all the same functionality is available.
  • All new syntax beyond RSpec is kept to a minimum, and exists solely to facilitate developer-driven BDD.
  • Use familiar methods for code navigation and reuse.

Example

Rails

  Feature "Compelling Feature" do
    Scenario "As a user, I would like to use a compelling feature" do
      Given :i_have_an_account
      And   :i_have_logged_in

      When  :i_access_a_compelling_feature

      Then  :i_am_presented_with_stunning_results
    end

    def i_have_an_account
      @user = create_user
    end

    def i_have_logged_in
      log_in_as @user
    end

    def i_access_a_compelling_feature
      get compelling_feature_path
      response.should be_success
    end

    def i_am_presented_with_stunning_results
      response.should have_text("Simply stunning!")
    end
  end

Installation

Gem

  sudo gem install spectie

Rails plugin

  script/plugin install git://github.com/ryankinderman/spectie.git

Git

  git clone git://github.com/ryankinderman/spectie.git

Configuration

Ruby on Rails

In spec/spec_helper.rb, after require ‘spec/rails‘, add:

  require 'spectie/rails'

That‘s it. Spectie registers itself with RSpec, so you can run your integration tests with the usual rake spec:integration command. Also, all of the usual methods in a Rails integration testing session are available for you to use as well.

Selenium

TODO

Author

Ryan Kinderman (ryan@kinderman.net)

Copyright

Copyright (c) 2009 Ryan Kinderman. See LICENSE for details.

[Validate]