Skip to content

Commit

Permalink
Fix dubious test
Browse files Browse the repository at this point in the history
The readlines method of File always return an array (can be empty) if a
file could be read, or raise a Errno::ENOENT if a file does not exist,
Errno::EACCES if it cannot be read, etc.

It seems to never return nil, and the stubbing is not working as
expected with some versions of ruby.  Adjust the test to align with what
would happen in the real world.
  • Loading branch information
smortex committed Aug 14, 2024
1 parent 51736ee commit 067fd17
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions spec/unit/mcollective/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ module MCollective
end

it "should report a warning when the classes file cannot be parsed" do
File.stubs(:readlines).returns(nil)
Log.expects(:warn).with("Parsing classes file '/some/file' failed: NoMethodError: undefined method `each' for nil:NilClass")

File.stubs(:readlines).raises("error")
expect(Util.has_cf_class?("test_class_test")).to eq(false)
end
end
Expand Down

0 comments on commit 067fd17

Please sign in to comment.