File: let_all.rb

package info (click to toggle)
ruby-maxitest 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 504 kB
  • sloc: ruby: 1,583; makefile: 7
file content (19 lines) | stat: -rw-r--r-- 341 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Maxitest
  module LetAll
    def let_all(name, &block)
      cache = []
      define_method(name) do
        if cache.empty?
          cache << instance_eval(&block)
        end
        cache.first
      end
    end

    def self.included(base)
      base.extend(self)
    end
  end
end

Minitest::Spec::DSL.include(Maxitest::LetAll)