spec/synvert/node_ext_spec.rb in synvert-0.0.8 vs spec/synvert/node_ext_spec.rb in synvert-0.0.9

- old
+ new

@@ -106,11 +106,11 @@ expect(children).to be_include :args expect(children).to be_include :ivar end end - describe '#match' do + describe '#match?' do let(:instance) { Synvert::Rewriter::Instance.new('file pattern') } it 'matches class name' do source = 'class Synvert; end' instance.current_source = source @@ -121,9 +121,23 @@ it 'matches message with regexp' do source = 'User.find_by_login(login)' instance.current_source = source node = parse(source) expect(node).to be_match(instance, type: 'send', message: /^find_by_/) + end + + it 'matches arguments with symbol' do + source = 'params[:user]' + instance.current_source = source + node = parse(source) + expect(node).to be_match(instance, type: 'send', receiver: 'params', message: '[]', arguments: [:user]) + end + + it 'matches arguments with string' do + source = 'params["user"]' + instance.current_source = source + node = parse(source) + expect(node).to be_match(instance, type: 'send', receiver: 'params', message: '[]', arguments: ['user']) end it 'matches arguments any' do source = 'config.middleware.insert_after ActiveRecord::QueryCache, Lifo::Cache, page_cache: false' instance.current_source = source