Top Level Namespace

Defined Under Namespace

Modules: Brine, BrineUtil, CleanerUpper, ClientBuilding, Coercion, MustacheBinder, Requesting, Selection, TypeChecking Classes: AllSelector, AnySelector, ClientBuilder, Coercer, DeleteCommand, OAuth2Params, Requester, ResponseStatusSequenceStubBuilder, Selector, StubBuilder, StubRequest, StubResponse, TypeChecks

Constant Summary collapse

RESPONSE_ATTRIBUTES =

Steps

'(status|headers|body)'
HTTP_METHOD =

Not loaded by default (except in the tests)

'GET|POST|PATCH|PUT|DELETE|HEAD|OPTIONS'
DATE =

Temporal

'\d{4}-\d{2}-\d{2}'
TIME =
'\d{2}:\d{2}:\d{2}'
MILLIS =
'(?:\.\d{3})?'
TZ =
'(?:Z|(?:[+-]\d{2}:\d{2}))'

Instance Method Summary collapse

Instance Method Details

#brine_mixObject

Load the files with side effects and return @ref Brine.

Expected to be called as ‘World(brine_mix)`



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/brine.rb', line 33

def brine_mix
  require 'brine/step_definitions/assignment'
  require 'brine/step_definitions/request_construction'
  require 'brine/step_definitions/assertions'
  require 'brine/step_definitions/cleanup'
  require 'brine/step_definitions/selection'

  require 'brine/transforms'
  require 'brine/rest_steps'
  require 'brine/hooks'
  Brine
end

#brine_root_urlString

The root url to which Brine will send requests.

This will normally be the value of ENV, and that value should be directly usable after older ENV is end-of-lifed (at which point this can be removed.

Returns:

  • (String)

    The root URL to use or nil if none is provided.



19
20
21
22
23
24
25
26
# File 'lib/brine/requester.rb', line 19

def brine_root_url
  if ENV['BRINE_ROOT_URL']
    ENV['BRINE_ROOT_URL']
  elsif ENV['ROOT_URL']
    deprecation_message('1.0', 'ROOT_URL is deprecated, replace with BRINE_ROOT_URL') if ENV['ROOT_URL']
    ENV['ROOT_URL']
  end
end

#build_stubObject



78
79
80
81
# File 'lib/brine/test_steps.rb', line 78

def build_stub
  stub.build($stubs)
  @stub = nil
end

#deprecation_message(version, message) ⇒ Object

Output a deprecation message with contents ‘msg`

Nothing will be output if BRINE_QUIET_DEPRECATIONS is set.

Parameters:

  • version (String)

    Version at which this feature will be removed.

  • message (String)

    The message to log.



43
44
45
# File 'lib/brine/util.rb', line 43

def deprecation_message(version, message)
  warn "DEPRECATION - Removal planned for #{version}: #{message}" unless ENV['BRINE_QUIET_DEPRECATIONS']
end

#dig_from_response(attribute, path = nil, plural = false) ⇒ Object



62
63
64
65
66
# File 'lib/brine/selector.rb', line 62

def dig_from_response(attribute, path=nil, plural=false)
  root = response.send(attribute.to_sym)
  return root if !path
  JsonPath.new("$.#{path}").send(plural ? :on : :first, root)
end

#kv_table(table) ⇒ Object

Return a table that that is a key value pair in a format ready for consumption



37
38
39
# File 'lib/brine/rest_steps.rb', line 37

def kv_table(table)
  transform_table!(table).rows_hash
end

#not_if(val) ⇒ Object

This file is legacy or unsorted steps which will be deprecated or moved into more appropriate homes



34
# File 'lib/brine/rest_steps.rb', line 34

def not_if(val) val ? :not_to : :to end

#oauth2Object

Request construction and response storage



6
# File 'lib/brine/requester.rb', line 6

require 'oauth2'

#replaced_with(type, new_step, version, multiline = nil) ⇒ Object



30
31
32
33
# File 'lib/brine/util.rb', line 30

def replaced_with(type, new_step, version, multiline=nil)
  deprecation_message(version, "Replace with: #{type} #{new_step}\n#{multiline}")
  step new_step, multiline
end

#response_body_child(path = "") ⇒ Object



117
118
119
# File 'lib/brine/rest_steps.rb', line 117

def response_body_child(path="")
  JsonPath.new("$.#{path}").on(response.body.to_json)
end

#stubObject



74
75
76
# File 'lib/brine/test_steps.rb', line 74

def stub
  @stub ||= StubBuilder.new
end