Sha256: d01cb64cd29926b2afe21e55970106a4e4125017d66737da962524ace57a7de6

Contents?: true

Size: 746 Bytes

Versions: 26

Compression:

Stored size: 746 Bytes

Contents

require 'spec_helper'

describe ApiResource::Typecast::StringTypecaster do

  let(:klass) { ApiResource::Typecast::StringTypecaster }

  context ".from_api" do 

    it "should work on any conceivable value" do
      klass.from_api(BasicObject).should eql("BasicObject")
      klass.from_api(true).should eql("true")
      klass.from_api(false).should eql("false")
      klass.from_api(nil).should eql("")
      klass.from_api("").should eql("")
      klass.from_api("abc").should eql("abc")
      klass.from_api(1).should eql("1")
      klass.from_api(1.0).should eql("1.0")
    end
  end

  context ".to_api" do
    it "should return itself" do
      val = "hello"
      klass.to_api(val).object_id.should eql(val.object_id)
    end
  end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
api_resource-0.6.5 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.4 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.3 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.2 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.1 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.0 spec/lib/typecasters/string_typecaster_spec.rb