[rspec-devel] [ rspec-Feature Requests-8149 ] specify_negatively

noreply at rubyforge.org noreply at rubyforge.org
Sat Jan 27 05:19:47 EST 2007


Feature Requests item #8149, was opened at 2007-01-25 13:55
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8149&group_id=797

Category: runner module
Group: None
>Status: Closed
Priority: 3
Submitted By: Yurii Rashkovskii (yrashk)
>Assigned to: Aslak Hellesøy (aslak_hellesoy)
Summary: specify_negatively

Initial Comment:
The idea is pretty simple: to let declare some specifications as those that _should_ fail:

context "Math behaviour" do

  specify "addition should give you the right answer" do
    (2+2).should == 4
  end

  specify_negatively "addition should not give you the wrong answer (should fail)" do
    (2+2).should == 5
  end

  specify_negatively "addition should not give you the wrong answer (bad negative test)"" do
    (2+2).should == 4
  end

end


Math behaviour
- addition should give you the right answer
- addition should not give you the wrong answer (should fail)
- addition should not give you the wrong answer (bad negative test) (FAILED - 1)

1)
'addition should not give you the wrong answer (bad negative test)' FAILED
This specification was expected to fail, but nothing failed

Finished in 0.041288 seconds

3 specifications, 1 failure


You can read discussion here:
http://rashkovskii.com/articles/2007/1/25/rspec-specify_negatively

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

>Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-01-27 05:19

Message:
I'm closing this since Proc.should_raise can be used to achieve a similar effect

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

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-01-25 14:08

Message:
Maybe I'm missing something here, but would this work for you? (already supported)

lambda do
  (2+2).should == 5
end.should_raise

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

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


More information about the rspec-devel mailing list