Permalink
Browse files

raise OTNetstring::Error when trying to encode non-primitive objects

  • Loading branch information...
1 parent 6644b75 commit 6d3076461928cc7c90400dbb8559dfa3077c4e54 @rkh committed May 15, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/otnetstring.rb
  2. +1 −1 spec/otnetstring_spec.rb
View
@@ -42,7 +42,7 @@ def self.encode(obj, string_sep = ',')
when Array then encode(obj.map { |e| encode(e) }.join, '[')
when Hash then encode(obj.map { |a,b| encode(a)+encode(b) }.join, '{')
when FalseClass, TrueClass then encode(obj.inspect, '!')
- else fail 'cannot encode %p' % obj
+ else raise Error, 'cannot encode %p' % obj
end
end
end
View
@@ -131,7 +131,7 @@
end
it "rejects non-primitives" do
- expect { TNetstring.encode(Object.new) }.to raise_error
+ expect { OTNetstring.encode(Object.new) }.to raise_error(OTNetstring::Error)
end
end
end

0 comments on commit 6d30764

Please sign in to comment.