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.10.1 spec/lib/attribute_parsing_spec.rb
flexirest-1.10.0 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.18 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.17 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.16 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.15 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.14 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.13 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.12 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.11 spec/lib/attribute_parsing_spec.rb
flexirest-1.9.10 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.9 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.8 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.7 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.6 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.5 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.4 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.3 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.2 spec/lib/attribute_parsing_spec.rb
flexirest-1.8.1 spec/lib/attribute_parsing_spec.rb