test/angelo/params_spec.rb in angelo-0.3.3 vs test/angelo/params_spec.rb in angelo-0.4.0

- old
+ new

@@ -58,10 +58,17 @@ parser.json = true parser.body = json_params parser.parse_post_body.must_equal post_params end + it "doesn't choke on empty JSON POST bodies" do + parser.form_encoded = false + parser.json = true + parser.body = "" + parser.parse_post_body.must_equal({}) + end + it 'recursively symhashes JSON POST bodies params' do nested = { foo: { bar: 'baz', that: { @@ -82,18 +89,36 @@ it 'should override query string with JSON POST bodies params' do parser.form_encoded = false parser.json = true parser.query_string = get_params parser.body = json_params - parser.parse_post_body.must_equal post_params + parser.parse_query_string_and_post_body.must_equal post_params end it 'does not parse POST bodies if no Content-Type' do parser.form_encoded = false parser.json = false parser.query_string = get_params parser.body = nil - parser.parse_post_body.must_equal params_s parser.parse_query_string.must_equal params_s + parser.parse_post_body.must_equal({}) + parser.parse_query_string_and_post_body.must_equal params_s + end + +end + +describe Angelo::SymHash do + + describe ".new" do + it "returns a Hash" do + Angelo::SymHash.new.must_be_kind_of Hash + end + end + + it "fetches values for Symbols that were inserted with Strings" do + symhash = Angelo::SymHash.new + symhash["x"] = "y" + symhash["x"].must_equal "y" + symhash[:x].must_equal "y" end end