test/angelo/params_spec.rb in angelo-0.4.1 vs test/angelo/params_spec.rb in angelo-0.5.0

- old
+ new

@@ -65,9 +65,30 @@ parser.json = true parser.body = "" parser.parse_post_body.must_equal({}) end + it "doesn't barf on JSON array POST bodies" do + parser.form_encoded = false + parser.json = true + parser.body = [123,234].to_json + ->{ parser.parse_post_body }.must_be_silent + end + + it 'raises properly on malformed JSON' do + parser.form_encoded = false + parser.json = true + parser.body = "{F(34nfnlv,-935;:fho2fhlj}}}function(){console.log('hi');}" + ->{ parser.parse_post_body }.must_raise JSON::ParserError + end + + it 'parses JSON array POST bodies' do + parser.form_encoded = false + parser.json = true + parser.body = [123,234].to_json + parser.parse_post_body.must_equal [123,234] + end + it 'recursively symhashes JSON POST bodies params' do nested = { foo: { bar: 'baz', that: {