Sha256: a002f32c7652d14471c44c28a1c20a62343a9bf0ed4ff1de3b1469e2868fb61d

Contents?: true

Size: 1.16 KB

Versions: 54

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

class AttributeParsingExampleBase
  include Flexirest::AttributeParsing

  def test(v)
    parse_attribute_value(v)
  end
end


describe Flexirest::AttributeParsing do
  let(:subject) { AttributeParsingExampleBase.new }

  it "should parse datetimes" do
    expect(subject.test("1980-12-24T00:00:00.000Z")).to be_a(DateTime)
  end

  it "should not parse a multiline string as a datetime" do
    expect(subject.test("not a datetime\n1980-12-24T00:00:00.000Z")).to be_a(String)
  end

  it "should parse dates" do
    expect(subject.test("1980-12-24")).to be_a(Date)
  end

  it "should not parse a multiline string as a datetime" do
    expect(subject.test("not a date\n1980-12-24")).to be_a(String)
  end

  it "should return strings for string values" do
    expect(subject.test("1980-12")).to eq("1980-12")
  end

  it "should return integers for integer values" do
    expect(subject.test(1980)).to eq(1980)
  end

  it "should return floats for float values" do
    expect(subject.test(1980.12)).to eq(1980.12)
  end

  it "should return as a string a date-like string that can't be parsed" do
    expect(subject.test("7/29/2018")).to eq("7/29/2018")
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
flexirest-1.8.0 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.9 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.8 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.7 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.6 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.5 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.4 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.3 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.2 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.1 spec/lib/attribute_parsing_spec.rb
flexirest-1.7.0 spec/lib/attribute_parsing_spec.rb
flexirest-1.6.9 spec/lib/attribute_parsing_spec.rb
flexirest-1.6.8 spec/lib/attribute_parsing_spec.rb
flexirest-1.6.7 spec/lib/attribute_parsing_spec.rb