Sha256: 0afda0758a56c33b31bfc5cb4204ef7b9e97845e5ef96693023a600475056a2b

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/reek/source/sexp_node'

describe Reek::Source::SexpNode do
  context 'format' do
    it 'formats self' do
      @node = s(:self)
      expect(@node.format_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-2.1.0 spec/reek/source/sexp_node_spec.rb