Sha256: a356d22ae8d3aef8be542bf797a9d16ed369343bccb74b174d7de79bffabbb7b

Contents?: true

Size: 993 Bytes

Versions: 10

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

RSpec.shared_examples 'no block evaluation' do
  context 'with block' do
    let(:block) { -> { fail } }

    it 'does not evaluate block' do
      apply
    end
  end
end

RSpec.shared_examples 'requires block' do
  context 'without block' do
    let(:block) { nil }

    specify do
      expect { apply }.to raise_error(LocalJumpError)
    end
  end
end

RSpec.shared_examples 'returns self' do
  it 'returns self' do
    expect(apply).to be(subject)
  end
end

RSpec.shared_examples '#apply block evaluation' do
  it 'evaluates block and returns its wrapped result' do
    expect { expect(apply).to eql(block_result) }
      .to change(yields, :to_a)
      .from([])
      .to([value])
  end
end

RSpec.shared_examples 'Functor#fmap block evaluation' do
  it 'evaluates block and returns its wrapped result' do
    expect { expect(apply).to eql(described_class.new(block_result)) }
      .to change(yields, :to_a)
      .from([])
      .to([value])
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mutant-0.9.9 spec/shared/base_behavior.rb
mutant-0.9.8 spec/shared/base_behavior.rb
mutant-0.9.7 spec/shared/base_behavior.rb
mutant-0.9.6 spec/shared/base_behavior.rb
mutant-0.9.5 spec/shared/base_behavior.rb
mutant-0.9.4 spec/shared/base_behavior.rb
mutant-0.9.3 spec/shared/base_behavior.rb
mutant-0.9.2 spec/shared/base_behavior.rb
mutant-0.9.1 spec/shared/base_behavior.rb
mutant-0.9.0 spec/shared/base_behavior.rb