Capybara aliases 'Feature' and 'Scenario' cause an 'undefined' error when used with RSpec

It looks like these aliases are not loaded properly. I use Rails 3.X, rspec 2.8, and capybara 1.1.2 to write some integration tests. I think that my installation of Capybara was successful, since everything works with the standard tags "describe" and "this", but the alias "feature" and "script" from Capybara gives an "undefined" error.

I don't see anything in the documentation that mentions more settings: https://github.com/jnicklas/capybara I just added "require capybara / rspec" to my spec_helper.rb

+4
source share
1 answer

It seems you cannot combine the description / its with the function / script syntax. I was getting the same error when I nested the scenario block inside the describe block. As soon as I replaced describe with feature , the test passed. One of them: it also does not look like nested feature blocks, which, it seems to me, make sense in the context of acceptance tests.

 describe "some feature" do # <== BAD scenario "some scenario" do #spec code here end end feature "some feature" do # <== GOOD scenario "some scenario" do #spec code here end end 

UPDATE I dug up the source code for Capybara, and before and it don't get the alias background and scenario unless the describe block was created using capybara_feature => true , which happens when you create a block with feature instead of describe .

+16
source

Source: https://habr.com/ru/post/1393050/


All Articles