Skip to content

Commit

Permalink
Stub File.read instead of IO.read in spec.
Browse files Browse the repository at this point in the history
Ruby 2.6 changed Pathname#read from using IO.read to File.read.
  • Loading branch information
jackorp authored and rymai committed Apr 4, 2019
1 parent fbae74a commit f469f51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spec/lib/guard/guardfile/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
let(:template) { File.join(described_class::HOME_TEMPLATES, "/bar") }

it "copies the Guardfile template and initializes the Guard" do
expect(IO).to receive(:read)
expect(File).to receive(:read)
.with(template).and_return "Template content"

expected = "\nTemplate content\n"
Expand All @@ -113,7 +113,7 @@
expect(::Guard::PluginUtil).to receive(:new) { plugin_util }
allow(plugin_util).to receive(:plugin_class) { nil }
path = File.expand_path("~/.guard/templates/foo")
expect(IO).to receive(:read).with(path) do
expect(File).to receive(:read).with(path) do
fail Errno::ENOENT
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def stub_file(path, contents = nil, &block)
allow(File).to receive(:exist?).with(path).and_return(exists)
if exists
if block.nil?
allow(IO).to receive(:read).with(path).and_return(contents)
allow(File).to receive(:read).with(path).and_return(contents)
else
allow(IO).to receive(:read).with(path) do
allow(File).to receive(:read).with(path) do
yield
end
end
else
allow(IO).to receive(:read).with(path) do
allow(File).to receive(:read).with(path) do
fail Errno::ENOENT
end
end
Expand Down

0 comments on commit f469f51

Please sign in to comment.