Sha256: 96dd99fd490494f8facfad162c0b3a5a203c566a8f30f598f20267faa30d9805

Contents?: true

Size: 949 Bytes

Versions: 9

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module Quby::Questionnaires::DSL
  describe CallsCustomMethods do

    class TestCustomMethod
      prepend CallsCustomMethods

      attr_reader :test
      def initialize(*args)
        @test = 'attribute'
      end
    end

    let(:custom_methods) { {custom: -> { 'custom_method' }} }
    let(:test_object) { TestCustomMethod.new(custom_methods: custom_methods) }

    describe 'prepending' do
      it 'does not skip the actual initializer' do
        expect(test_object.test).to eq('attribute')
      end
    end

    describe '#method_missing' do
      it 'allows the class to receive messages defined in custom_methods' do
        expect(test_object.custom).to eq('custom_method')
      end
    end

    describe '#respond_to_missing?' do
      it 'also considers custom methods' do
        expect(test_object.send(:respond_to_missing?, :custom)).to eq(true)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
quby-4.0.4 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-4.0.3 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-4.0.2 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-4.0.1 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-4.0.0 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-3.2.2 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-3.2.1 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-3.2.0 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb
quby-3.2.0.pre.pre1 spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb