Sha256: 2c6e63da40615aa3f8da6acf734f0e5e7f974dfb1c165b1936d5a04994e37e45

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

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

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

  it 'is equal to another method definition with same source file and line numbers' do
    definition_one = MethodLog::MethodDefinition.new(source_file: source_file, lines: 1..3)
    definition_two = MethodLog::MethodDefinition.new(source_file: source_file, lines: 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 = MethodLog::MethodDefinition.new(source_file: source_file, lines: 1..3)
    definition_two = MethodLog::MethodDefinition.new(source_file: source_file, lines: 1..3)

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

  it 'describes method definition' do
    definition = MethodLog::MethodDefinition.new(source_file: source_file, lines: 1..3)

    expect(definition.to_s).to eq(%{
  path/to/source.rb:1..3
  def bar
    # implementation
  end
    }.strip)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
method_log-0.0.2 spec/method_definition_spec.rb
method_log-0.0.1 spec/method_definition_spec.rb