GithubHelp home page GithubHelp logo

Comments (4)

DannyBen avatar DannyBen commented on May 28, 2024 1

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 Capybara::Mechanize::Driver.new can have its "app" argument optional, and default to proc {}? Or, if not, maybe something in the README to mention how to use this without a rack app?

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.

from capybara-mechanize.

DannyBen avatar DannyBen commented on May 28, 2024 1

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 Capybara.app_host is set.

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 proc {} app above, I wish this "implementation detail" would be hidden.

In other words, would it make sense to change line 6 here:

https://github.com/jeroenvandijk/capybara-mechanize/blob/1428d6a96f0ab91c18aa88e76e21661e0e30e96b/lib/capybara/mechanize/driver.rb#L5-L7

to something like:

def initialize(app=nil, **options)
  app ||= proc {}
  #...

from capybara-mechanize.

phillbaker avatar phillbaker commented on May 28, 2024

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?

from capybara-mechanize.

twalpole avatar twalpole commented on May 28, 2024

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.

from capybara-mechanize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.