Sha256: 2811e2d76f044d42c39c411f30b5021484821e43ff141b622ac432d151d5d5b6

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  describe Rewriter::UnlessExistCondition do
    let(:source) { <<~EOS }
      RSpec.configure do |config|
        config.include EmailSpec::Helpers
        config.include EmailSpec::Methods
      end
    EOS
    let(:node) { Parser::CurrentRuby.parse(source) }
    let(:instance) { double(current_node: node, current_parser: :parser) }

    describe '#process' do
      it 'call block if match anything' do
        run = false
        condition =
          Rewriter::UnlessExistCondition.new instance,
                                             type: 'send',
                                             message: 'include',
                                             arguments: ['FactoryGirl::Syntax::Methods'] 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::UnlessExistCondition.new instance,
                                             type: 'send',
                                             message: 'include',
                                             arguments: ['EmailSpec::Helpers'] do
            run = true
          end
        condition.process
        expect(run).to be_falsey
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
synvert-core-2.2.2 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.2.1 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.2.0 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.1.2 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.1.1 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.1.0 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.0.3 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.0.2 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.0.1 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb
synvert-core-2.0.0 spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb