Sha256: 0b5a165e8fb324edacc667aca86aea09245f62235132a26717c74384f62c7bb7

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

require "spec_helper"

describe Her::Middleware::DefaultParseJSON do
  subject { described_class.new }
  let(:body) { "{\"data\": 1, \"errors\": 2, \"metadata\": 3}" }

  it "parses body as json" do
    subject.parse(body).tap do |json|
      json[:data].should == 1
      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 == 1
      json[:errors].should == 2
      json[:metadata].should == 3
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
her-0.1.8.1 spec/middleware/default_parse_json_spec.rb
her-0.1.8 spec/middleware/default_parse_json_spec.rb