Sha256: afe3a86603ca35c5e25be442cb31a8c92466a41178ee79a97a3028f2254b0cb4

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::MethodDefinitions do
  subject(:definitions) { described_class.new }

  describe '#add' do
    let(:name) { :the_method }

    context 'when passing block' do
      it 'returns the resulting array' do
        expect(definitions.add(name) { RandomGenerator.rand })
          .to be_a(Array)
      end

      it 'returns an array of MethodDefinition' do
        expect(definitions.add(name) { RandomGenerator.rand }.first)
          .to be_a(Sinclair::MethodDefinition)
      end

      it 'creates a new BlockDefinition' do
        expect(definitions.add(name) { RandomGenerator.rand }.first)
          .to be_a(Sinclair::MethodDefinition::BlockDefinition)
      end
    end

    context 'when passing block' do
      it 'returns the resulting array' do
        expect(definitions.add(name, 'RandomGenerator.rand'))
          .to be_a(Array)
      end

      it 'returns an array of MethodDefinition' do
        expect(definitions.add(name, 'RandomGenerator.rand').last)
          .to be_a(Sinclair::MethodDefinition)
      end

      it 'creates a new StringDefinition' do
        expect(definitions.add(name, 'RandomGenerator.rand').last)
          .to be_a(Sinclair::MethodDefinition::StringDefinition)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sinclair-1.5.2 spec/lib/sinclair/method_definitions_spec.rb
sinclair-1.5.1 spec/lib/sinclair/method_definitions_spec.rb
sinclair-1.5.0 spec/lib/sinclair/method_definitions_spec.rb