Permalink
Browse files

Added a cuke for predicate matchers.

  • Loading branch information...
myronmarston committed Oct 3, 2010
1 parent b3faf00 commit a0fb168a6717a2ada38bbf6c3dc258518fe6e478
Showing with 41 additions and 0 deletions.
  1. +41 −0 features/matchers/predicates.feature
@@ -0,0 +1,41 @@
+Feature: predicate matchers
+
+ As an RSpec user
+ I want to set expectations based upon the predicate methods of my objects
+ So that I don't have to write a custom matcher for such a simple case
+
+ Scenario: should be_zero (based on Fixnum#zero?)
+ Given a file named "should_be_zero_spec.rb" with:
+ """
+ describe 0 do
+ it { should be_zero }
+ end
+
+ describe 7 do
+ it { should be_zero } # deliberately fail
+ end
+ """
+ When I run "rspec ./should_be_zero_spec.rb"
+ Then the output should contain "2 examples, 1 failure"
+ And the output should contain "expected zero? to return true, got false"
+
+ Scenario: should_not be_empty (based on Arrray#empty?)
+ Given a file named "should_not_be_empty_spec.rb" with:
+ """
+ describe Array do
+ context "with 3 items" do
+ it "is not empty" do
+ [1, 2, 3].should_not be_empty
+ end
+ end
+
+ context "with no items" do
+ it "is empty, but we'll fail this spec anyway" do
+ [].should_not be_empty
+ end
+ end
+ end
+ """
+ When I run "rspec ./should_not_be_empty_spec.rb"
+ Then the output should contain "2 examples, 1 failure"
+ And the output should contain "expected empty? to return false, got true"

0 comments on commit a0fb168

Please sign in to comment.