Skip to content

Commit

Permalink
Fix Dir#exists? deprecation warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
bigzed authored and JonRowe committed Jan 7, 2023
1 parent 3d3045b commit a85d0a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
### Development
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...3-12-maintenance)

Bug Fixes:

* Fix `exist` matcher warning when used with `Dir`. (Steve Dierker, #1398)

### 3.12.1 / 2022-12-16
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.0...v3.12.1)

Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/matchers/built_in/exist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def predicates
end

def deprecated(predicate, actual)
predicate == :exists? && (File == actual || FileTest == actual)
predicate == :exists? && (File == actual || FileTest == actual || Dir == actual)
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/rspec/matchers/built_in/exist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def send
expect(FileTest).to exist __FILE__
end
end

if RUBY_VERSION > "1.9"
context 'Dir has deprecated exists?' do
it 'will not call exists? triggering the warning' do
expect(Dir).to exist Dir.pwd
end
end
end
end
end

Expand Down

0 comments on commit a85d0a6

Please sign in to comment.