Sha256: 824b402cf046adbceddf03028c905b3d8db812b475b88c5a798f9ae05baf506e

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.8.16 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.15 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.14 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.13 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb
mutant-0.8.12 spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb