Skip to content

Commit

Permalink
Fix class_eval to be friendlier
Browse files Browse the repository at this point in the history
This came up in Style::EvalWithLocation. It makes backtraces easier to
follow.
  • Loading branch information
natesholland committed May 5, 2019
1 parent 92686f2 commit fb6d66e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/http/mime_type/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class << self
end

%w[encode decode].each do |operation|
class_eval <<-RUBY, __FILE__, __LINE__
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{operation}(*)
fail Error, "\#{self.class} does not supports ##{operation}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/http/response/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def inspect
end

SYMBOLS.each do |code, symbol|
class_eval <<-RUBY, __FILE__, __LINE__
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{symbol}? # def bad_request?
#{code} == code # 400 == code
end # end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/http/response/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

described_class::REASONS.each do |code, reason|
class_eval <<-RUBY
class_eval <<-RUBY, __FILE__, __LINE__ + 1
context 'with well-known code: #{code}' do
let(:code) { #{code} }
it { is_expected.to eq #{reason.inspect} }
Expand Down Expand Up @@ -165,7 +165,7 @@
end

described_class::SYMBOLS.each do |code, symbol|
class_eval <<-RUBY
class_eval <<-RUBY, __FILE__, __LINE__ + 1
context 'with well-known code: #{code}' do
let(:code) { #{code} }
it { is_expected.to be #{symbol.inspect} }
Expand Down Expand Up @@ -193,7 +193,7 @@
end

described_class::SYMBOLS.each do |code, symbol|
class_eval <<-RUBY
class_eval <<-RUBY, __FILE__, __LINE__ + 1
describe '##{symbol}?' do
subject { status.#{symbol}? }
Expand Down
2 changes: 1 addition & 1 deletion spec/support/dummy_server/servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def self.handlers
end

%w[get post head].each do |method|
class_eval <<-RUBY, __FILE__, __LINE__
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def self.#{method}(path, &block)
handlers["#{method}:\#{path}"] = block
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/ssl_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def client_params
end

%w[server client].each do |side|
class_eval <<-RUBY, __FILE__, __LINE__
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{side}_cert
@#{side}_cert ||= ChildCertificate.new ca
end
Expand Down

0 comments on commit fb6d66e

Please sign in to comment.