summaryrefslogtreecommitdiff
path: root/spec/ruby/library/yaml
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/yaml')
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb20
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb2
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb2
-rw-r--r--spec/ruby/library/yaml/shared/each_document.rb19
-rw-r--r--spec/ruby/library/yaml/shared/load.rb6
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb18
6 files changed, 31 insertions, 36 deletions
diff --git a/spec/ruby/library/yaml/load_stream_spec.rb b/spec/ruby/library/yaml/load_stream_spec.rb
index 31bc862f5e..5f5d4c7337 100644
--- a/spec/ruby/library/yaml/load_stream_spec.rb
+++ b/spec/ruby/library/yaml/load_stream_spec.rb
@@ -1,9 +1,23 @@
require_relative '../../spec_helper'
require_relative 'fixtures/strings'
-require_relative 'shared/each_document'
-
require 'yaml'
describe "YAML.load_stream" do
- it_behaves_like :yaml_each_document, :load_stream
+ it "calls the block on each successive document" do
+ documents = []
+ YAML.load_stream(YAMLSpecs::MULTIDOCUMENT) do |doc|
+ documents << doc
+ end
+ documents.should == [["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
+ ["Chicago Cubs", "St Louis Cardinals"]]
+ end
+
+ it "works on files" do
+ test_parse_file = fixture __FILE__, "test_yaml.yml"
+ File.open(test_parse_file, "r") do |file|
+ YAML.load_stream(file) do |doc|
+ doc.should == {"project"=>{"name"=>"RubySpec"}}
+ end
+ end
+ end
end
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/each_document.rb b/spec/ruby/library/yaml/shared/each_document.rb
deleted file mode 100644
index 6f00aee297..0000000000
--- a/spec/ruby/library/yaml/shared/each_document.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-describe :yaml_each_document, shared: true do
- it "calls the block on each successive document" do
- documents = []
- YAML.send(@method, YAMLSpecs::MULTIDOCUMENT) do |doc|
- documents << doc
- end
- documents.should == [["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
- ["Chicago Cubs", "St Louis Cardinals"]]
- end
-
- it "works on files" do
- test_parse_file = fixture __FILE__, "test_yaml.yml"
- File.open(test_parse_file, "r") do |file|
- YAML.send(@method, file) do |doc|
- doc.should == {"project"=>{"name"=>"RubySpec"}}
- end
- end
- end
-end
diff --git a/spec/ruby/library/yaml/shared/load.rb b/spec/ruby/library/yaml/shared/load.rb
index b8bb605b0a..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,7 +117,7 @@ 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
@@ -137,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 08c5451416..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
@@ -84,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
@@ -94,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