Module: Pact::Helpers

Included in:
Pact
Defined in:
lib/pact/helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
# File 'lib/pact/helpers.rb', line 10

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

Instance Method Details

#each_like(content, options = {}) ⇒ Object



28
29
30
# File 'lib/pact/helpers.rb', line 28

def each_like content, options = {}
  Pact::ArrayLike.new(content, options)
end

#like(content) ⇒ Object



24
25
26
# File 'lib/pact/helpers.rb', line 24

def like content
  Pact::SomethingLike.new(content)
end

#term(arg1, arg2 = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/pact/helpers.rb', line 14

def term arg1, arg2 = nil
  case arg1
  when Hash then Pact::Term.new(arg1)
  when Regexp then Pact::Term.new(matcher: arg1, generate: arg2)
  when String then Pact::Term.new(matcher: arg2, generate: arg1)
  else
    raise ArgumentError, "Cannot create a Pact::Term from arguments #{arg1.inspect} and #{arg2.inspect}. Please provide a Regexp and a String."
  end
end