When you run all the specifications, some specifications fail (sometimes), but when you run only a specific file, they pass (always)

When I run $ rspecRails 4.1 in my application, some of the options in the user_spec.rbsystem fail:

104 examples, 5 failures, 2 pending

And all 5 errors are related to the fact that in one field there are two errors, and not just one:

1) User creating a guest validates presence of name
   Failure/Error: expect(@guest).to have(1).error_on(:name)
     expected 1 error on :name, got 2
   # ./spec/models/user_spec.rb:43:in `block (3 levels) in <top (required)>'
   # -e:1:in `<main>'

Errors are always double: @messages={:name=>["can't be blank", "can't be blank"]}>but should be: @messages={:name=>["can't be blank"]}>.

Strange, this does not happen when you run only the specified file ( $ rspec ./spec/models/user_spec.rb).

22 examples, 0 failures

I tried $ git bisect, but could not find the problem.

, - https://github.com/jmuheim/communes/commit/0dee0d4983809bc19b6cb97ff9bab071fc866b02 ($ rspec $ rspec ./spec/models/user_spec.rb) , , , , , .

, Spring , Spring ($ spring stop), $ rspec , . , :

$ spring stop
Spring stopped.

$ rspec
Finished in 3.66 seconds
104 examples, 0 failures, 2 pending

$ spring stop
Spring stopped.

$ rspec
104 examples, 5 failures, 2 pending

. /. .

+4
2

, , , , .

rspec 3.3+ --bisect, , .

, , , , .

rspec --seed 1245 --bisect

https://relishapp.com/rspec/rspec-core/docs/command-line/bisect

+2

, , - : , . , . rspec ( ), .

, , User , . , rspec , , : seed, rspec , , .

, ( caller) user.rb - , user.rb .

+1

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


All Articles