Sha256: e685ef7edadef0cb9ac93454d7c059d1e8c6f3e65b060b86d6b4e4f622c57bef
Contents?: true
Size: 783 Bytes
Versions: 9
Compression:
Stored size: 783 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Kernel.eval_or_yield" do before :all do @obj = RSpec::Mocks::Mock.new('obj') end it "should instance_eval when the block takes no params" do @obj.should_receive(:test).and_return('OK') eval_or_yield(@obj) { self.should_not == @obj self.test.should == 'OK' } end it "should yield when the block takes a param" do @obj.should_receive(:test).and_return('OK') eval_or_yield(@obj) { |o| self.should_not == @obj o.should == @obj lambda { self.test }.should raise_error(NoMethodError) o.test.should == 'OK' } end it "should return the object when no block is given" do eval_or_yield(@obj).should == @obj end end
Version data entries
9 entries across 9 versions & 1 rubygems