Module: RSpec::Strict::Let

Defined in:
lib/rspec/lint.rb

Constant Summary collapse

DEFINITIONS =
Hash.new

Instance Method Summary collapse

Instance Method Details

#let(name, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rspec/lint.rb', line 6

def let(name, &block)
  definition = caller.first.dup.freeze
  Let::DEFINITIONS[definition] = name

  super

  wrapper =
    Module.new do
      define_method(name) do
        Let::DEFINITIONS.delete(definition)

        super()
      end
    end

  prepend(wrapper)
end