Sha256: 31ba1b6767366e83dc04bd6255400293742ee5f667e0acffa3a33d327150f9c1

Contents?: true

Size: 843 Bytes

Versions: 13

Compression:

Stored size: 843 Bytes

Contents

require 'spec_helper'

shared_examples_for 'no method error' do
  specify do
    expect { subject }.to raise_error(NoMethodError)
  end
end

describe Virtus::Coercion::Object, '.method_missing' do
  subject { described_class.send(method_name, value) }

  let(:value) { '1' }

  context 'with a non-typecast method' do
    let(:method_name) { 'not_here' }

    it_should_behave_like 'no method error'
  end

  Virtus::Attribute::Object.descendants.each do |attribute|
    let(:method_name) { attribute.coercion_method }

    context "with #{attribute.coercion_method.inspect} and an input value" do
      it { should equal(value) }
    end

    context "with #{attribute.coercion_method.inspect} and without an input value" do
      subject { described_class.send(method_name) }

      it_should_behave_like 'no method error'
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
virtus-0.5.5 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.5.4 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.5.3 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.5.2 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.5.1 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.5.0 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.4.2 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.4.1 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.4.0 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.3.0 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.2.0 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.1.0 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb