Sha256: e32480a86fe66b99a3c7be22848e967b21ac08ab0b6cfd6a881469f9f8809e5f

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
require 'data-com-api/query_parameters'

describe DataComApi::QueryParameters do

  subject(:query_parameters) { FactoryGirl.build(:query_parameters) }

  it "has a valid factory" do
    expect{query_parameters}.not_to raise_error
  end

  describe "#updated_since" do

    it "returns time object" do
      current_time = Time.now.utc.in_time_zone(DataComApi::Client::TIME_ZONE)
      query_parameters.updated_since = current_time.to_s

      expect(query_parameters.updatedSince).to be_an_instance_of ActiveSupport::TimeWithZone
    end

    it "returns same time as the one assigned" do
      current_time = Time.now.utc.in_time_zone(DataComApi::Client::TIME_ZONE)
      query_parameters.updated_since = current_time.to_s

      # XXX: Be careful, comparison between the two ActiveSupport::TimeWithZone
      #      fails for unknown reasons to me, even if to_i and to_s are equal.
      #      Comparison through strings seems ok by the way because the class
      #      will just output data directly to the API, so string based
      expect(query_parameters.updatedSince.to_s).to eq(current_time.to_s)
    end

  end

  it "has only string values when converted to_hash" do
    query_parameters.pageSize = 5

    expect(
      query_parameters.to_hash['pageSize']
    ).to eq query_parameters.pageSize.to_s
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
data-com-api-0.2.1 spec/models/query_parameters_spec.rb
data-com-api-0.2.0 spec/models/query_parameters_spec.rb
data-com-api-0.1.5 spec/models/query_parameters_spec.rb
data-com-api-0.1.4 spec/models/query_parameters_spec.rb
data-com-api-0.1.3 spec/models/query_parameters_spec.rb
data-com-api-0.1.2 spec/models/query_parameters_spec.rb
data-com-api-0.1.1 spec/models/query_parameters_spec.rb
data-com-api-0.1.0 spec/models/query_parameters_spec.rb