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.25 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.24 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.23 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.22 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.21 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.20 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.19 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.18 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.17 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.16 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.15 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.14 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.13 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.12 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.11 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.9 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.10 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.8 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.7 spec/lib/typecasters/string_typecaster_spec.rb
api_resource-0.6.6 spec/lib/typecasters/string_typecaster_spec.rb