Michael Klishin <[email protected]> writes:
> On 25.01.2009, at 19:01, Shalon Wood wrote:
>
>> 1) Is it possible to wrap up the steps needed to login as a given user
>> so that I can just say 'Given I am logged in as <foo>', rather than
>> putting in all the steps needed in each scenario?
>>
>
> you can use global Before step but I'd keep authentication step
> as visible as possible
Hmm. The thing is, that's fairly long:
Given I am not authenticated
When I go to http://playground.playground.pele.cx/login
And I fill in "username" with "<mail>"
And I fill in "password" with "<password>"
And I press "Log In"
All before I start the stuff that's actually relevant to the scenario in
question, which is why I was hoping to be able to say 'Given I am logged
in as <foo>'.
>
>> 2) Alternatively, how do I set a cookie so that I don't need to visit
>> /login, etc?
>>
>
> You can use Merb's #request method from Cucumber which takes :jar option
> and tracks cookies betweet requests. If you use subdomains, you'd have
> to
> patch Merb core's test helper a little to use configurable default
> host instead of example.org,
> because otherwise cookies are set for one domain, but next request
> uses a different one,
> and cookie do not match => your authentication does not work.
Hmm. I'm actually using full urls in each feature, since I do use
subdomains, so would that actually be a problem?
As for using :jar in the #request method, I wasn't able to get that
working in my controller tests, but I also wasn't able to find an
example of how to use it anywhere -- can you point me to one? That would
work fine, as I'd just write a Given step that set it.
>
>> 3) Is it possible to use Cucumber/Webrat to test making
>> xml_http_requests, so that I can test that my actions do the right
>> thing
>> both for xml_http_requests and ordinary requests? E.G.,
>> Paragraphs#update returns the edited paragraph block for an
>> xml_http_request (most of the time), but the entire page for a normal
>> request.
>
> Just set headers (#header method of Webrat) and/or use .json in the
> URI to imitate
> JS client.
Ah, that makes sense -- I'm still not all that familiar with
javascript/json/etc. yet (the javascript stuff I have is brute-force
reverse engineered from Rails' helpers, and until I have a way to test
it I'm afraid to try to move to something cleaner).
Shalon Wood
--
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---