Hello,
I'm using rspec 3.0.0.beta1. I'm trying to test for yield self. Example:
class Test
def initialize
yield self if block_given?
end
end
I can't figure out how to test it. This is the closest successful test I
wrote:
describe Test do
context 'giving a block with one argument' do
it 'yields itself'
expect { |b| described_class.new &b }.to yield_with_args
described_class
end
end
end
But it tests only the yield argument type, not the object identity.
This is a failing test that goes close to the wanted result:
describe Test do
context 'giving a block with one argument' do
it 'yields itself'
instance = nil
expect { |b|
instance = described_class.new &b
}.to yield_with_args instance
end
end
end
Indeed it fails, since that at the time that the last instance occurrence
is evaluated its value is nil, so it doesn't match with instance value at
the block evaluation time.
Do you have some ideas about?
Thank you
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/385a47f7-5305-4343-b564-e0214d3666fd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.