Sha256: 872eff2634413101a283d4225bd5443eaf6921d975c760762f07da2af41960c7

Contents?: true

Size: 721 Bytes

Versions: 12

Compression:

Stored size: 721 Bytes

Contents

# encoding: utf-8
require "spec_helper"

describe Her::Middleware::FirstLevelParseJSON do
  subject { described_class.new }
  let(:body) { "{\"id\": 1, \"name\": \"Tobias Fünke\", \"errors\": 2, \"metadata\": 3}" }

  it "parses body as json" do
    subject.parse(body).tap do |json|
      json[:data].should == { :id => 1, :name => "Tobias Fünke" }
      json[:errors].should == 2
      json[:metadata].should == 3
    end
  end

  it "parses :body key as json in the env hash" do
    env = { :body => body }
    subject.on_complete(env)
    env[:body].tap do |json|
      json[:data].should == { :id => 1, :name => "Tobias Fünke" }
      json[:errors].should == 2
      json[:metadata].should == 3
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
her-0.3.6 spec/middleware/first_level_parse_json_spec.rb
her-0.3.5 spec/middleware/first_level_parse_json_spec.rb
her-0.3.4 spec/middleware/first_level_parse_json_spec.rb
her-0.3.1 spec/middleware/first_level_parse_json_spec.rb
her-0.3 spec/middleware/first_level_parse_json_spec.rb
her-0.2.6 spec/middleware/first_level_parse_json_spec.rb
her-0.2.5 spec/middleware/first_level_parse_json_spec.rb
her-0.2.4 spec/middleware/first_level_parse_json_spec.rb
her-0.2.3 spec/middleware/first_level_parse_json_spec.rb
her-0.2.2 spec/middleware/first_level_parse_json_spec.rb
her-0.2.1 spec/middleware/first_level_parse_json_spec.rb
her-0.2 spec/middleware/first_level_parse_json_spec.rb