<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,9 +4,10 @@ module Spec
     class Be #:nodoc:
       include Spec::Matchers::Pretty
       
-      def initialize(*args)
+      def initialize(*args, &amp;block)
         @expected = args.empty? ? true : set_expected(args.shift)
         @args = args
+        @block = block
         @comparison_method = nil
       end
       
@@ -17,13 +18,13 @@ module Spec
       
       def run_predicate_on(actual)
         begin
-          return @result = actual.__send__(predicate, *@args)
+          return @result = actual.__send__(predicate, *@args, &amp;@block)
         rescue NameError =&gt; predicate_missing_error
           &quot;this needs to be here or rcov will not count this branch even though it's executed in a code example&quot;
         end
 
         begin
-          return @result = actual.__send__(present_tense_predicate, *@args)
+          return @result = actual.__send__(present_tense_predicate, *@args, &amp;@block)
         rescue NameError
           raise predicate_missing_error
         end
@@ -196,8 +197,8 @@ it is a bit confusing.
     #   collection.should be_empty #passes if target.empty?
     #   target.should_not be_empty #passes unless target.empty?
     #   target.should_not be_old_enough(16) #passes unless target.old_enough?(16)
-    def be(*args)
-      Matchers::Be.new(*args)
+    def be(*args, &amp;block)
+      Matchers::Be.new(*args, &amp;block)
     end
 
     # passes if target.kind_of?(klass)</diff>
      <filename>lib/spec/matchers/be.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,12 +3,12 @@ module Spec
     
     class Has
       
-      def initialize(expected, *args)
-        @expected, @args = expected, args
+      def initialize(expected, *args, &amp;block)
+        @expected, @args, @block = expected, args, block
       end
       
       def matches?(actual)
-        actual.__send__(predicate(@expected), *@args)
+        actual.__send__(predicate(@expected), *@args, &amp;@block)
       end
       
       def failure_message_for_should</diff>
      <filename>lib/spec/matchers/has.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,8 @@
 module Spec
   module Matchers
     def method_missing(sym, *args, &amp;block) # :nodoc:
-      return Matchers::Be.new(sym, *args) if sym.to_s =~ /^be_/
-      return Matchers::Has.new(sym, *args) if sym.to_s =~ /^have_/
+      return Matchers::Be.new(sym, *args, &amp;block) if sym.to_s =~ /^be_/
+      return Matchers::Has.new(sym, *args, &amp;block) if sym.to_s =~ /^have_/
       super
     end
   end</diff>
      <filename>lib/spec/matchers/method_missing.rb</filename>
    </modified>
    <modified>
      <diff>@@ -117,6 +117,114 @@ describe &quot;should_not be_predicate(*args)&quot; do
   end
 end
 
+describe &quot;should be_predicate(&amp;block)&quot; do
+  it &quot;should pass when actual returns true for :predicate?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:happy?).and_yield
+    delegate.should_receive(:check_happy).and_return(true)
+    actual.should be_happy { delegate.check_happy }
+  end
+
+  it &quot;should fail when actual returns false for :predicate?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:happy?).and_yield
+    delegate.should_receive(:check_happy).and_return(false)
+    lambda {
+      actual.should be_happy { delegate.check_happy }
+    }.should fail_with(&quot;expected happy? to return true, got false&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :predicate?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_happy =&gt; true)
+    lambda {
+      Object.new.should be_happy { delegate.check_happy }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should_not be_predicate(&amp;block)&quot; do
+  it &quot;should pass when actual returns false for :predicate?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:happy?).and_yield
+    delegate.should_receive(:check_happy).and_return(false)
+    actual.should_not be_happy { delegate.check_happy }
+  end
+
+  it &quot;should fail when actual returns true for :predicate?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:happy?).and_yield
+    delegate.should_receive(:check_happy).and_return(true)
+    lambda {
+      actual.should_not be_happy { delegate.check_happy }
+    }.should fail_with(&quot;expected happy? to return false, got true&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :predicate?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_happy =&gt; true)
+    lambda {
+      Object.new.should_not be_happy { delegate.check_happy }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should be_predicate(*args, &amp;block)&quot; do
+  it &quot;should pass when actual returns true for :predicate?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:older_than?).with(3).and_yield(3)
+    delegate.should_receive(:check_older_than).with(3).and_return(true)
+    actual.should be_older_than(3) { |age| delegate.check_older_than(age) }
+  end
+
+  it &quot;should fail when actual returns false for :predicate?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:older_than?).with(3).and_yield(3)
+    delegate.should_receive(:check_older_than).with(3).and_return(false)
+    lambda {
+      actual.should be_older_than(3) { |age| delegate.check_older_than(age) }
+    }.should fail_with(&quot;expected older_than?(3) to return true, got false&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :predicate?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_older_than =&gt; true)
+    lambda {
+      Object.new.should be_older_than(3) { |age| delegate.check_older_than(age) }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should_not be_predicate(*args, &amp;block)&quot; do
+  it &quot;should pass when actual returns false for :predicate?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:older_than?).with(3).and_yield(3)
+    delegate.should_receive(:check_older_than).with(3).and_return(false)
+    actual.should_not be_older_than(3) { |age| delegate.check_older_than(age) }
+  end
+
+  it &quot;should fail when actual returns true for :predicate?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:older_than?).with(3).and_yield(3)
+    delegate.should_receive(:check_older_than).with(3).and_return(true)
+    lambda {
+      actual.should_not be_older_than(3) { |age| delegate.check_older_than(age) }
+    }.should fail_with(&quot;expected older_than?(3) to return false, got true&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :predicate?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_older_than =&gt; true)
+    lambda {
+      Object.new.should_not be_older_than(3) { |age| delegate.check_older_than(age) }
+    }.should raise_error(NameError)
+  end
+end
+
 describe &quot;should be_true&quot; do
   it &quot;should pass when actual equal(true)&quot; do
     true.should be_true</diff>
      <filename>spec/spec/matchers/be_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -70,6 +70,115 @@ describe &quot;should_not have_sym(*args)&quot; do
   end
 end
 
+describe &quot;should have_sym(&amp;block)&quot; do
+  it &quot;should pass when actual returns true for :has_sym?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).and_yield
+    delegate.should_receive(:check_has_foo).and_return(true)
+    actual.should have_foo { delegate.check_has_foo }
+  end
+
+  it &quot;should fail when actual returns false for :has_sym?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).and_yield
+    delegate.should_receive(:check_has_foo).and_return(false)
+    lambda {
+      actual.should have_foo { delegate.check_has_foo }
+    }.should fail_with(&quot;expected #has_foo?(nil) to return true, got false&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :has_sym?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_has_foo =&gt; true)
+    lambda {
+      Object.new.should have_foo { delegate.check_has_foo }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should_not have_sym(&amp;block)&quot; do
+  it &quot;should pass when actual returns false for :has_sym?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).and_yield
+    delegate.should_receive(:check_has_foo).and_return(false)
+    actual.should_not have_foo { delegate.check_has_foo }
+  end
+
+  it &quot;should fail when actual returns true for :has_sym?(&amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).and_yield
+    delegate.should_receive(:check_has_foo).and_return(true)
+    lambda {
+      actual.should_not have_foo { delegate.check_has_foo }
+    }.should fail_with(&quot;expected #has_foo?(nil) to return false, got true&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :has_sym?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_has_foo =&gt; true)
+    lambda {
+      Object.new.should_not have_foo { delegate.check_has_foo }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should have_sym(*args, &amp;block)&quot; do
+  it &quot;should pass when actual returns true for :has_sym?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).with(:a).and_yield(:a)
+    delegate.should_receive(:check_has_foo).with(:a).and_return(true)
+    actual.should have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+  end
+
+  it &quot;should fail when actual returns false for :has_sym?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).with(:a).and_yield(:a)
+    delegate.should_receive(:check_has_foo).with(:a).and_return(false)
+    lambda {
+      actual.should have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+    }.should fail_with(&quot;expected #has_foo?(:a) to return true, got false&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :has_sym?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_has_foo =&gt; true)
+    lambda {
+      Object.new.should have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+    }.should raise_error(NameError)
+  end
+end
+
+describe &quot;should_not have_sym(*args, &amp;block)&quot; do
+  it &quot;should pass when actual returns false for :has_sym?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).with(:a).and_yield(:a)
+    delegate.should_receive(:check_has_foo).with(:a).and_return(false)
+    actual.should_not have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+  end
+
+  it &quot;should fail when actual returns true for :has_sym?(*args, &amp;block)&quot; do
+    actual = mock(&quot;actual&quot;)
+    delegate = mock(&quot;delegate&quot;)
+    actual.should_receive(:has_foo?).with(:a).and_yield(:a)
+    delegate.should_receive(:check_has_foo).with(:a).and_return(true)
+    lambda {
+      actual.should_not have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+    }.should fail_with(&quot;expected #has_foo?(:a) to return false, got true&quot;)
+  end
+
+  it &quot;should fail when actual does not respond to :has_sym?&quot; do
+    delegate = mock(&quot;delegate&quot;, :check_has_foo =&gt; true)
+    lambda {
+      Object.new.should_not have_foo(:a) { |foo| delegate.check_has_foo(foo) }
+    }.should raise_error(NameError)
+  end
+end
+
+
 describe &quot;has&quot; do
   it &quot;should work when the target implements #send&quot; do
     o = {:a =&gt; &quot;A&quot;}</diff>
      <filename>spec/spec/matchers/has_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e45788319aaf2911409ec5905de9decbe2e25b81</id>
    </parent>
  </parents>
  <author>
    <name>Tom Stuart</name>
    <email>tom@experthuman.com</email>
  </author>
  <url>http://github.com/dchelimsky/rspec/commit/c83c3676a8ef8b7de97d88433fe29ef89dcb79f1</url>
  <id>c83c3676a8ef8b7de97d88433fe29ef89dcb79f1</id>
  <committed-date>2009-11-04T17:05:55-08:00</committed-date>
  <authored-date>2009-11-04T07:10:25-08:00</authored-date>
  <message>Add block argument support to predicate matchers

[#905 state:resolved milestone:'Next Release']</message>
  <tree>5d9f73a4d45a9b162e8bdcb3b5f0e6e77f50e9c0</tree>
  <committer>
    <name>David Chelimsky</name>
    <email>dchelimsky@gmail.com</email>
  </committer>
</commit>
