Sha256: 66b8ddc937441af2130953256657a3b4575eac533ce934c055da2fdc2ec11a5a
Contents?: true
Size: 1.85 KB
Versions: 8
Compression:
Stored size: 1.85 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' require 'mspec/guards/extensions' describe Object, "#extended_on" do before :all do @verbose = $VERBOSE $VERBOSE = nil @ruby_name = Object.const_get :RUBY_NAME if Object.const_defined? :RUBY_NAME end after :all do $VERBOSE = @verbose if @ruby_name Object.const_set :RUBY_NAME, @ruby_name else Object.send :remove_const, :RUBY_NAME end end before :each do ScratchPad.clear end it "raises an Exception when passed :ruby" do Object.const_set :RUBY_NAME, "jruby" lambda { extended_on(:ruby) { ScratchPad.record :yield } }.should raise_error(Exception) ScratchPad.recorded.should_not == :yield end it "does not yield when #standard? returns true" do Object.const_set :RUBY_NAME, "ruby" extended_on(:rubinius) { ScratchPad.record :yield } ScratchPad.recorded.should_not == :yield end it "does not yield when #implementation? returns false" do Object.const_set :RUBY_NAME, "jruby" extended_on(:rubinius) { ScratchPad.record :yield } ScratchPad.recorded.should_not == :yield end it "yields when #implementation? returns true" do Object.const_set :RUBY_NAME, "rbx" extended_on(:rubinius) { ScratchPad.record :yield } ScratchPad.recorded.should == :yield end end describe Object, "#extended_on" do before :each do @guard = ExtensionsGuard.new ExtensionsGuard.stub!(:new).and_return(@guard) end it "sets the name of the guard to :extended_on" do extended_on(:rubinius) { } @guard.name.should == :extended_on end it "calls #unregister even when an exception is raised in the guard block" do @guard.should_receive(:match?).and_return(true) @guard.should_receive(:unregister) lambda do extended_on(:rubinius) { raise Exception } end.should raise_error(Exception) end end
Version data entries
8 entries across 8 versions & 1 rubygems