hello there,<br><br>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.<br><br>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:
<br><br><tt>dir = File.dirname(__FILE__)</tt><br>
<tt>require 'rubygems'</tt><br>
<tt>require 'spec/story'</tt><br>
<tt>require "#{dir}/helper"</tt><br>
<br>
<tt>steps_for(:dealer_login) do</tt><br>
<tt> Given("I have opened a session") do</tt><br>
<tt> @session = open_session</tt><tt></tt><br>
<tt> end</tt><br>
<br>
<tt> Given("I am not logged in") do</tt><br>
<tt> @session.instance_variable_get("@session").should == nil</tt><br>
<tt> end</tt><br>
<br>
<tt> Given("I have a valid login/password combo") do</tt><br>
<tt> @login_with = valid_dealer_credentials</tt><br>
<tt> end</tt><br>
<br>
<tt> When("I submit my login/ password") do</tt><br>
<tt> @session.post("/gateway", :user=> @login_with)</tt><br>
<tt> end</tt><br>
<br>#there has to be a better way to address this<br>
<tt> Then("I should be authenticated") do</tt><br>
<tt> @session.response.session.data.should == {:id => </tt><tt>1, "flash" => {}}</tt><br>
<tt> end</tt><br>
<br>#and this is just hideous. <br>
<tt> Then("I should be sent to the dealer landing page") do</tt><br>
<tt> puts @session.response.instance_variable_get</tt><tt>("@redirected_to").should == {:controller => "dealers"}</tt><br>
<tt> end</tt><br>
<tt>end</tt><br>
<br>
<tt>with_steps_for(:dealer_login) do</tt><br>
<tt> run_local_story "dealer_story", :type=>RailsStory</tt><br>
<tt>end</tt>
<br><br>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.)
<br><br>in the event that this has not been addressed, i see two possibilities:<br><br>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.
<br><br>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.<br><br>regards,<br>evan<br><br>