How to get Cucumber/Capybara/Mechanize to work against external non-rails site

前端 未结 2 1385
一向
一向 2020-12-30 11:12

I\'m trying to do BDD on a Google App Script. I understand that in principle I should be able to use some combination of Cucumber, Capybara and Mechanize to do BDD on a non

相关标签:
2条回答
  • 2020-12-30 11:45

    If you are not using Rails, set Capybara.app to your rack app:

    It was meant to be read as:

    If the application that you are testing is a Rack app, but not Rails, set Capybara.app to your Rack app:

    Capybara's README was updated as the result of this question.

    As you want to run tests against external application, you should set Capybara.app_host instead of Capybara.app.


    I haven't used capybara-mechanize but I think it may be not the best driver to use to test external non-Rack application. Mechanize inherits from Racktest and Racktest is for testing apps with Rack interface (mostly Rails). If your app doesn't have Rack interface, then capybara-mechanize may be not the best choice.

    I recommend you to use the built-in selenium, poltergeist, capybara-webkit or terminus

    Also your code can be written a bit nicer using Capybara.configure:

    Capybara.configure do |config|
      config.run_server = false
      config.default_driver = :selenium
      config.app_host = 'https://www.google.com' # change url
    end
    
    0 讨论(0)
  • 2020-12-30 12:00

    From Jeroen van Dijk on this Google group message, just set your Capybara.app to something that evaluates to true. i.e.

    Capybara.app = "make sure this isn't nil"
    

    As long as Capybara.run_server is set to false, it will not ever try to boot the app. It is working thus far for me.

    0 讨论(0)
提交回复
热议问题