On 10/24/07, Evan David Light <[EMAIL PROTECTED]> wrote:
> 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.
That is correct. It gets evaluated, as your example narrative states:
in the context of the interview object.
How about something like this?
it "should evaluate ..." do
$interview = nil
Interview.create(:title => "Text") do
$interview = self
end
$interview.should be_an_instance_of(Interview)
end
end
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users