Sha256: 176b884974867cc1f9b348e47ff06066a5fc50da55e210edfc0cd6d46417bfa3

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  describe Rewriter::IfExistCondition do
    let(:source) {
      """
      RSpec.configure do |config|
        config.include EmailSpec::Helpers
        config.include EmailSpec::Methods
      end
      """
    }
    let(:node) { Parser::CurrentRuby.parse(source) }
    let(:instance) { double(:current_node => node) }

    describe '#process' do
      it 'call block if match anything' do
        run = false
        condition = Rewriter::IfExistCondition.new instance, type: 'send', message: 'include', arguments: ['EmailSpec::Helpers'] do
          run = true
        end
        condition.process
        expect(run).to be_truthy
      end

      it 'not call block if not match anything' do
        run = false
        condition = Rewriter::IfExistCondition.new instance, type: 'send', message: 'include', arguments: ['FactoryGirl::SyntaxMethods'] do
          run = true
        end
        condition.process
        expect(run).to be_falsey
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
synvert-core-0.16.1 spec/synvert/core/rewriter/condition/if_exist_condition_spec.rb
synvert-core-0.16.0 spec/synvert/core/rewriter/condition/if_exist_condition_spec.rb