Permalink
Browse files

Change key error to argument error.

Ruby 1.8 and 1.9 raise different errors for key missing when using
fetch.
  • Loading branch information...
1 parent 8e25489 commit ffb0d9de41a12bc07f701953270a8d6c8ad0ca13 @jnunemaker jnunemaker committed Oct 11, 2012
View
2 lib/plucky/normalizers/options_hash_value.rb
@@ -7,7 +7,7 @@ module Normalizers
class OptionsHashValue
def initialize(args = {})
@key_normalizer = args.fetch(:key_normalizer) {
- raise KeyError, "Missing required argument :key_normalizer"
+ raise ArgumentError, "Missing required key :key_normalizer"
}
@value_normalizers = {
View
2 lib/plucky/normalizers/sort_value.rb
@@ -3,7 +3,7 @@ module Normalizers
class SortValue
def initialize(args = {})
- @key_normalizer = args.fetch(:key_normalizer) { raise KeyError, "Missing required argument :key_normalizer" }
+ @key_normalizer = args.fetch(:key_normalizer) { raise ArgumentError, "Missing required key :key_normalizer" }
end
# Public: Given a value returns it normalized for Mongo's sort option
View
2 spec/plucky/normalizers/options_hash_value_spec.rb
@@ -28,7 +28,7 @@
it "raises exception if missing key normalizer" do
expect {
described_class.new
- }.to raise_error(KeyError, "Missing required argument :key_normalizer")
+ }.to raise_error(ArgumentError, "Missing required key :key_normalizer")
end
it "allows injecting a new value normalizer" do

0 comments on commit ffb0d9d

Please sign in to comment.