Sha256: a80e1aac82258df49fd410170b6a22b5971ce70535fe72f410ce2530d8cab722

Contents?: true

Size: 841 Bytes

Versions: 5

Compression:

Stored size: 841 Bytes

Contents

require 'spec_helper'

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

  let(:value) { '1' }

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

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

    it_behaves_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_behaves_like 'no method error'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
virtus-0.0.10 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.0.9 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.0.8 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.0.7 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb
virtus-0.0.6 spec/unit/virtus/coercion/object/class_methods/method_missing_spec.rb