Sha256: fcd68e7958850d261dc8db273c7a08a447586132c9e796de012ae6b8abb5ba6c

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

When /^I (GET|PUT|POST|PATCH|DELETE)( to)? "(.*?)"$/ do |verb, unused, url_path|
  verb = verb.downcase.to_sym
  send(verb, render_string(url_path))
end

When /^I (GET|PUT|POST|PATCH|DELETE)( to)? "([^"]*)" with:$/ do |verb, unused, url, params|
  options = {}

  params.hashes.each do |row|
    options[row[:Name]] = render_string(row[:Value])
  end

  verb = verb.downcase.to_sym
  send(verb, render_string(url), options)
end

When /^I (GET|PUT|POST|PATCH|DELETE) to "(.*?)" with the JSON:$/ do |verb, url, body|
  verb = verb.downcase.to_sym
  send(verb, render_string(url), render_string(body))
end

Then /^the response (should be|is) (\d+)$/ do |verb, code|
  expect(last_response.status).to eq(code), "expected #{code} got #{last_response.status} \n\n #{last_response.body}
"
end

Then /^I should be redirected to "([^"]+)"$/ do |path|
  expect(last_response.location).to end_with path
end

Then /^I should receive the JSON:$/ do |json|
  template_vars['timestamp'] = Time.now.utc.iso8601
  expected = JSON.parse(render_string(json))

  begin
    received = JSON.parse(last_response.body)
  rescue JSON::ParserError => e
    raise "Unexpected response: #{last_response.body}\n#{e}"
  end

  expect(received).to eql(expected)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lookout-rack-test-2.2.0 lib/lookout/rack/test/cucumber/general_steps.rb
lookout-rack-test-2.1.0 lib/lookout/rack/test/cucumber/general_steps.rb
lookout-rack-test-2.0.2 lib/lookout/rack/test/cucumber/general_steps.rb
lookout-rack-test-2.0.1 lib/lookout/rack/test/cucumber/general_steps.rb
lookout-rack-test-2.0.0 lib/lookout/rack/test/cucumber/general_steps.rb
lookout-rack-test-1.3.0 lib/lookout/rack/test/cucumber/general_steps.rb