-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: mechanize requires a rack application, but none was given #66
Comments
Hi @DannyBen, I don't know if this project is a full replacement for webkit/poltergesit, but I think mechanize should accept any URL. I believe this is described in the README here: https://github.com/jeroenvandijk/capybara-mechanize/#remote-testing Can you share your current configuration or an example that is't working? |
Hi, Well, for me this can definitely be a full replacement. I am not testing complex javascript pages, but rather clicking links and filling out basic forms. So here is the situation: With the help of someone at the Capybara group, I realized that this: Capybara.register_driver :mechanize do |app|
Capybara::Mechanize::Driver.new app
end should be changed to this: Capybara.register_driver :mechanize do |app|
Capybara::Mechanize::Driver.new(proc {})
end And then things are working without a rack app. Here is the most minimal example repo I have created for the occasion. Perhaps the initializer for Also, as for the default app that you pointed me to - yes, I am aware of this, but I only care about testing fully qualified external URLs, so I guess it will not come into play. |
TL;DR; It's not that capybara-mechanize requires an app, it's that the rack-test driver does. The issue here is that capybara-mechanize derives from the rack-test driver, and the rack-test driver requires an app. If the user sticks to only visiting fully qualified urls then only the capybara-mechanize version of visit is used, and the rack-test driver version of visit (which is what requires the app to route to) is never called and therefore the app isn't strictly necessary. |
I understand, assuming that my understanding is also correct when saying that even when using relative URLs, it will still bypass the default Rack::Test if What I am saying (now that there is a solution) is this: The original intention of Capybara-Mechanize (so it seems) was to be a "Rack::Test + external links" driver. I think that it can also act as a very lightweight way to do general purpose acceptance tests on sites that are external (to the point of view of the feature definitions). I have this kind of setup, and up until now I was working with the heavy weights webkit / selenium / poltergeist. For this to be fully true, it should be able to initialize without a rack app. Right now it sort of does, by using the In other words, would it make sense to change line 6 here: to something like: def initialize(app=nil, **options)
app ||= proc {}
#... |
This example will help all users that follow README but did not come across phillbaker#66
I was hoping Mechanize can be a replacement for the outdated webkit / poltergeist drivers, so that I can just
visit "http://some.domain.com"
and it will work, even when called without any Rack application.Was I wrong?
The text was updated successfully, but these errors were encountered: