Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/never_bounce/api/feature/require_attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module InstanceMethods
# Require attribute to be set. Return attribute value.
# @return [mixed]
def require_attr(name)
send(name).tap do |_|
raise AttributeError, "Attribute must be set: #{name}" if _.nil?
send(name).tap do |value|
raise AttributeError, "Attribute must be set: #{name}" if value == nil
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/never_bounce/api/feature/require_attr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,18 @@ def b
r.a = "a"
expect(r.b).to eq ["a", "b"]
end

it "doesn't trip HTTParty's deprecation warning on #nil?" do
request = instance_double(HTTParty::Request, options: {})
response = instance_double(Net::HTTPResponse, body: nil, to_hash: {})
parsed_block = lambda { nil }

server_obj = HTTParty::Response.new(request, response, parsed_block)

r = klass.new
r.a = server_obj

expect { r.b }.not_to output(/DEPRECATION/).to_stderr
end
end
end; end; end