Sha256: d98292ebb5e87f2de1e942eea9aaa7dfdcd9c192115c4b777184b97ddf7dd0e8

Contents?: true

Size: 676 Bytes

Versions: 3

Compression:

Stored size: 676 Bytes

Contents

require "spec_helper"

describe Pliny::Helpers::Params do

  def app
    Sinatra.new do
      helpers Pliny::Helpers::Params
      post "/" do
        body_params.to_json
      end
    end
  end

  it "loads json params" do
    post "/", {hello: "world"}.to_json, {'CONTENT_TYPE' => 'application/json'}
    assert_equal "{\"hello\":\"world\"}", last_response.body
  end

  it "loads form data params" do
    post "/", {hello: "world"}
    assert_equal "{\"hello\":\"world\"}", last_response.body
  end

  it "loads from an unknown content type" do
    post "/", "<hello>world</hello>", {'CONTENT_TYPE' => 'application/xml'}
    assert_equal "{}", last_response.body
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pliny-0.27.0 spec/helpers/params_spec.rb
pliny-0.26.2 spec/helpers/params_spec.rb
pliny-0.26.1 spec/helpers/params_spec.rb