undefined method `visit' when using RSpec and Capybara in rails

后端 未结 5 1029
面向向阳花
面向向阳花 2020-12-02 09:20

I can\'t get capybara working with rspec. It gives me this error:

undefined method `visit\' for #

        
5条回答
  •  粉色の甜心
    2020-12-02 10:20

    Try performing all your setup in a before block:

    spec/features/security_spec.rb

    describe "security" do
      before do
        visit "/sessions/new"
        fill_in "username", :with => "user"
        fill_in "password", :with => "pass"
        click_button "Sign In"
      end
    
      it "signs users in" do
        page.should have_content('Login Successful')
      end
    end
    

提交回复
热议问题