Skip to content

Commit

Permalink
Inline and remove inspect_source_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Eres authored and bbatsov committed Dec 24, 2020
1 parent f57312a commit d160595
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions lib/rubocop/rspec/cop_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ module CopHelper
let(:ruby_version) { 2.4 }
let(:rails_version) { false }

def inspect_source_file(source)
Tempfile.open('tmp') { |f| inspect_source(source, f) }
end

def inspect_source(source, file = nil)
RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}
RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}
Expand Down
12 changes: 10 additions & 2 deletions spec/rubocop/cop/layout/end_of_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
# be moved somewhere more general ?
# Also working with encodings is actually the responsibility of
# 'whitequark/parser' gem, not Rubocop itself so these test really belongs there(?)
offenses = inspect_source_file(<<~RUBY)

encoding = 'iso-8859-15'
input = (+<<~RUBY).force_encoding(encoding)
# coding: ISO-8859-15#{eol}
# Euro symbol: \xa4#{eol}
RUBY
expect(offenses.size).to eq(1)

expect do
Tempfile.open('tmp', encoding: encoding) { |f| expect_no_offenses(input, f) }
end.to raise_error(
RSpec::Expectations::ExpectationNotMetError,
/Carriage return character (detected|missing)./
)
end
end

Expand Down

0 comments on commit d160595

Please sign in to comment.