Sha256: 39f97809b7e7f88a69864fa90c36799aa16562cbef4b717c59113442c7ca41ec

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

require 'spec_helper'

module DutyCalculator
  describe Response do
    context ".initialize" do
      it "coerces some uglyness" do
        hash = {
            "string_value" => "stringerific",
            "__content__" => "should_be_string",
            "nested_integer" => {
                "__content__" => "1223"
            },
            "nested_zero" => {
                "__content__" => "0"
            }
        }
        response = DutyCalculator::Response.new(hash)
        expect(response["string_value"].class).to eq(String)
        expect(response.keys.include?("value")).to eq(true)
        expect(response.keys.include?("__content__")).to_not eq(true)
        expect(response["value"].class).to eq(String)
        expect(response["nested_integer"]["value"].class).to eq(Float)
        expect(response["nested_zero"]["value"].class).to eq(Float)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
duty_calculator-0.0.8 spec/duty_calculator/response_spec.rb
duty_calculator-0.0.7 spec/duty_calculator/response_spec.rb
duty_calculator-0.0.6 spec/duty_calculator/response_spec.rb