Sha256: f4e44503dad2709a559dcfcaf11337938be5c8b9120a3149fba5f4de50c4ceb1

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/reek/ast/node'

RSpec.describe Reek::AST::Node do
  context 'format' do
    it 'formats self' do
      expect(s(:self).format_to_ruby).to eq('self')
    end
  end

  context 'hash' do
    it 'hashes equal for equal sexps' do
      node1 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      node2 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      expect(node1.hash).to eq(node2.hash)
    end

    it 'hashes diferent for diferent sexps' do
      node1 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      node2 = s(:def, :jim, s(:args), s(:send, s(:int, 3), :+, s(:send, nil, :fred)))
      expect(node1.hash).not_to eq(node2.hash)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-3.3.0 spec/reek/ast/node_spec.rb