Sha256: 6fcb82d902d0cb73d2879bef3e5450fe458300107d097624a1200b14ba31da2c

Contents?: true

Size: 831 Bytes

Versions: 7

Compression:

Stored size: 831 Bytes

Contents

require 'spec_helper'

describe Springboard::Client::Body do
  let(:hash) { {"key1" => "val1", "key2" => {"subkey1" => "subval1"}} }
  let(:body) { Springboard::Client::Body.new(hash)}

  describe "[]" do
    it "should support string keys" do
      expect(body["key1"]).to eq("val1")
    end

    it "should support symbol keys" do
      expect(body[:key1]).to eq("val1")
    end
  end

  describe "nested hashes" do
    it "should support nested indifferent access" do
      expect(body[:key2][:subkey1]).to eq("subval1")
      expect(body['key2']['subkey1']).to eq("subval1")
      expect(body[:key2]['subkey1']).to eq("subval1")
      expect(body['key2'][:subkey1]).to eq("subval1")
    end
  end

  describe "to_hash" do
    it "should return the original hash" do
      expect(body.to_hash).to be === hash
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
springboard-retail-5.0.0.beta1 spec/springboard/client/body_spec.rb
springboard-retail-4.3.0 spec/springboard/client/body_spec.rb
springboard-retail-4.2.1 spec/springboard/client/body_spec.rb
springboard-retail-4.2.0 spec/springboard/client/body_spec.rb
springboard-retail-4.1.1 spec/springboard/client/body_spec.rb
springboard-retail-4.1.0 spec/springboard/client/body_spec.rb
springboard-retail-4.0.1 spec/springboard/client/body_spec.rb