Sha256: b373a9ab159c7db0396f988e063f85a4c6d8ae40e01aa48548e6da27d9dc48bf

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

require 'method_log/method_definition'
require 'method_log/source_file'

module MethodLog
  describe MethodDefinition do
    let(:source_file) do
      source(path: 'path/to/source.rb', source: %{
        class Foo
          def bar
            # implementation
          end
        end
      })
    end

    it 'is equal to another method definition with same source file and line numbers' do
      definition_one = MethodDefinition.new(source_file, 1..3)
      definition_two = MethodDefinition.new(source_file, 1..3)

      expect(definition_one).to eq(definition_two)
    end

    it 'has same hash as another method definition with same path and line numbers' do
      definition_one = MethodDefinition.new(source_file, 1..3)
      definition_two = MethodDefinition.new(source_file, 1..3)

      expect(definition_one.hash).to eq(definition_two.hash)
    end

    it 'provides access to the method source' do
      definition = MethodDefinition.new(source_file, 1..3)

      expect(definition.source).to eq(source_file.snippet(1..3))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
method_log-0.2.1 spec/method_definition_spec.rb
method_log-0.2.0 spec/method_definition_spec.rb
method_log-0.1.1 spec/method_definition_spec.rb
method_log-0.1.0 spec/method_definition_spec.rb
method_log-0.0.7 spec/method_definition_spec.rb
method_log-0.0.6 spec/method_definition_spec.rb