Permalink
Browse files

hash response wrapper doesnt return nil for non present attributes

  • Loading branch information...
1 parent fd6a8eb commit 39b66f159057d0bd02186e1a8c6c09228187d66f @jwagener jwagener committed Feb 22, 2011
Showing with 8 additions and 1 deletion.
  1. +3 −1 lib/soundcloud/hash_response_wrapper.rb
  2. +5 −0 spec/soundcloud/hash_response_wrapper_spec.rb
@@ -1,7 +1,9 @@
class Soundcloud::HashResponseWrapper < Hashie::Mash
attr_reader :response
def initialize(response, *args)
- super(response, *args)
+ super(response, *args) do |x|
+ raise NoMethodError
+ end
@response = response
end
end
@@ -5,6 +5,11 @@
it "should provide a Mash with accessors for the key/values of the passed response" do
Soundcloud::HashResponseWrapper.new({:foo => 'bar'}).foo.should == 'bar'
end
+
+ it "should not have nil accessors for non present keys" do
+ Soundcloud::HashResponseWrapper.new({:foo => 'bar'}).should raise_error
+ end
+
end
describe '#response' do

0 comments on commit 39b66f1

Please sign in to comment.