why?
I think that’s because line 20 is contained within another group (ie:
inside describe “#some_method” do), so all examples from this group
are run.
Try running your tests with -l 21 (ie: the first line contained within
the it of the test you want to run); that should run only that test.
Still can’t get consistent behavior with -l, consider the following…
test_spec.rb
describe SomeModule
it # special it
describe “some method of the module”
it… # ‘lonely it’
it… # ‘lonely it’
it… # ‘special it’
context…
it… # ‘context it’
…
(…where carets indicate nesting levels.)
So, when I enter -l [the line for ‘describe SomeModule’], the lines
commented ‘special it’ and all my ‘context it’ tests run but not lines
commented ‘lonely it’.
And when I enter -l [the line for ‘describe “some method of the
module”’] I get all the enclosed tests, except those in the context
block (and even some tests from another module tested below
SomeModule!)
When I run test_spec.rb, I get everything.
I’m trying to draw a takeaway from this, but all I can come up with
is: ‘If you use nested blocks in your RSpec tests, do not expect -l to
test everything in the block you’re targeting.’
Lille
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.