Skip to content

Commit

Permalink
Merge pull request #8 from DannyBen/change/default-prompt-answer
Browse files Browse the repository at this point in the history
Change default prompt response from Yes to No
  • Loading branch information
DannyBen committed Jun 16, 2023
2 parents 6392047 + fdf6fa0 commit 494be83
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
matrix: { ruby: ['2.7', '3.0', '3.1', '3.2', head] }
matrix: { ruby: ['3.0', '3.1', '3.2', head] }

steps:
- name: Check out code
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inherit_gem:
- rspec.yml

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0
Exclude:
- dev/**/*
- sample/**/*
8 changes: 4 additions & 4 deletions lib/recode/handler/prompt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def apply?
when 'q', "\u0003"
say 'b`Quit`'
raise Recode::Abort
when 'n'
say 'r`No`'
false
else
when 'y'
say 'g`Yes`'
true
else
say 'r`No`'
false
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/recode/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def changes
end

def files
@files ||= Dir["#{path}/**/*.{#{extensions.join ','}}"].sort
@files ||= Dir["#{path}/**/*.{#{extensions.join ','}}"]
end

def refresh_files
Expand Down
10 changes: 8 additions & 2 deletions recode.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/dannyben/recode'
s.license = 'MIT'

s.required_ruby_version = '>= 2.7.0'
s.required_ruby_version = '>= 3.0'

s.add_runtime_dependency 'colsole', '>= 0.8.1', '< 2'
s.add_runtime_dependency 'diffy', '~> 3.3'
s.add_runtime_dependency 'mister_bin', '~> 0.7'
s.add_runtime_dependency 'strings-inflection', '~> 0.1'
s.metadata['rubygems_mfa_required'] = 'true'

s.metadata = {
'bug_tracker_uri' => 'https://github.com/DannyBen/recode/issues',
'changelog_uri' => 'https://github.com/DannyBen/recode/blob/master/CHANGELOG.md',
'source_code_uri' => 'https://github.com/DannyBen/recode',
'rubygems_mfa_required' => 'true',
}
end
28 changes: 15 additions & 13 deletions spec/recode/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@
end

context 'with --prompt' do
it 'applies the refactor changes' do
allow($stdin).to receive(:getch).and_return('y')

in_sample_dir do
expect { subject.run %w[Person to User in rb yml --prompt] }
.to output_approval('cli/refactor/person-user-prompt')
end
end

context 'when answering no' do
it 'does not apply the changes' do
allow($stdin).to receive(:getch).and_return 'n'
context 'when answering yes' do
it 'applies the refactor changes' do
allow($stdin).to receive(:getch).and_return('y')

in_sample_dir do
expect { subject.run %w[Person to User in rb yml --prompt] }
.to output_approval('cli/refactor/person-user-prompt-no')
.to output_approval('cli/refactor/person-user-prompt')
end
end
end
Expand All @@ -65,6 +56,17 @@
end
end
end

context 'when answering anything but quit or yes' do
it 'does not apply the changes' do
allow($stdin).to receive(:getch).and_return 'k'

in_sample_dir do
expect { subject.run %w[Person to User in rb yml --prompt] }
.to output_approval('cli/refactor/person-user-prompt-no')
end
end
end
end
end
end

0 comments on commit 494be83

Please sign in to comment.