Forum: RSpec Testing Sub-domains with Cucumber

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.
2f030c2a9e4e1e165a0cb360805951f3?d=identicon&s=25 Tom Hoen (hoenth)
on 2009-01-14 02:46
My site uses sub-domains to create a context for the user. In my tests,
I need to stipulate what domain is being used, to test whether the
context is correct for the given user.

But I cannot find if and where i can change the request.host value, if
indeed, that is what I need to change.

When I say 'visits "/login"' in a step, I want it to have know to go to
harvey.localhost:3000 for this feature/scenario. In another
feature/scenario, I will want it to go to humbel.localhost:3000 etc.

What would you suggest.

All the best,
Tom
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-01-14 10:09
(Received via mailing list)
On 14 Jan 2009, at 01:46, Tom Hoen wrote:

> harvey.localhost:3000 for this feature/scenario. In another
> feature/scenario, I will want it to go to humbel.localhost:3000 etc.
>
> What would you suggest.


Are we on rails here, or something else? You might be better asking on
the webrat list (google group - check the webrat readme for details)
or IRC, to be honest.

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
2f030c2a9e4e1e165a0cb360805951f3?d=identicon&s=25 Tom Hoen (hoenth)
on 2009-01-14 14:20
Matt Wynne wrote:

>
> Are we on rails here, or something else? You might be better asking on
> the webrat list (google group - check the webrat readme for details)
> or IRC, to be honest.
>

Thanks Matt, I will send a message to the webrat group. It is rails, so
I have the same issue with view specs, but I am trying to solve the
Cucumber issue first, figuring it will help me with the specs.
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2009-01-14 15:48
(Received via mailing list)
On Jan 13, 2009, at 8:46 PM, Tom Hoen wrote:

> harvey.localhost:3000 for this feature/scenario. In another
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


I do:

host! "#{account.to_param}.example.com"

--linoj
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-01-14 16:55
(Received via mailing list)
On Tue, Jan 13, 2009 at 8:46 PM, Tom Hoen <lists@ruby-forum.com> wrote:
>
> When I say 'visits "/login"' in a step, I want it to have know to go to
> harvey.localhost:3000 for this feature/scenario. In another
> feature/scenario, I will want it to go to humbel.localhost:3000 etc.

Have you tried telling it "visits http://harvey.localhost:3000/login"
instead of just /login?

If that doesn't work: I remember having to spec some subdomain stuff
for a prior project.  Digging into the Rails code, I found the
TestRequest class, and saw in its initializer that by default it sets
the host to 'test.host'.  But it also sets up host as an accessor, so
you can set it to something else after the request gets created.

I'd leave off the :3000 port, though, unless you intend that to be
used in production as well.  If you're in the test environment and
making TestRequests you don't need it.

(And if you're in development mode and need to hit against a real
server, I've found my life got a whole lot simpler after I set up
Passenger.  No need to worry about starting up script/server or
hitting different ports, ever.)


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
2f030c2a9e4e1e165a0cb360805951f3?d=identicon&s=25 Tom Hoen (hoenth)
on 2009-01-14 17:39
Jonathan Linowes wrote:

> I do:
>
> host! "#{account.to_param}.example.com"
>
> --linoj

linoj - thanks for the info. Where do you put this?
387fb00ef9d6d523d43018d9c81ab36b?d=identicon&s=25 Jonathan Linowes (Guest)
on 2009-01-14 18:55
(Received via mailing list)
On Jan 14, 2009, at 11:39 AM, Tom Hoen wrote:

> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


for example,

Given /^a "(.+)" account$/ do |name|
   account = Account.create( :name => name )
   host! "#{account.to_param}.example.com"
end
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2009-01-28 15:32
Jonathan Linowes wrote:
> On Jan 14, 2009, at 11:39 AM, Tom Hoen wrote:
>
>> Posted via http://www.ruby-forum.com/.
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
> for example,
>
> Given /^a "(.+)" account$/ do |name|
>    account = Account.create( :name => name )
>    host! "#{account.to_param}.example.com"
> end

Can somebody point me to the documentation of host!, or explain what is
it.
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-01-28 17:00
(Received via mailing list)
On 28 Jan 2009, at 14:32, Juanma Cervera wrote:

> is
> it.

http://apidock.com/rails/ActionController/Integrat...!

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
This topic is locked and can not be replied to.