Sha256: c2c87d20e658da2507f6ab25f31ae28a9661ecb99d6b8809e70505a4e32f7835
Contents?: true
Size: 1.89 KB
Versions: 4
Compression:
Stored size: 1.89 KB
Contents
Synvert::Rewriter.new "convert_rspec_message_expectation" do description <<-EOF It convert rspec message expectation. obj.should_receive(:message) => expect(obj).to receive(:message) Klass.any_instance.should_receive(:message) => expect_any_instance_of(Klass).to receive(:message) expect(obj).to receive(:message).and_return { 1 } => expect(obj).to receive(:message) { 1 } expect(obj).to receive(:message).and_return { 1 } => expect(obj).to receive(:message) { 1 } expect(obj).to receive(:message).and_return => expect(obj).to receive(:message) EOF if_gem 'rspec', {gte: '2.14.0'} within_files 'spec/**/*.rb' do # obj.should_receive(:message) => expect(obj).to receive(:message) # Klass.any_instance.should_receive(:message) => expect_any_instance_of(Klass).to receive(:message) with_node type: 'send', message: 'should_receive' do if_exist_node type: 'send', message: 'any_instance' do replace_with "expect_any_instance_of({{receiver.receiver}}).to receive({{arguments}})" end unless_exist_node type: 'send', message: 'any_instance' do replace_with "expect({{receiver}}).to receive({{arguments}})" end end end within_files 'spec/**/*.rb' do # expect(obj).to receive(:message).and_return { 1 } => expect(obj).to receive(:message) { 1 } with_node type: 'send', receiver: {type: 'send', message: 'expect'}, arguments: {first: {type: 'block', caller: {type: 'send', message: 'and_return', arguments: []}}} do replace_with "{{receiver}}.to {{arguments.first.caller.receiver}} { {{arguments.first.body}} }" end # expect(obj).to receive(:message).and_return => expect(obj).to receive(:message) with_node type: 'send', receiver: {type: 'send', message: 'expect'}, arguments: {first: {type: 'send', message: 'and_return', arguments: []}} do replace_with "{{receiver}}.to {{arguments.first.receiver}}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems