Module: Common::Helper

Includes:
Faker
Included in:
Spinach::FeatureSteps
Defined in:
lib/generators/command/templates/helper.rb

Instance Method Summary collapse

Methods included from Faker

#random_email, #random_first_name, #random_last_name, #random_name

Instance Method Details

#appObject



21
22
23
# File 'lib/generators/command/templates/helper.rb', line 21

def app
  Rack::Builder.parse_file('config.ru').first
end

#body_idsObject



33
34
35
# File 'lib/generators/command/templates/helper.rb', line 33

def body_ids
  parsed_body.map { |obj| obj['id'] }
end

#http_statusObject



25
26
27
# File 'lib/generators/command/templates/helper.rb', line 25

def http_status
  last_response.status
end

#json_bodyObject



9
10
11
# File 'lib/generators/command/templates/helper.rb', line 9

def json_body
  last_response.body
end

#json_datetime_format(datetime) ⇒ Object



29
30
31
# File 'lib/generators/command/templates/helper.rb', line 29

def json_datetime_format(datetime)
  datetime.to_formatted_s(:iso8601) if datetime
end

#json_encode(json_hash) ⇒ Object



17
18
19
# File 'lib/generators/command/templates/helper.rb', line 17

def json_encode(json_hash)
  ActiveSupport::JSON.encode(json_hash)
end

#mail_deliveriesObject



37
38
39
# File 'lib/generators/command/templates/helper.rb', line 37

def mail_deliveries
  ActionMailer::Base.deliveries
end

#parsed_bodyObject



13
14
15
# File 'lib/generators/command/templates/helper.rb', line 13

def parsed_body
  JSON.parse(json_body, symbolize_names: true)
end