Sha256: a58a3cf0789eddb664ff98d8bb9e6a2e5f1672e6e8f9afa4a6fa77a1c7f0d787

Contents?: true

Size: 838 Bytes

Versions: 3

Compression:

Stored size: 838 Bytes

Contents

require 'spec_helper'

describe HeartlandRetail::Client::Body do
  let(:hash) { {"key1" => "val1", "key2" => {"subkey1" => "subval1"}} }
  let(:body) { HeartlandRetail::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

3 entries across 3 versions & 1 rubygems

Version Path
heartland-retail-5.1.0 spec/heartland/client/body_spec.rb
heartland-retail-5.0.1 spec/heartland/client/body_spec.rb
heartland-retail-5.0.0 spec/heartland/client/body_spec.rb