Sha256: f52dd23915119abbcd5d20f49b52673f83422195dac91a46938d34adf68e9a3b

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

require_relative '../spec_helper'
Reek::CLI::Silencer.without_warnings { require 'parser/ruby25' }
require_lib 'reek/tree_dresser'

RSpec.describe Reek::TreeDresser do
  describe '#dress' do
    let(:dresser) { described_class.new }
    let(:sexp) do
      Parser::Ruby25.parse('class Klazz; def meth(argument); argument.call_me; end; end')
    end
    let(:dressed_ast) { dresser.dress(sexp, {}) }

    # The dressed AST looks like this:
    #   (class
    #     (const nil :Klazz) nil
    #     (def :meth
    #       (args
    #         (arg :argument))
    #       (send
    #         (lvar :argument) :call_me)))
    let(:const_node) { dressed_ast.children.first }
    let(:def_node) { dressed_ast.children.last }
    let(:args_node) { def_node.children[1] }
    let(:send_node) { def_node.children[2] }

    it 'dresses `const` nodes properly' do
      expect(const_node).to be_a Reek::AST::SexpExtensions::ConstNode
    end

    it 'dresses `def` nodes properly' do
      expect(def_node).
        to be_a(Reek::AST::SexpExtensions::DefNode).
        and be_a(Reek::AST::SexpExtensions::MethodNodeBase)
    end

    it 'dresses `args` nodes properly' do
      expect(args_node).
        to be_a(Reek::AST::SexpExtensions::ArgsNode).
        and be_a(Reek::AST::SexpExtensions::NestedAssignables)
    end

    it 'dresses `send` nodes properly' do
      expect(send_node).to be_a Reek::AST::SexpExtensions::SendNode
    end
  end
end

Version data entries

20 entries across 18 versions & 2 rubygems

Version Path
reek-6.0.3 spec/reek/tree_dresser_spec.rb
reek-6.0.2 spec/reek/tree_dresser_spec.rb
reek-6.0.1 spec/reek/tree_dresser_spec.rb
reek-6.0.0 spec/reek/tree_dresser_spec.rb
reek-5.6.0 spec/reek/tree_dresser_spec.rb
reek-5.5.0 spec/reek/tree_dresser_spec.rb
reek-5.4.1 spec/reek/tree_dresser_spec.rb
reek-5.4.0 spec/reek/tree_dresser_spec.rb
reek-5.3.2 spec/reek/tree_dresser_spec.rb
reek-5.3.1 spec/reek/tree_dresser_spec.rb
reek-5.3.0 spec/reek/tree_dresser_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/tree_dresser_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/tree_dresser_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/tree_dresser_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/spec/reek/tree_dresser_spec.rb
reek-5.2.0 spec/reek/tree_dresser_spec.rb
reek-5.1.0 spec/reek/tree_dresser_spec.rb
reek-5.0.2 spec/reek/tree_dresser_spec.rb
reek-5.0.1 spec/reek/tree_dresser_spec.rb
reek-5.0.0 spec/reek/tree_dresser_spec.rb