On 25.01.2009, at 21:49, Shalon Wood wrote:

> Hmm. I'm actually using full urls in each feature, since I do use
> subdomains, so would that actually be a problem?


I copied merb's request_helper.rb and modified the following line:

- uri.host   ||= "example.org"
+ uri.host   ||= (Merb::Config[:subdomains][:base_domain] ||  
raise("Merb::Config[:subdomains][:base_domain] is not set. Should be  
myapp.test for test env"))

To understand why it is necessary, let me explain how webrat works:

1. It uses Merb/Rails request helpers to make initial request. visit/ 
click and others are just one more layer of abstraction that lets you  
write less boilerplate code.
2. It grabs request from Merb, and looks to Location header. If it is  
present, it uses that value to follow a redirect: that is, issue  
another GET request starting from
     step 1.
3. Cookies (and thus session id) are preserved (Merb reuses Set-Cookie  
header value in test helper) as long as they match
host and path (current implementation is NOT fully RFC compliant).

However, since default host is "example.org", and you app may not use  
base domain, you'll be not notified about this, your session just "got  
lost". I spend hours
once trying to narrow down where exactly in all the Merb session setup  
code and Webrat request cycle that problem appeared.

I also had to update method that checks if cookie matches against host  
and path to add a simple way to turn on debugging there:

http://gist.github.com/52665

For now it all lives in mylocal gems directory, and once I figure out  
how to patch Webrat
without breaking Rails apps (yes, Webrat has poor test suite that  
overuses mocks which is quite lame for a testing tool),
we will have really solid Webrat support in Merb.

In fact, most of the code should be moved to Merb core IMO, and it's  
good, because it's always
easier to fix the problem yourself than to try to push patches to  
other projects.

MK


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to