[rspec-users] how to set up data before story runner steps?

Bei libei.twer at gmail.com
Tue Feb 26 23:53:36 EST 2008


Hi

     I'm using story runner of RSpec now. What I'm trying to do is
initializing the @selenium before any steps of one story is executing,
and stop @selenium after any story is finished. just as @BeforeClass
and @AfterClass in jUnit
     Any suggestions on this?

     Thanks!!!


Bei

here is my code for
STEPS:

     steps_for(:search) do

    Given("user could access search page") do
        @google_page = GooglePage.new(@selenium)
        @google_page.open;
    end

    Given("user enter search test: $search_text") do |$search_text|
        @google_page.search_text=$search_text
    end

    When("do search") do
        @search_result_page =  @google_page.search
    end

    Then("show search result") do
        @search_result_page.should_not == nil
    end
end


STORY:

  Story: #000
      As A command human
      I want to get information quickly
      So that I could save me time on doing real things

  Scenario: could search
      Given user could access search page
      And user enter search test: asdfasdfasdfas
      When do search
      Then show search result


GLUE:
  with_steps_for :search do
      run 'stories/000.story'
  end




More information about the rspec-users mailing list