Lille
2011-Jan-11 18:32 UTC
[rspec-users] when using command line -l, why do tests from other describe blocks run?
Hi, I frequently use the -l option to run only tests of interest, but it''s messy in a way I don''t understand... describe SomeModel do describe "#some_method" do it... # let''s call this line 20 end describe "#some_other_method" do it... # here''s some other test end end If I enter ''spec -l 20 spec/models/some_model_spec.rb'' on the command line, I get my line 20 test and others -- say the other test, above -- why? Thanks, Lille
Mike Mazur
2011-Jan-11 23:09 UTC
[rspec-users] when using command line -l, why do tests from other describe blocks run?
Hi, On Wed, Jan 12, 2011 at 02:32, Lille <lille.penguini at gmail.com> wrote:> I frequently use the -l option to run only tests of interest, but it''s > messy in a way I don''t understand... > > describe SomeModel do > > ?describe "#some_method" do > > ? ? it... # let''s call this line 20 > > ?end > > ?describe "#some_other_method" do > > ? ?it... # here''s some other test > > ?end > > end > > If I enter ''spec -l 20 spec/models/some_model_spec.rb'' on the command > line, I get my line 20 test and others -- say the other test, above -- > 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. Mike
Lille
2011-Jan-14 01:30 UTC
[rspec-users] when using command line -l, why do tests from other describe blocks run?
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 On Jan 11, 6:09?pm, Mike Mazur <mma... at gmail.com> wrote:> Hi, > > > > On Wed, Jan 12, 2011 at 02:32, Lille <lille.pengu... at gmail.com> wrote: > > I frequently use the -l option to run only tests of interest, but it''s > > messy in a way I don''t understand... > > > describe SomeModel do > > > ?describe "#some_method" do > > > ? ? it... # let''s call this line 20 > > > ?end > > > ?describe "#some_other_method" do > > > ? ?it... # here''s some other test > > > ?end > > > end > > > If I enter ''spec -l 20 spec/models/some_model_spec.rb'' on the command > > line, I get my line 20 test and others -- say the other test, above -- > > 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. > > Mike > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users