File: api_test_helpers.rb

package info (click to toggle)
ruby-acts-as-api 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 624 kB
  • sloc: ruby: 2,366; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module ApiTestHelpers
  def response_body
    response.body.strip
  end

  def response_body_json
    ActiveSupport::JSON.decode(response_body)
  end

  def response_body_jsonp(callback)
    jsonp_callback(callback).match(response_body)
  end

  def jsonp_callback(callback)
    /\A#{callback}\((.*),\s+\d{3}\)\z/
  end
end

RSpec.configure do |c|
  c.include ApiTestHelpers
end