2018-01-29 11:08:16 -05:00
|
|
|
describe :key_error, shared: true do
|
|
|
|
it "raises a KeyError" do
|
|
|
|
-> {
|
|
|
|
@method.call(@object, 'foo')
|
|
|
|
}.should raise_error(KeyError)
|
|
|
|
end
|
|
|
|
|
2020-02-08 05:43:27 -05:00
|
|
|
it "sets the Hash as the receiver of KeyError" do
|
|
|
|
-> {
|
|
|
|
@method.call(@object, 'foo')
|
|
|
|
}.should raise_error(KeyError) { |err|
|
|
|
|
err.receiver.should equal(@object)
|
|
|
|
}
|
|
|
|
end
|
2018-01-29 11:08:16 -05:00
|
|
|
|
2020-02-08 05:43:27 -05:00
|
|
|
it "sets the unmatched key as the key of KeyError" do
|
|
|
|
-> {
|
|
|
|
@method.call(@object, 'foo')
|
|
|
|
}.should raise_error(KeyError) { |err|
|
|
|
|
err.key.to_s.should == 'foo'
|
|
|
|
}
|
2018-01-29 11:08:16 -05:00
|
|
|
end
|
|
|
|
end
|