[rspec-users] session data and user stories

Evan Short evan.short at gmail.com
Wed Jan 16 17:59:23 EST 2008


hello there,

i have been trying my hand at this rbehave material, specifically in terms
of integration testing a rails application, and i am curious about the most
friendly way to deal with session data.

currently, the only way i have found to simulate a session is to open a
session and refer to everything afterward via the @session variable stored
after open_session. it seems to be workable, but is far from ideal:

dir = File.dirname(__FILE__)
require 'rubygems'
require 'spec/story'
require "#{dir}/helper"

steps_for(:dealer_login) do
    Given("I have opened a session") do
      @session = open_session
    end

    Given("I am not logged in") do
      @session.instance_variable_get("@session").should == nil
    end

    Given("I have a valid login/password combo") do
      @login_with = valid_dealer_credentials
    end

    When("I submit my login/ password") do
      @session.post("/gateway", :user=> @login_with)
    end

#there has to be a better way to address this
    Then("I should be authenticated") do
      @session.response.session.data.should == {:id => 1, "flash" => {}}
    end

#and this is just hideous.
    Then("I should be sent to the dealer landing page") do
      puts @session.response.instance_variable_get("@redirected_to").should
== {:controller => "dealers"}
    end
end

with_steps_for(:dealer_login) do
    run_local_story "dealer_story", :type=>RailsStory
end

there is a good chance someone has already covered this and i have just
managed to miss it. documentation on rbehave is sparse (at best, as i have
seen it. i have the peepcode, but if anyone has any other good resources i
would be more than appreciative.)

in the event that this has not been addressed, i see two possibilities:

first, that i am somehow subverting the intention of rbehave. as i
understand it, however, rbehave is at least partially intended for
integration-level specification, so it seems to me that this session
information would be valuable.

on the other hand, perhaps this needs to be addressed in some way. i would
be happy to help, but i am interested to see the community's opinion on the
issue first.

regards,
evan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080116/ed685b34/attachment.html 


More information about the rspec-users mailing list