Cucumber and subdomains

7 views
Skip to first unread message

Chris Booth

unread,
Apr 28, 2009, 4:58:05 PM4/28/09
to Orlando Ruby Users Group Discussion
Hey folks,

I'm trying to user cucumber/webrat to test a project that uses
subdomains. I've set up the local subdomains in my hosts, and they
work fine through a browser, so I'm pretty sure that's all configured
properly. However, I'm having issues with the tests passing. I set
up the following scenario:

Scenario: URL with no subdomain
Given I visit http://www.example.dev:3000
Then I should see "promo site"

and added the following custom step definition:

Given /^I visit (.*)$/ do |url|
if url.match(/^http:\/\//)
session = Webrat::MechanizeSession.new
session.visit(url)
response = session.response
else
visit url
end
end

The visit step is passing, but the "I should see..." step fails.
Putting this URL in my browser does indeed show the correct text, so
I'm pretty sure I've dorked something in the test itself. Any ideas
what I'm doing wrong here?

Thanks,

Chris

Tim Rosenblatt

unread,
Apr 29, 2009, 12:59:03 AM4/29/09
to orug-di...@googlegroups.com
Hey Chris,

I can't help with this current issue yet, but I am looking into how to follow external redirects. I have a system that uses Twitter OAuth (twitterauth gem) for logins, and I want to have Cucumber log in to Twitter and then come back and do work on the site.

So far, it seems that Cucumber has several different types of redirect handling, and there are 4 different ways of following redirects.

If anyone else has info, please chime in. Also Chris, feel free to get in touch with me and we might be able to pair program/get this sorted out. Got VNC?

-- Tim
--
Tim Rosenblatt
http://www.timrosenblatt.com

Chris Booth

unread,
Apr 29, 2009, 12:28:13 PM4/29/09
to Orlando Ruby Users Group Discussion
Pairing on this would be awesome. I don't have VNC on my dev machine
yet but I can get it no prob. Should I just email you to try and
schedule some time?

Thanks for the offer!

Chris

On Apr 29, 12:59 am, Tim Rosenblatt <t...@timrosenblatt.com> wrote:
> Hey Chris,
>
> I can't help with this current issue yet, but I am looking into how to
> follow external redirects. I have a system that uses Twitter OAuth
> (twitterauth gem) for logins, and I want to have Cucumber log in to Twitter
> and then come back and do work on the site.
>
> So far, it seems that Cucumber has several different types of redirect
> handling, and there are 4 different ways of following redirects.
>
> If anyone else has info, please chime in. Also Chris, feel free to get in
> touch with me and we might be able to pair program/get this sorted out. Got
> VNC?
>
> -- Tim
>
>
>
> On Tue, Apr 28, 2009 at 4:58 PM, Chris Booth <regis...@boothclan.com> wrote:
>
> > Hey folks,
>
> > I'm trying to user cucumber/webrat to test a project that uses
> > subdomains.  I've set up the local subdomains in my hosts, and they
> > work fine through a browser, so I'm pretty sure that's all configured
> > properly.  However, I'm having issues with the tests passing.   I set
> > up the following scenario:
>
> >    Scenario: URL with no subdomain
> >        Given I visithttp://www.example.dev:3000

Chris Booth

unread,
May 6, 2009, 10:23:27 AM5/6/09
to Orlando Ruby Users Group Discussion
Thought I'd post the solution I found if anyone else runs into this
issue. I'm sure that there are other (probably better) ways to do
this, but this one worked for me:

http://gist.github.com/107539

Any feedback would be appreciated!

--Chris

Tim Rosenblatt

unread,
May 7, 2009, 12:37:06 PM5/7/09
to orug-di...@googlegroups.com
You sir, are a rockstar. Thx.

Chris Booth

unread,
May 7, 2009, 2:32:08 PM5/7/09
to Orlando Ruby Users Group Discussion
well thanks! (So when do the groupies arrive?)

Tim Rosenblatt

unread,
May 7, 2009, 4:26:35 PM5/7/09
to orug-di...@googlegroups.com
Not sure. We *are* in Vegas. Anyone have an extra suitcase? We could bring you some.
Reply all
Reply to author
Forward
0 new messages