Sha256: 289c63bcacc3b12f284e0d0c1f48394d2445709cad29b7c3be055e88d1f17588

Contents?: true

Size: 529 Bytes

Versions: 10

Compression:

Stored size: 529 Bytes

Contents

require 'spec_helper'

describe Coercer::Object, '.to_hash' do
  subject { object.to_hash(value) }

  let(:object) { described_class.new }
  let(:value)  { stub('value')   }

  context 'when the value responds to #to_hash' do
    let(:coerced) { stub('coerced') }

    before do
      value.should_receive(:to_hash).with().and_return(coerced)
    end

    it { should be(coerced) }
  end

  context 'when the value does not respond to #to_hash' do
    specify { expect { subject }.to raise_error(UnsupportedCoercion) }
  end
end

Version data entries

10 entries across 8 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/coercible-1.0.0/spec/unit/coercible/coercer/object/to_hash_spec.rb
coercible-1.0.0 spec/unit/coercible/coercer/object/to_hash_spec.rb