Change request HTTP_HOST in tests.

34 views
Skip to first unread message

Peter

unread,
Mar 17, 2009, 3:51:28 AM3/17/09
to merb
Hello,

Please how can I change in my test the default domain "example.org" ?

I tried this request['HTTP_HOST'] = "test.example.org" in my before
(:each) do but it's not working.

wrong number of arguments (0 for 1)

Thanks,

Peter.

scottmotte

unread,
Mar 17, 2009, 10:13:45 AM3/17/09
to merb
This is something I'd love to know as well. I tried many different
combinations a month ago but with no success. Atmos mentions it is
possible, but after searching code source on github I haven't been
able to find any example usage of it.

http://atmos.org/index.php/2008/11/29/merb-10-controller-testing/

Shalon Wood

unread,
Mar 17, 2009, 11:07:30 AM3/17/09
to me...@googlegroups.com

Just use a full url:

response = request("http://playground.playground.pele.cx/blogposts/show/1", :method => "GET")

Shalon Wood
--

scottmotte

unread,
Mar 26, 2009, 4:42:14 PM3/26/09
to merb
Thank you Shalon!

To clarify to everyone, you, of course, need to use example.org
instead though as your test domain. So you could do:

def valid_site_attributes(options = {})
{
:domain => 'http://www.example.org',
:folder => 'exampleorg',
:subdomain => 'example',
:active => true,
:id => 1
}.merge(options)
end

given "current_site" do
Site.all.destroy!
@current_site = Site.create(valid_site_attributes)
end

describe "/payment", :given => 'current_site' do
before(:each) do
@response = request("http://example.example.org/payment")
end

it "should respond successfully" do
@response.should be_successful
end
end


And that will be green :)


On Mar 17, 8:07 am, Shalon Wood <ds...@pele.cx> wrote:
> Just use a full url:
>
>       response = request("http://playground.playground.pele.cx/blogposts/show/1", :method => "GET")
>
> Shalon Wood
>
>
>
>
>
> scottmotte <sc...@scottmotte.com> writes:
> > This is something I'd love to know as well. I tried many different
> > combinations a month ago but with no success.Atmosmentions it is
Reply all
Reply to author
Forward
0 new messages