Sha256: 228556c11fd4329388fdd1f13eea972fe41cbf20d88d80e529fb35064294dc53

Contents?: true

Size: 976 Bytes

Versions: 8

Compression:

Stored size: 976 Bytes

Contents

require 'spec_helper'

describe ActiveZuora::DateField do
  subject { described_class.new("date", described_class, {:zuora_name => "date"}) }

  describe "#type_cast" do
    it "returns nil if provided nil" do
      expect(subject.type_cast(nil)).to eq(nil)
    end

    it "returns a date when given a datetime object" do
      datetime = DateTime.now
      expect(subject.type_cast(datetime)).to be_a(Date)
    end

    it "returns a date when given a date object" do
      date = Date.today
      expect(subject.type_cast(date)).to be_a(Date)
    end
  end

  describe "#build_xml" do
    let(:xml)  { double(:xml, :tag! => nil) }
    let(:soap) { double(:soap, :namespace_by_uri => nil) }
    let(:options) { {} }

    it "handles a nil value" do
      expect { subject.build_xml(xml, soap, nil, options) }.to_not raise_error
    end

    it "handles a date value" do
      expect { subject.build_xml(xml, soap, Date.today, options) }.to_not raise_error
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
active_zuora-2.6.0 spec/fields/date_field_spec.rb
active_zuora-2.5.4 spec/fields/date_field_spec.rb
active_zuora-2.5.3 spec/fields/date_field_spec.rb
active_zuora-2.5.2 spec/fields/date_field_spec.rb
active_zuora-2.5.1 spec/fields/date_field_spec.rb
active_zuora-2.5.0 spec/fields/date_field_spec.rb
active_zuora-2.4.1 spec/fields/date_field_spec.rb
active_zuora-2.4.0 spec/fields/date_field_spec.rb