Forum: RSpec testing multiple sessions in cucumber/webrat

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
57badfb3e8a4e8a81536f7dc6e47b812?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-02-28 21:16
(Received via mailing list)
Is it possible to have a scenario where you are testing the
interaction between two different session?

i.e.

Given User A clicks this link
Then User B should see this

It used to be possible, but don't know if it still is.

Joe
B8c4bfb1b6002a5b43d87de3335401f5?d=identicon&s=25 BJ Clark (Guest)
on 2009-03-01 02:19
(Received via mailing list)
Joe,I would test this in 2 steps.
I'd first test that whatever state change (or whatever happens when you
User
A clicks the link) takes place.
Then in another test, I'd check that, given a certain state (or again,
whatever is supposed to happen), then User B sees whatever.

HTH,
BJ Clark
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2009-03-02 02:18
(Received via mailing list)
So you're saying no?  :D
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2009-03-02 03:33
(Received via mailing list)
On Sun, Mar 1, 2009 at 8:04 PM, Joe Van Dyk <joevandyk@gmail.com> wrote:
> So you're saying no?  :D

It is possible, you simply have to logout from UserA and log in as
UserB. Also, although it's not exposed with webrat IIRC it is possible
to have selenium run to separate browsers at the same time. You could
theoretically have UserA and UserB logged in concurrently doing their
thing,

Zach



>>
>>> It used to be possible, but don't know if it still is.
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-03-02 04:48
(Received via mailing list)
Joe Van Dyk wrote:
> Joe
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

Have you tried creating a new webrat session?  I haven't looked into it
myself, but like you said it was possible.  Not much has changed with
the underling rails integration session so I imagine that if you just
created a new webrat session and used that for user B then you should be
fine.  (So, you will have to store this second session as an instance
var in the other session.. kinda odd but I would try it.)  I would be
interested to hear if this works, so please report back.  BTW, you might
get some better answers on the webrat mailing list.

-Ben
3880f04333bf8375b44cd6aa135406c7?d=identicon&s=25 Bart Zonneveld (Guest)
on 2009-03-02 15:17
(Received via mailing list)
On 28-feb-2009, at 21:04, Joe Van Dyk wrote:

> Is it possible to have a scenario where you are testing the
> interaction between two different session?

If you mean something along these lines:

User A uploads a picture,
User B logs in to see the picture uploaded by User A

that is possible.

I use this construct a lot to test-drive some revisions code I came
up with. Something like:

Given I am logged in
And     there is an article
And    the title of the article has been modified twice
When I  compare the revisions
Then  I should see the difference in title

GIven "the title of the article has been modified twice" do
   Given "I am logged in as an editor"

   2.times do |i|
     visit edit_article_path(@article)
     fill_in "Title", :with => "Title #{i}"
     click_button "Save"
   end

   Given "I am logged in as a writer"
end

cheers,
bartz
56ba4bd2ec5bbc31b48eb1b072096d77?d=identicon&s=25 Eric Kramer (cosmocracy)
on 2009-04-22 22:50
Joe Van Dyk wrote:
> Is it possible to have a scenario where you are testing the
> interaction between two different session?

Not sure if this is exactly what you need, but I found this technique to
be very handy:

   http://erikonrails.snowedin.net/?p=159

It involves mixing in a method to ActionController::Integration::Session
so that you can create a step definition that happens "outside" the
current session:

module ActionController
  module Integration
    class Session
      def in_a_separate_session
        old = @response.clone
        yield
        @response = old
      end
    end
  end
end

Here's a sample usage from his page:

Then /^I should be logged in$/ do
  in_a_separate_session do
    Given "I visit /users/me"
    Then "I should see \"You are logged in\""
  end
end
This topic is locked and can not be replied to.