diff options
Diffstat (limited to 'spec/ruby/library')
-rw-r--r-- | spec/ruby/library/bigdecimal/BigDecimal_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/library/bigdecimal/minus_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/bigdecimal/plus_spec.rb | 7 | ||||
-rw-r--r-- | spec/ruby/library/ipaddr/operator_spec.rb | 7 | ||||
-rw-r--r-- | spec/ruby/library/mathn/mathn_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/library/rbconfig/rbconfig_spec.rb | 16 | ||||
-rw-r--r-- | spec/ruby/library/stringio/puts_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/yaml/fixtures/example_class.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/yaml/to_yaml_spec.rb | 3 |
9 files changed, 56 insertions, 13 deletions
diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb index 52f026fb2b..03f0c0adfd 100644 --- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb +++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb @@ -1,6 +1,12 @@ require_relative '../../spec_helper' require 'bigdecimal' +describe "BigDecimal" do + it "is not defined unless it is required" do + ruby_exe('puts Object.const_defined?(:BigDecimal)').should == "false\n" + end +end + describe "Kernel#BigDecimal" do it "creates a new object of class BigDecimal" do diff --git a/spec/ruby/library/bigdecimal/minus_spec.rb b/spec/ruby/library/bigdecimal/minus_spec.rb index 02f7f02296..267a0f7eab 100644 --- a/spec/ruby/library/bigdecimal/minus_spec.rb +++ b/spec/ruby/library/bigdecimal/minus_spec.rb @@ -55,4 +55,12 @@ describe "BigDecimal#-" do (@one_minus - @infinity).should == @infinity_minus end + describe "with Object" do + it "tries to coerce the other operand to self" do + object = mock("Object") + object.should_receive(:coerce).with(@one).and_return([@one, BigDecimal("42")]) + (@one - object).should == BigDecimal("-41") + end + end + end diff --git a/spec/ruby/library/bigdecimal/plus_spec.rb b/spec/ruby/library/bigdecimal/plus_spec.rb index 9247ff6146..cefc43aeaa 100644 --- a/spec/ruby/library/bigdecimal/plus_spec.rb +++ b/spec/ruby/library/bigdecimal/plus_spec.rb @@ -44,4 +44,11 @@ describe "BigDecimal#+" do (@infinity + @infinity_minus).nan?.should == true end + describe "with Object" do + it "tries to coerce the other operand to self" do + object = mock("Object") + object.should_receive(:coerce).with(@one).and_return([@one, BigDecimal("42")]) + (@one + object).should == BigDecimal("43") + end + end end diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb index fe94a39ae1..a0984bfcfe 100644 --- a/spec/ruby/library/ipaddr/operator_spec.rb +++ b/spec/ruby/library/ipaddr/operator_spec.rb @@ -2,14 +2,11 @@ require_relative '../../spec_helper' require 'ipaddr' describe "IPAddr Operator" do - IN6MASK32 = "ffff:ffff::" - IN6MASK128 = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" - before do @in6_addr_any = IPAddr.new() @a = IPAddr.new("3ffe:505:2::/48") @b = IPAddr.new("0:0:0:1::") - @c = IPAddr.new(IN6MASK32) + @c = IPAddr.new("ffff:ffff::") end it "bitwises or" do @@ -48,7 +45,7 @@ describe "IPAddr Operator" do it "inverts" do a = ~@in6_addr_any - a.to_s.should == IN6MASK128 + a.to_s.should == "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" @in6_addr_any.to_s.should == "::" end diff --git a/spec/ruby/library/mathn/mathn_spec.rb b/spec/ruby/library/mathn/mathn_spec.rb index c9e8c05a8d..129c8f3288 100644 --- a/spec/ruby/library/mathn/mathn_spec.rb +++ b/spec/ruby/library/mathn/mathn_spec.rb @@ -3,7 +3,11 @@ require_relative '../../spec_helper' describe "mathn" do ruby_version_is "2.5" do it "is no longer part of the standard library" do - -> { require "mathn" }.should raise_error(LoadError) + -> { + require "mathn" + }.should raise_error(LoadError) { |e| + e.path.should == 'mathn' + } end end end diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb index caa557c32c..af74043c9c 100644 --- a/spec/ruby/library/rbconfig/rbconfig_spec.rb +++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb @@ -1,11 +1,23 @@ require_relative '../../spec_helper' require 'rbconfig' -describe 'RbConfig::CONFIG values' do - it 'are all strings' do +describe 'RbConfig::CONFIG' do + it 'values are all strings' do RbConfig::CONFIG.each do |k, v| k.should be_kind_of String v.should be_kind_of String end end + + it "['rubylibdir'] returns the directory containing Ruby standard libraries" do + rubylibdir = RbConfig::CONFIG['rubylibdir'] + File.directory?(rubylibdir).should == true + File.exist?("#{rubylibdir}/fileutils.rb").should == true + end + + it "['archdir'] returns the directory containing standard libraries C extensions" do + archdir = RbConfig::CONFIG['archdir'] + File.directory?(archdir).should == true + File.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}").should == true + end end diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb index 396d9f25f4..152bfb13f8 100644 --- a/spec/ruby/library/stringio/puts_spec.rb +++ b/spec/ruby/library/stringio/puts_spec.rb @@ -51,6 +51,14 @@ describe "StringIO#puts when passed an Array" do @io.puts([obj]) @io.string.should == "to_s\n" end + + it "returns general object info if :to_s does not return a string" do + object = mock('hola') + object.should_receive(:to_s).and_return(false) + + @io.puts(object).should == nil + @io.string.should == object.inspect.split(" ")[0] + ">\n" + end end describe "StringIO#puts when passed 1 or more objects" do diff --git a/spec/ruby/library/yaml/fixtures/example_class.rb b/spec/ruby/library/yaml/fixtures/example_class.rb index 751435a305..8259870799 100644 --- a/spec/ruby/library/yaml/fixtures/example_class.rb +++ b/spec/ruby/library/yaml/fixtures/example_class.rb @@ -1,5 +1,7 @@ -class FooBar - def initialize(name) - @name = name +module YAMLSpecs + class Example + def initialize(name) + @name = name + end end end diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb index 9713657a26..d73ae9bee4 100644 --- a/spec/ruby/library/yaml/to_yaml_spec.rb +++ b/spec/ruby/library/yaml/to_yaml_spec.rb @@ -13,8 +13,7 @@ describe "Object#to_yaml" do end it "returns the YAML representation of a Class object" do - FooBar.new("baz").to_yaml.should match_yaml("--- !ruby/object:FooBar\nname: baz\n") - + YAMLSpecs::Example.new("baz").to_yaml.should match_yaml("--- !ruby/object:YAMLSpecs::Example\nname: baz\n") end it "returns the YAML representation of a Date object" do |