[rspec-devel] [ rspec-Feature Requests-8783 ] auto generate spec names from last expectation

noreply at rubyforge.org noreply at rubyforge.org
Wed Feb 21 11:11:17 EST 2007


Feature Requests item #8783, was opened at 2007-02-21 11:28
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8783&group_id=797

Category: expectation module
Group: None
>Status: Closed
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: David Chelimsky (dchelimsky)
Summary: auto generate spec names from last expectation

Initial Comment:
Two specs from the stack example:

 
  specify "should not be empty" do
    @stack.should_not be_empty
  end
  
  specify "should remain not empty after #peek" do
    @stack.peek
    @stack.should_not be_empty
  end

In the second spec, the name "should remain not empty after #peek" adds value because it is different from the actual expectation, but the first one is obvious duplication between the spec name and the expectation. That one should be auto generated:

specify do
  @stack.should_not be_empty
end

...

A stack with one item
- should not be empty

For that to work, should and should_not will both need to be involved (since they are the only ones who know whether it should or should_not). Perhaps something like:

if matcher.responds_to?(name)
  magic_autogeneration_callback("should #{matcher.name}")
end

or something like that...


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

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-02-21 16:11

Message:
Fixed in trunk (rev 1519)

OK - this works now for everything but "should change" and "should satisfy", which both take blocks, rendering them pretty useless for autogeneration.

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

Comment By: David Chelimsky (dchelimsky)
Date: 2007-02-21 15:05

Message:
Got this started - works for the following as of trunk(1518):

context "37" do
  specify do
    37.should equal(37)
  end
end

output:
37
- should equal(37)

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

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


More information about the rspec-devel mailing list