rspec for "transactions"

15 views
Skip to first unread message

Dan Franko

unread,
Sep 16, 2014, 4:59:18 PM9/16/14
to rs...@googlegroups.com
Hello.  I've been struggling with this for quite some time and I'm hoping someone can help out.  The answer is probably right in front of me!  I'm using rspec with watir-webdriver for regression tests and I want to do something simple like create a ticket and then lookup that same ticket in an isolated manner.  Is this possible and what would be the best way to go about it?  I can do this with a differently scoped variable, but that doesn't appear to be the correct way to approach this.  Thanks!

describe "Ticketing system",:template do
before(:all) do
@b = Watir::Browser.start("google.com",:chrome)
end
it 'can create a ticket' do
@b.link(:text => "Create ticket")
ticket = @b.div(:id => "ticket").text
expect(ticket).to eql(123456)
end

it 'can lookup a created ticket' do
@b.text_field(:id => "search").set(ticket)
end

after(:all) do
@b.close rescue nil
end
end


Jon Rowe

unread,
Sep 16, 2014, 5:48:56 PM9/16/14
to rs...@googlegroups.com
The traditional way to do this would be to create a ticket in the second test without going through the browser (so using whatever database ORM/API you have), then check you can look it up. This avoids sharing state between the tests and creating a dependency between them.

Jon Rowe
---------------------------

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/1ec2fa65-8c60-4fda-aa83-5f074c0bb69a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages