Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Eliminate File.exists? deprecation warnings on Ruby 2.1.0

  • Loading branch information...
commit 3d21b52eef5538f4ed57699b0ce05c88f735509f 1 parent 7d00ea4
@pixeltrix pixeltrix authored
View
10 spec/actions/create_file_spec.rb
@@ -29,13 +29,13 @@ def silence!
it 'creates a file' do
create_file('doc/config.rb')
invoke!
- expect(File.exists?(File.join(destination_root, 'doc/config.rb'))).to be true
+ expect(File.exist?(File.join(destination_root, 'doc/config.rb'))).to be true
end
it 'does not create a file if pretending' do
create_file('doc/config.rb', {}, :pretend => true)
invoke!
- expect(File.exists?(File.join(destination_root, 'doc/config.rb'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc/config.rb'))).to be false
end
it 'shows created status to the user' do
@@ -58,7 +58,7 @@ def silence!
it 'converts encoded instructions' do
create_file('doc/%file_name%.rb.tt')
invoke!
- expect(File.exists?(File.join(destination_root, 'doc/rdoc.rb.tt'))).to be true
+ expect(File.exist?(File.join(destination_root, 'doc/rdoc.rb.tt'))).to be true
end
describe 'when file exists' do
@@ -137,13 +137,13 @@ def silence!
create_file('doc/config.rb')
invoke!
revoke!
- expect(File.exists?(@action.destination)).to be false
+ expect(File.exist?(@action.destination)).to be false
end
it 'does not raise an error if the file does not exist' do
create_file('doc/config.rb')
revoke!
- expect(File.exists?(@action.destination)).to be false
+ expect(File.exist?(@action.destination)).to be false
end
end
View
8 spec/actions/create_link_spec.rb
@@ -36,7 +36,7 @@ def silence!
create_link('doc/config.rb', :symbolic => true)
invoke!
destination_path = File.join(destination_root, 'doc/config.rb')
- expect(File.exists?(destination_path)).to be true
+ expect(File.exist?(destination_path)).to be true
expect(File.symlink?(destination_path)).to be true
end
@@ -44,7 +44,7 @@ def silence!
create_link(@hardlink_to, :symbolic => false)
invoke!
destination_path = @hardlink_to
- expect(File.exists?(destination_path)).to be true
+ expect(File.exist?(destination_path)).to be true
expect(File.symlink?(destination_path)).to be false
end
@@ -52,14 +52,14 @@ def silence!
create_link('doc/config.rb')
invoke!
destination_path = File.join(destination_root, 'doc/config.rb')
- expect(File.exists?(destination_path)).to be true
+ expect(File.exist?(destination_path)).to be true
expect(File.symlink?(destination_path)).to be true
end
it 'does not create a link if pretending' do
create_link('doc/config.rb', {}, :pretend => true)
invoke!
- expect(File.exists?(File.join(destination_root, 'doc/config.rb'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc/config.rb'))).to be false
end
it 'shows created status to the user' do
View
32 spec/actions/directory_spec.rb
@@ -28,7 +28,7 @@ def exists_and_identical?(source_path, destination_path)
source = File.join(source_root, source_path, file)
destination = File.join(destination_root, destination_path, file)
- expect(File.exists?(destination)).to be true
+ expect(File.exist?(destination)).to be true
expect(FileUtils.identical?(source, destination)).to be true
end
end
@@ -42,7 +42,7 @@ def exists_and_identical?(source_path, destination_path)
it 'does not create a directory in pretend mode' do
invoke! 'doc', 'ghost', :pretend => true
- expect(File.exists?('ghost')).to be false
+ expect(File.exist?('ghost')).to be false
end
it 'copies the whole directory recursively to the default destination' do
@@ -59,25 +59,25 @@ def exists_and_identical?(source_path, destination_path)
invoke! '.', 'commands', :recursive => false
file = File.join(destination_root, 'commands', 'group.thor')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
file = File.join(destination_root, 'commands', 'doc')
- expect(File.exists?(file)).to be false
+ expect(File.exist?(file)).to be false
file = File.join(destination_root, 'commands', 'doc', 'README')
- expect(File.exists?(file)).to be false
+ expect(File.exist?(file)).to be false
end
it 'ignores files within excluding/ directories when exclude_pattern is provided' do
invoke! 'doc', 'docs', :exclude_pattern => /excluding\//
file = File.join(destination_root, 'docs', 'excluding', 'rdoc.rb')
- expect(File.exists?(file)).to be false
+ expect(File.exist?(file)).to be false
end
it 'copies and evaluates files within excluding/ directory when no exclude_pattern is present' do
invoke! 'doc', 'docs'
file = File.join(destination_root, 'docs', 'excluding', 'rdoc.rb')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
expect(File.read(file)).to eq("BAR = BAR\n")
end
@@ -91,7 +91,7 @@ def exists_and_identical?(source_path, destination_path)
it 'copies and evaluates templates' do
invoke! 'doc', 'docs'
file = File.join(destination_root, 'docs', 'rdoc.rb')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
expect(File.read(file)).to eq("FOO = FOO\n")
end
@@ -105,20 +105,20 @@ def exists_and_identical?(source_path, destination_path)
it 'copies directories' do
invoke! 'doc', 'docs'
file = File.join(destination_root, 'docs', 'components')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
expect(File.directory?(file)).to be true
end
it 'does not copy .empty_directory files' do
invoke! 'doc', 'docs'
file = File.join(destination_root, 'docs', 'components', '.empty_directory')
- expect(File.exists?(file)).to be false
+ expect(File.exist?(file)).to be false
end
it 'copies directories even if they are empty' do
invoke! 'doc/components', 'docs/components'
file = File.join(destination_root, 'docs', 'components')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
it 'does not copy empty directories twice' do
@@ -153,17 +153,17 @@ def exists_and_identical?(source_path, destination_path)
invoke! 'doc'
revoke! 'doc'
- expect(File.exists?(File.join(destination_root, 'doc', 'README'))).to be false
- expect(File.exists?(File.join(destination_root, 'doc', 'config.rb'))).to be false
- expect(File.exists?(File.join(destination_root, 'doc', 'components'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc', 'README'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc', 'config.rb'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc', 'components'))).to be false
end
it 'works with glob characters in the path' do
invoke! 'app{1}'
- expect(File.exists?(File.join(destination_root, 'app{1}', 'README'))).to be true
+ expect(File.exist?(File.join(destination_root, 'app{1}', 'README'))).to be true
revoke! 'app{1}'
- expect(File.exists?(File.join(destination_root, 'app{1}', 'README'))).to be false
+ expect(File.exist?(File.join(destination_root, 'app{1}', 'README'))).to be false
end
end
end
View
6 spec/actions/empty_directory_spec.rb
@@ -54,7 +54,7 @@ def base
it 'copies the file to the specified destination' do
empty_directory('doc')
invoke!
- expect(File.exists?(File.join(destination_root, 'doc'))).to be true
+ expect(File.exist?(File.join(destination_root, 'doc'))).to be true
end
it 'shows created status to the user' do
@@ -66,7 +66,7 @@ def base
base.inside('foo', :pretend => true) do
empty_directory('ghost')
end
- expect(File.exists?(File.join(base.destination_root, 'ghost'))).to be false
+ expect(File.exist?(File.join(base.destination_root, 'ghost'))).to be false
end
describe 'when directory exists' do
@@ -83,7 +83,7 @@ def base
empty_directory('doc')
invoke!
revoke!
- expect(File.exists?(@action.destination)).to be false
+ expect(File.exist?(@action.destination)).to be false
end
end
View
16 spec/actions/file_manipulation_spec.rb
@@ -13,7 +13,7 @@ def action(*args, &block)
def exists_and_identical?(source, destination)
destination = File.join(destination_root, destination)
- expect(File.exists?(destination)).to be true
+ expect(File.exist?(destination)).to be true
source = File.join(source_root, source)
expect(FileUtils).to be_identical(source, destination)
@@ -174,21 +174,21 @@ def file
it 'copies the template to the specified destination' do
action :template, 'doc/config.rb', 'doc/configuration.rb'
file = File.join(destination_root, 'doc/configuration.rb')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
it 'converts encoded instructions' do
expect(runner).to receive(:file_name).and_return('rdoc')
action :template, 'doc/%file_name%.rb.tt'
file = File.join(destination_root, 'doc/rdoc.rb')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
it 'accepts filename without .tt for template method' do
expect(runner).to receive(:file_name).and_return('rdoc')
action :template, 'doc/%file_name%.rb'
file = File.join(destination_root, 'doc/rdoc.rb')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
it 'logs status' do
@@ -206,7 +206,7 @@ def file
action :template, 'doc/config.yaml.tt'
file = File.join(destination_root, 'doc/config.yaml')
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
end
@@ -222,18 +222,18 @@ def file
describe '#remove_file' do
it 'removes the file given' do
action :remove_file, 'doc/README'
- expect(File.exists?(file)).to be false
+ expect(File.exist?(file)).to be false
end
it 'removes directories too' do
action :remove_dir, 'doc'
- expect(File.exists?(File.join(destination_root, 'doc'))).to be false
+ expect(File.exist?(File.join(destination_root, 'doc'))).to be false
end
it 'does not remove if pretending' do
runner(:pretend => true)
action :remove_file, 'doc/README'
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
it 'logs status' do
View
4 spec/actions_spec.rb
@@ -146,14 +146,14 @@ def file
it 'creates the directory if it does not exist' do
runner.inside('foo') do
- expect(File.exists?(file)).to be true
+ expect(File.exist?(file)).to be true
end
end
describe 'when pretending' do
it 'no directories should be created' do
runner.inside('bar', :pretend => true) {}
- expect(File.exists?('bar')).to be false
+ expect(File.exist?('bar')).to be false
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.