Visit method not found in my rspec

前端 未结 6 1903
鱼传尺愫
鱼传尺愫 2020-11-30 03:08

My java web application is running on tomcat at http://localhost:8080/

Writing my first spec, home_spec:

require \'spec_helper\'


d         


        
相关标签:
6条回答
  • 2020-11-30 03:18

    Also make sure your tests are in the /spec/features directory. According to rspec-rails and capybara 2.0, Capybara v2 and higher will not be available by default in RSpec request specs. They suggest to "...move any tests that use capybara from spec/requests to spec/features."

    0 讨论(0)
  • 2020-11-30 03:24

    By default the capybara DSL is included automatically if the file is in spec/requests, spec/integration or if the example group has :type => :request.

    Because your file is in spec/home the capybara helpers aren't being included. You can either conform to one of the patterns above or adding include Capybara::DSL should also do the trick (you might also need to replicate some of the before(:each) stuff that would be setup.)

    0 讨论(0)
  • 2020-11-30 03:26

    1) Add to ‘rails_helper’ config:

    config.include Capybara::DSL
    config.include Capybara::RSpecMatchers
    
    And comment out the `require 'spec_helper'` line.
    

    2) Add to 'spec_helper':

    require 'rails_helper'
    
    0 讨论(0)
  • 2020-11-30 03:27

    The default directory that Capybara::RSpec now looks at to include the Capybara::DSL and Capybara::RSpecMatchers is changed from requests to features.

    After I renamed my requests directory to features I got the matcher and DSL methods available again without having to explicitly include them.

    See the following commit

    0 讨论(0)
  • 2020-11-30 03:33

    First check it out

    If you are not success,

    Add this code your end of the your spec helper actually out of the RSpec.configure block as well

    module ::RSpec::Core
      class ExampleGroup
        include Capybara::DSL
        include Capybara::RSpecMatchers
      end
    end
    
    0 讨论(0)
  • 2020-11-30 03:44

    Regarding to rspec issues (https://github.com/rspec/rspec-rails/issues/360)

    you should put

    config.include Capybara::DSL
    

    in spec_helper.rb, inside the config block.

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