diff options
Diffstat (limited to 'spec/ruby/core/module/refine_spec.rb')
| -rw-r--r-- | spec/ruby/core/module/refine_spec.rb | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index 7a5d607c4f..d0fc7015f8 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -11,7 +11,7 @@ describe "Module#refine" do end mod.should_not == inner_self - inner_self.should be_kind_of(Module) + inner_self.should.is_a?(Module) inner_self.name.should == nil end @@ -43,7 +43,7 @@ describe "Module#refine" do end end - inner_self.public_instance_methods.should include(:blah) + inner_self.public_instance_methods.should.include?(:blah) end it "returns created anonymous module" do @@ -63,7 +63,7 @@ describe "Module#refine" do Module.new do refine {} end - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises TypeError if not passed a class" do @@ -71,7 +71,7 @@ describe "Module#refine" do Module.new do refine("foo") {} end - end.should raise_error(TypeError, "wrong argument type String (expected Class or Module)") + end.should.raise(TypeError, "wrong argument type String (expected Class or Module)") end it "accepts a module as argument" do @@ -84,7 +84,7 @@ describe "Module#refine" do end end - inner_self.public_instance_methods.should include(:blah) + inner_self.public_instance_methods.should.include?(:blah) end it "applies refinements to the module" do @@ -117,7 +117,7 @@ describe "Module#refine" do Module.new do refine String end - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "applies refinements to calls in the refine block" do @@ -136,7 +136,7 @@ describe "Module#refine" do refine(String) {def foo; "foo"; end} -> { "hello".foo - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end @@ -145,7 +145,7 @@ describe "Module#refine" do refine(String) {def foo; 'foo'; end} end - -> {"hello".foo}.should raise_error(NoMethodError) + -> {"hello".foo}.should.raise(NoMethodError) end # When defining multiple refinements in the same module, @@ -209,7 +209,7 @@ describe "Module#refine" do [1, 2].to_json_format end - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end # method lookup: @@ -243,32 +243,6 @@ describe "Module#refine" do result.should == "foo from singleton class" end - ruby_version_is ""..."3.2" do - it "looks in the included modules for builtin methods" do - result = ruby_exe(<<-RUBY) - a = Module.new do - def /(other) quo(other) end - end - - refinement = Module.new do - refine Integer do - include a - end - end - - result = nil - Module.new do - using refinement - result = 1 / 2 - end - - print result.class - RUBY - - result.should == 'Rational' - end - end - it "looks in later included modules of the refined module first" do a = Module.new do def foo @@ -622,7 +596,7 @@ describe "Module#refine" do using refinement_with_super -> { refined_class.new.bar - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end end @@ -636,7 +610,7 @@ describe "Module#refine" do } [1,2].orig_count.should == 2 end - -> { [1,2].orig_count }.should raise_error(NoMethodError) + -> { [1,2].orig_count }.should.raise(NoMethodError) end it 'and alias_method aliases a method within a refinement module, but not outside it' do @@ -648,7 +622,7 @@ describe "Module#refine" do } [1,2].orig_count.should == 2 end - -> { [1,2].orig_count }.should raise_error(NoMethodError) + -> { [1,2].orig_count }.should.raise(NoMethodError) end it "and instance_methods returns a list of methods including those of the refined module" do @@ -730,11 +704,10 @@ describe "Module#refine" do end end end - spec = self - klass = Class.new { instance_methods.should_not spec.send(:include, :refinement_only_method) } + klass = Class.new { instance_methods.should_not.include?(:refinement_only_method) } instance = klass.new - instance.methods.should_not include :refinement_only_method + instance.methods.should_not.include? :refinement_only_method instance.respond_to?(:refinement_only_method).should == false - -> { instance.method :refinement_only_method }.should raise_error(NameError) + -> { instance.method :refinement_only_method }.should.raise(NameError) end end |
