Method: MiniSpec::ClassAPI#before
- Defined in:
- lib/minispec/api/class/before.rb
#before(*matchers, &proc) ⇒ Object
run some code before any or matching tests. if called without arguments the hook will run before any test. if any arguments passed it will run only before matched tests. strings, symbols and regexps accepted as arguments. also :except option accepted.
describe Specs do
before /shoes/, except: /red/ do
# ...
end
end
61 62 63 64 65 66 67 |
# File 'lib/minispec/api/class/before.rb', line 61 def before *matchers, &proc proc || raise(ArgumentError, 'block is missing') matchers.flatten! matchers = [:*] if matchers.empty? return if before?.find {|x| x[0] == matchers && x[1].source_location == proc.source_location} before?.push([matchers, proc]) end |