File: httparty_steps.rb

package info (click to toggle)
ruby-httparty 0.21.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 908 kB
  • sloc: ruby: 6,782; xml: 425; sh: 35; makefile: 14
file content (65 lines) | stat: -rw-r--r-- 1,988 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
When /^I set my HTTParty timeout option to (\d+)$/ do |timeout|
  @request_options[:timeout] = timeout.to_i
end

When /^I set my HTTParty open_timeout option to (\d+)$/ do |timeout|
  @request_options[:open_timeout] = timeout.to_i
end

When /^I set my HTTParty read_timeout option to (\d+)$/ do |timeout|
  @request_options[:read_timeout] = timeout.to_i
end

When /^I set my HTTParty header '(.*)' to value '(.*)'$/ do |name, value|
  @request_options[:headers] ||= {}
  @request_options[:headers][name] = value
end

When /I set my HTTParty logger option/ do
  # TODO: make the IO something portable
  @request_options[:logger] = Logger.new("/dev/null")
end

When /I set my HTTParty parser option to a proc/ do
  @request_options[:parser] = proc { |body| body }
end

When /I call HTTParty#get with '(.*)'$/ do |url|
  begin
    @response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}", @request_options)
  rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
    @exception_from_httparty = e
  end
end

When /^I call HTTParty#head with '(.*)'$/ do |url|
  begin
    @response_from_httparty = HTTParty.head("http://#{@host_and_port}#{url}", @request_options)
  rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
    @exception_from_httparty = e
  end
end

When /I call HTTParty#get with '(.*)' and a basic_auth hash:/ do |url, auth_table|
  h = auth_table.hashes.first
  @response_from_httparty = HTTParty.get(
    "http://#{@host_and_port}#{url}",
    basic_auth: { username: h["username"], password: h["password"] }
  )
end

When /I call HTTParty#get with '(.*)' and a digest_auth hash:/ do |url, auth_table|
  h = auth_table.hashes.first
  @response_from_httparty = HTTParty.get(
    "http://#{@host_and_port}#{url}",
    digest_auth: { username: h["username"], password: h["password"] }
  )
end

When /I call Marshal\.dump on the response/ do
  begin
    Marshal.dump(@response_from_httparty)
  rescue TypeError => e
    @exception_from_httparty = e
  end
end