Sha256: 46a119e8f4358640523f02c6c694ea2fd342f3f9b7b61f7e7457d55bd7ec0ed6

Contents?: true

Size: 983 Bytes

Versions: 4

Compression:

Stored size: 983 Bytes

Contents

Synvert::Rewriter.new "convert_rspec_block_to_expect" do
  description <<-EOF
It converts rspec block to expect.

    lambda { do_something }.should raise_error => expect { do_something }.to raise_error
    proc { do_something }.should raise_error => expect { do_something }.to raise_error
    -> { do_something }.should raise_error => expect { do_something }.to raise_error
  EOF

  if_gem 'rspec', {gte: '2.11.0'}

  within_files 'spec/**/*.rb' do
    # lambda { do_something }.should raise_error => expect { do_something }.to raise_error
    # proc { do_something }.should raise_error => expect { do_something }.to raise_error
    # -> { do_something }.should raise_error => expect { do_something }.to raise_error
    {should: 'to', should_not: 'not_to'}.each do |old_message, new_message|
      with_node type: 'send', receiver: {type: 'block'}, message: old_message do
        replace_with "expect { {{receiver.body}} }.#{new_message} {{arguments}}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
synvert-0.0.17 lib/synvert/snippets/rspec/block_to_expect.rb
synvert-0.0.16 lib/synvert/snippets/rspec/block_to_expect.rb
synvert-0.0.15 lib/synvert/snippets/rspec/block_to_expect.rb
synvert-0.0.14 lib/synvert/snippets/rspec/block_to_expect.rb