Skip to content

Commit

Permalink
Ruby: Handle more gemspec sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
greysteil committed Feb 27, 2019
1 parent 00fef36 commit bc9e1cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def on_send(node)
# that constant probably comes from a required file
replace_version_assignments(node)

# Remove any uses of a VERSION constant (or similar), as
# that constant probably comes from a required file
replace_version_constant_references(node)

# Replace the `s.files= ...` assignment with a blank array, as
# occassionally a File.open(..).readlines pattern is used
replace_file_assignments(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@
let(:content) { 'Spec.new { |s| s.version = "#{Example::Version}" }' }
it { is_expected.to eq('Spec.new { |s| s.version = "#{"1.5.0"}" }') }
end
# rubocop:enable Lint/InterpolationCheck

# rubocop:disable Lint/InterpolationCheck
context "with a version constant used elsewhere in the file" do
let(:content) { 'Spec.new { |s| something == "v#{Example::Version}" }' }
it { is_expected.to eq('Spec.new { |s| something == "v#{"1.5.0"}" }') }
end

context "with a version constant used in assignment in the file" do
let(:content) { 'Spec.new { |s| something = "v#{Example::Version}" }' }
it { is_expected.to eq('Spec.new { |s| something = "v#{"1.5.0"}" }') }
end
Expand Down

0 comments on commit bc9e1cc

Please # to comment.