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...@gmail.com> wrote:
> Hi,
>
>
>
> On Wed, Jan 12, 2011 at 02:32, Lille <lille.pengu...@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...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to