[rspec-users] Mocking within a Proc/Block?

Evan David Light evan at tiggerpalace.com
Thu Oct 25 00:42:26 EDT 2007


The following works:

   it "should evaluate a passed in block in the context of the  
interview object" do
     block = Proc.new { raise unless self.is_a? 
(Interview) }.should_not raise_error
     Interview.create(:title => "Text", &block)
   end

However, the following does not:

   it "should evaluate a passed in block in the context of the  
interview object" do
     block = Proc.new { self.should be_an_instance_of(Interview) }
     Interview.create(:title => "Text", &block)
   end

I'd far prefer to use the latter.  However "be_an_instance_of" is not  
defined on my Interview class per the interpreter.  While I've poked  
a little inside RSpec for insights, I'm just a tad too tired to dig  
in for an answer for this one.  Can someone help me out after  
clobbering me for what is likely to turn out to be a foolish question?

Thanks,
Evan


More information about the rspec-users mailing list