[rspec-devel] [ rspec-Bugs-9286 ] spec --line switch fails when spec has loops

noreply at rubyforge.org noreply at rubyforge.org
Wed Mar 14 15:35:35 EDT 2007


Bugs item #9286, was opened at 2007-03-14 14:08
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=9286&group_id=797

Category: None
Group: None
Status: Closed
Resolution: Rejected
Priority: 3
Submitted By: Chris Hoffman (hoffman_c)
Assigned to: Aslak Hellesøy (aslak_hellesoy)
Summary: spec --line switch fails when spec has loops

Initial Comment:
Hello,
  When running specific specs via the --line switch, it appears that there is a preprocessing step before this line number is attached to a segment of code.  For example:

[1,6].each do |size|
  context "Foo.bar of size #{size}" do
    specify "should return Bar"
  end
end

If I run 'spec --line 2 foo_spec.rb', only the context with size 1 will execute.  By itself, this is no big deal, but let's consider an augmentation of this example:

[1,6].each do |size|
  context "Foo.bar of size #{size}" do
    specify "should return Bar" do
      foo.bar.should == Bar
    end
  end
end

context "Bar.baz" do
  specify "should return Baz" do
    bar.baz.should == Baz
  end
end

Now, if I want to execute the "should return Baz" specification, I must anticipate the new line number after the loop has been "unfolded," so to speak.

Thanks for the help.  Rspec is great!


----------------------------------------------------------------------

>Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-03-14 15:35

Message:
I've updated the help message locally - will commit it when I've finished the other stuff I'm working on.

----------------------------------------------------------------------

Comment By: Chris Hoffman (hoffman_c)
Date: 2007-03-14 15:12

Message:
Hello,
  Could you please annotate the help screen so that another
user does not fall into the same trap, then?  It took me
quite some time to figure out that this was what was happening.

Thank you.

----------------------------------------------------------------------

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-03-14 15:01

Message:
Due to the way --line is implemented I regret to have to reject this RFE. Here is why:

--line is merely a preprocessor for --spec, which takes a spec name as argument. This argument is either the context/describe name, the specify/it name or both (combined with a space).

--line just looks (upwards) for the nearest spec and context, constructs a "#{context_name} #{spec_name}" and delegates to the --spec functionality. Because these names cannot be determined at the time --line is evaluated, it won't work.

The solution is to use --spec instead, and use your own brain power to determine what its argument should be!


It's impossible (or at least very hard) to evaluate

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=9286&group_id=797


More information about the rspec-devel mailing list