summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/helpers/io_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/spec/helpers/io_spec.rb')
-rw-r--r--spec/mspec/spec/helpers/io_spec.rb48
1 files changed, 24 insertions, 24 deletions
diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb
index 4fa1f97d46..14c1a2d6b5 100644
--- a/spec/mspec/spec/helpers/io_spec.rb
+++ b/spec/mspec/spec/helpers/io_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'
-describe IOStub do
+RSpec.describe IOStub do
before :each do
@out = IOStub.new
@sep = $\
@@ -14,42 +14,42 @@ describe IOStub do
it "provides a write method" do
@out.write "this"
- @out.should == "this"
+ expect(@out).to eq("this")
end
it "concatenates the arguments sent to write" do
@out.write "flim ", "flam"
- @out.should == "flim flam"
+ expect(@out).to eq("flim flam")
end
it "provides a print method that appends the default separator" do
$\ = " [newline] "
@out.print "hello"
@out.print "world"
- @out.should == "hello [newline] world [newline] "
+ expect(@out).to eq("hello [newline] world [newline] ")
end
it "provides a puts method that appends the default separator" do
@out.puts "hello", 1, 2, 3
- @out.should == "hello\n1\n2\n3\n"
+ expect(@out).to eq("hello\n1\n2\n3\n")
end
it "provides a puts method that appends separator if argument not given" do
@out.puts
- @out.should == "\n"
+ expect(@out).to eq("\n")
end
it "provides a printf method" do
@out.printf "%-10s, %03d, %2.1f", "test", 42, 4.2
- @out.should == "test , 042, 4.2"
+ expect(@out).to eq("test , 042, 4.2")
end
it "provides a flush method that does nothing and returns self" do
- @out.flush.should == @out
+ expect(@out.flush).to eq(@out)
end
end
-describe Object, "#new_fd" do
+RSpec.describe Object, "#new_fd" do
before :each do
@name = tmp("io_specs")
@io = nil
@@ -62,34 +62,34 @@ describe Object, "#new_fd" do
it "returns an Integer that can be used to create an IO instance" do
fd = new_fd @name
- fd.should be_kind_of(Integer)
+ expect(fd).to be_kind_of(Integer)
@io = IO.new fd, 'w:utf-8'
@io.sync = true
@io.print "io data"
- IO.read(@name).should == "io data"
+ expect(IO.read(@name)).to eq("io data")
end
it "accepts an options Hash" do
- FeatureGuard.stub(:enabled?).and_return(true)
+ allow(FeatureGuard).to receive(:enabled?).and_return(true)
fd = new_fd @name, { :mode => 'w:utf-8' }
- fd.should be_kind_of(Integer)
+ expect(fd).to be_kind_of(Integer)
@io = IO.new fd, 'w:utf-8'
@io.sync = true
@io.print "io data"
- IO.read(@name).should == "io data"
+ expect(IO.read(@name)).to eq("io data")
end
it "raises an ArgumentError if the options Hash does not include :mode" do
- FeatureGuard.stub(:enabled?).and_return(true)
- lambda { new_fd @name, { :encoding => "utf-8" } }.should raise_error(ArgumentError)
+ allow(FeatureGuard).to receive(:enabled?).and_return(true)
+ expect { new_fd @name, { :encoding => "utf-8" } }.to raise_error(ArgumentError)
end
end
-describe Object, "#new_io" do
+RSpec.describe Object, "#new_io" do
before :each do
@name = tmp("io_specs.txt")
end
@@ -101,14 +101,14 @@ describe Object, "#new_io" do
it "returns a File instance" do
@io = new_io @name
- @io.should be_an_instance_of(File)
+ expect(@io).to be_an_instance_of(File)
end
it "opens the IO for reading if passed 'r'" do
touch(@name) { |f| f.print "io data" }
@io = new_io @name, "r"
- @io.read.should == "io data"
- lambda { @io.puts "more data" }.should raise_error(IOError)
+ expect(@io.read).to eq("io data")
+ expect { @io.puts "more data" }.to raise_error(IOError)
end
it "opens the IO for writing if passed 'w'" do
@@ -116,14 +116,14 @@ describe Object, "#new_io" do
@io.sync = true
@io.print "io data"
- IO.read(@name).should == "io data"
+ expect(IO.read(@name)).to eq("io data")
end
it "opens the IO for reading if passed { :mode => 'r' }" do
touch(@name) { |f| f.print "io data" }
@io = new_io @name, { :mode => "r" }
- @io.read.should == "io data"
- lambda { @io.puts "more data" }.should raise_error(IOError)
+ expect(@io.read).to eq("io data")
+ expect { @io.puts "more data" }.to raise_error(IOError)
end
it "opens the IO for writing if passed { :mode => 'w' }" do
@@ -131,6 +131,6 @@ describe Object, "#new_io" do
@io.sync = true
@io.print "io data"
- IO.read(@name).should == "io data"
+ expect(IO.read(@name)).to eq("io data")
end
end