Sha256: 4e2f46836d6d18850b19791a921a9221f5b9a7efec5ef1512e52a75882412301

Contents?: true

Size: 940 Bytes

Versions: 4

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Mutant::AST::Meta::Send, '#proc?' do
  subject { described_class.new(node).proc? }

  shared_context 'proc send' do |source|
    let(:node) { Parser::CurrentRuby.parse(source).children.first }
  end

  shared_examples 'proc definition' do |*args|
    include_context 'proc send', *args

    it { should be(true) }
  end

  shared_examples 'not a proc definition' do |*args|
    include_context 'proc send', *args

    it { should be_falsey }
  end

  it_behaves_like 'proc definition', 'proc { }'
  it_behaves_like 'proc definition', 'Proc.new { }'
  it_behaves_like 'not a proc definition', 'new { }'
  it_behaves_like 'not a proc definition', 'foo.proc { }'
  it_behaves_like 'not a proc definition', 'Proc.blah { }'
  it_behaves_like 'not a proc definition', 'Proc().new { }'
  it_behaves_like 'not a proc definition', 'Foo.new { }'
  it_behaves_like 'not a proc definition', 'blah { }'
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.8.20 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.19 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.18 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.17 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb