[rspec-users] Story Framework

Željko Filipin
Wed, 16 Apr 2008 08:04:49 -0000

I want to use story framework for driving my (functional) Watir tests. I
want to start with something simple, like logging in. I had an hour today to
try it, and I did not get very far. (I have found
http://rspec.info/documentation/stories.html and I will take a look at it
tomorrow.)

I have found basic information about story framework at rspec.info and
modified example from there. Am I on the right track?

login.txt:

Story: login user
  As registered user
  I want to log in
  So I can use the application

  Scenario: user name and password are correct
    Given my user name and password are correct
    When I enter user name and password at login page and click login button
    I should be logged in



define.rb:

steps_for(:user) do
  Given("my $username and $password are correct") do |username,
password|
    member = User.new(username, password)
  end
  When("I enter $username and $password at login page and click login
button") do |member|
    member.log_in
  end
  Then("I should be logged in") do |member|
    member.should be_logged_in
  end
end



run.rb:

with_steps_for :user do
  run ''rspec''
end



?eljko Filipin
--
ZeljkoFilipin.com
-------------- next part --------------
An HTML attachment was scrubbed...