Capybara methods are undefined

前端 未结 2 555
暗喜
暗喜 2021-01-15 09:48

I cannot get capybara to work. I am using capybara 2.0.0

I get this error

Failure/Error: visit \"/users/sign_in\"
     NoMethodError:
       undefine         


        
2条回答
  •  轮回少年
    2021-01-15 09:58

    If you've got version >= 2.0, any tests that use Capybara methods like visit should go under a spec/features directory, and not under spec/requests, where they'd normally reside in Capybara 1.1.2.

    Have a look at the following links for more information:

    • rspec-rails and capybara 2.0: what you need to know
    • rspec-rails gem Capybara page

    If you don't want to use a spec/features directory, you should be able to mark a test as a feature in the following way and have Capybara methods work:

    describe "Some action", type: :feature do
      before do
        visit "/users/sign_in"
        # ...
      end
      # ...
    end
    

提交回复
热议问题