diff options
Diffstat (limited to 'spec/ruby/library/yaml')
| -rw-r--r-- | spec/ruby/library/yaml/dump_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/yaml/parse_file_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/yaml/parse_spec.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/library/yaml/shared/load.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/library/yaml/to_yaml_spec.rb | 20 |
5 files changed, 26 insertions, 16 deletions
diff --git a/spec/ruby/library/yaml/dump_spec.rb b/spec/ruby/library/yaml/dump_spec.rb index ea94b2f856..97b665d6a5 100644 --- a/spec/ruby/library/yaml/dump_spec.rb +++ b/spec/ruby/library/yaml/dump_spec.rb @@ -39,7 +39,11 @@ describe "YAML.dump" do end it "dumps an OpenStruct" do - require "ostruct" + begin + require "ostruct" + rescue LoadError + skip "OpenStruct is not available" + end os = OpenStruct.new("age" => 20, "name" => "John") yaml_dump = YAML.dump(os) diff --git a/spec/ruby/library/yaml/parse_file_spec.rb b/spec/ruby/library/yaml/parse_file_spec.rb index 7bffcdc62f..a29377f163 100644 --- a/spec/ruby/library/yaml/parse_file_spec.rb +++ b/spec/ruby/library/yaml/parse_file_spec.rb @@ -5,6 +5,6 @@ require 'yaml' describe "YAML.parse_file" do it "returns a YAML::Syck::Map object after parsing a YAML file" do test_parse_file = fixture __FILE__, "test_yaml.yml" - YAML.parse_file(test_parse_file).should be_kind_of(Psych::Nodes::Document) + YAML.parse_file(test_parse_file).should.is_a?(Psych::Nodes::Document) end end diff --git a/spec/ruby/library/yaml/parse_spec.rb b/spec/ruby/library/yaml/parse_spec.rb index 37e2b7fa0a..832cd99d03 100644 --- a/spec/ruby/library/yaml/parse_spec.rb +++ b/spec/ruby/library/yaml/parse_spec.rb @@ -4,7 +4,7 @@ require 'yaml' describe "YAML.parse with an empty string" do it "returns false" do - YAML.parse('').should be_false + YAML.parse('').should == false end end diff --git a/spec/ruby/library/yaml/shared/load.rb b/spec/ruby/library/yaml/shared/load.rb index bd55332fe5..7e5669f2d0 100644 --- a/spec/ruby/library/yaml/shared/load.rb +++ b/spec/ruby/library/yaml/shared/load.rb @@ -60,7 +60,7 @@ describe :yaml_load_safe, shared: true do else error = ArgumentError end - -> { YAML.send(@method, "key1: value\ninvalid_key") }.should raise_error(error) + -> { YAML.send(@method, "key1: value\ninvalid_key") }.should.raise(error) end it "accepts symbols" do @@ -117,13 +117,17 @@ describe :yaml_load_unsafe, shared: true do ].should be_computed_by(:usec) end - it "rounds values smaller than 1 usec to 0 " do + it "rounds values smaller than 1 usec to 0" do YAML.send(@method, "2011-03-22t23:32:11.000000342222+01:00").usec.should == 0 end end it "loads an OpenStruct" do - require "ostruct" + begin + require "ostruct" + rescue LoadError + skip "OpenStruct is not available" + end os = OpenStruct.new("age" => 20, "name" => "John") loaded = YAML.send(@method, "--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n") loaded.should == os @@ -133,6 +137,6 @@ describe :yaml_load_unsafe, shared: true do loaded = YAML.send(@method, "--- !ruby/object:File {}\n") -> { loaded.read(1) - }.should raise_error(IOError) + }.should.raise(IOError) end end diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb index 547009c942..328ab25552 100644 --- a/spec/ruby/library/yaml/to_yaml_spec.rb +++ b/spec/ruby/library/yaml/to_yaml_spec.rb @@ -32,25 +32,25 @@ describe "Object#to_yaml" do it "returns the YAML representation of a FalseClass" do false_klass = false - false_klass.should be_kind_of(FalseClass) + false_klass.should.is_a?(FalseClass) false_klass.to_yaml.should match_yaml("--- false\n") end it "returns the YAML representation of a Float object" do float = 1.2 - float.should be_kind_of(Float) + float.should.is_a?(Float) float.to_yaml.should match_yaml("--- 1.2\n") end it "returns the YAML representation of an Integer object" do int = 20 - int.should be_kind_of(Integer) + int.should.is_a?(Integer) int.to_yaml.should match_yaml("--- 20\n") end it "returns the YAML representation of a NilClass object" do nil_klass = nil - nil_klass.should be_kind_of(NilClass) + nil_klass.should.is_a?(NilClass) nil_klass.to_yaml.should match_yaml("--- \n") end @@ -65,6 +65,8 @@ describe "Object#to_yaml" do it "returns the YAML representation of a Struct object" do Person = Struct.new(:name, :gender) Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n") + ensure + Object.send(:remove_const, :Person) end it "returns the YAML representation of an unnamed Struct object" do @@ -82,7 +84,7 @@ describe "Object#to_yaml" do it "returns the YAML representation of a TrueClass" do true_klass = true - true_klass.should be_kind_of(TrueClass) + true_klass.should.is_a?(TrueClass) true_klass.to_yaml.should match_yaml("--- true\n") end @@ -92,10 +94,10 @@ describe "Object#to_yaml" do it "returns the YAML representation for Range objects" do yaml = Range.new(1,3).to_yaml - yaml.include?("!ruby/range").should be_true - yaml.include?("begin: 1").should be_true - yaml.include?("end: 3").should be_true - yaml.include?("excl: false").should be_true + yaml.include?("!ruby/range").should == true + yaml.include?("begin: 1").should == true + yaml.include?("end: 3").should == true + yaml.include?("excl: false").should == true end it "returns the YAML representation of numeric constants" do |
