mockserver-client 1.0.8.pre → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +2 -1
  3. data/README.md +79 -227
  4. data/lib/mockserver/client.rb +518 -0
  5. data/lib/mockserver/errors.rb +18 -0
  6. data/lib/mockserver/forward_chain_expectation.rb +117 -0
  7. data/lib/mockserver/models.rb +1507 -0
  8. data/lib/mockserver/version.rb +3 -3
  9. data/lib/mockserver/websocket_client.rb +353 -0
  10. data/lib/mockserver-client.rb +7 -16
  11. data/mockserver-client.gemspec +26 -27
  12. metadata +54 -206
  13. data/.gitignore +0 -21
  14. data/.rubocop.yml +0 -7
  15. data/Rakefile +0 -10
  16. data/bin/mockserver +0 -9
  17. data/lib/cli.rb +0 -146
  18. data/lib/mockserver/abstract_client.rb +0 -111
  19. data/lib/mockserver/mock_server_client.rb +0 -46
  20. data/lib/mockserver/model/array_of.rb +0 -85
  21. data/lib/mockserver/model/body.rb +0 -56
  22. data/lib/mockserver/model/cookie.rb +0 -36
  23. data/lib/mockserver/model/delay.rb +0 -34
  24. data/lib/mockserver/model/enum.rb +0 -47
  25. data/lib/mockserver/model/expectation.rb +0 -139
  26. data/lib/mockserver/model/forward.rb +0 -41
  27. data/lib/mockserver/model/header.rb +0 -43
  28. data/lib/mockserver/model/parameter.rb +0 -43
  29. data/lib/mockserver/model/request.rb +0 -81
  30. data/lib/mockserver/model/response.rb +0 -45
  31. data/lib/mockserver/model/times.rb +0 -61
  32. data/lib/mockserver/proxy_client.rb +0 -9
  33. data/lib/mockserver/utility_methods.rb +0 -59
  34. data/pom.xml +0 -118
  35. data/spec/fixtures/forward_mockserver.json +0 -7
  36. data/spec/fixtures/incorrect_login_response.json +0 -20
  37. data/spec/fixtures/post_login_request.json +0 -22
  38. data/spec/fixtures/register_expectation.json +0 -50
  39. data/spec/fixtures/retrieved_request.json +0 -22
  40. data/spec/fixtures/search_request.json +0 -6
  41. data/spec/fixtures/times_once.json +0 -6
  42. data/spec/integration/mock_client_integration_spec.rb +0 -82
  43. data/spec/mockserver/builder_spec.rb +0 -90
  44. data/spec/mockserver/mock_client_spec.rb +0 -80
  45. data/spec/mockserver/proxy_client_spec.rb +0 -38
  46. data/spec/spec_helper.rb +0 -61
@@ -1,61 +0,0 @@
1
- # encoding: UTF-8
2
- require 'hashie'
3
- require_relative './enum'
4
-
5
- #
6
- # A class to model the number of times an expectation should be respected.
7
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
8
- #
9
- module MockServer::Model
10
- # Enum for boolean values since Ruby does not have this by default
11
- class Boolean < Enum
12
- def allowed_values
13
- [true, false]
14
- end
15
-
16
- def !
17
- !@value
18
- end
19
-
20
- def initialize(supplied_value)
21
- @value = pre_process_value(supplied_value)
22
- end
23
- end
24
-
25
- # Model for times class
26
- class Times < Hashie::Dash
27
- include Hashie::Extensions::MethodAccess
28
- include Hashie::Extensions::IgnoreUndeclared
29
- include Hashie::Extensions::Coercion
30
-
31
- property :remaining_times, default: 0
32
- property :unlimited, default: false
33
-
34
- coerce_key :unlimited, Boolean
35
- end
36
-
37
- # DSL methods related to times
38
- module DSL
39
- def unlimited
40
- Times.new(unlimited: true)
41
- end
42
-
43
- def once
44
- Times.new(remaining_times: 1)
45
- end
46
-
47
- def exactly(num)
48
- Times.new(remaining_times: num)
49
- end
50
-
51
- def at_least(num)
52
- Times.new(remaining_times: num, unlimited: true)
53
- end
54
-
55
- def times(&_)
56
- obj = once
57
- yield obj if block_given?
58
- obj
59
- end
60
- end
61
- end
@@ -1,9 +0,0 @@
1
- # encoding: UTF-8
2
- require_relative './abstract_client'
3
-
4
- #
5
- # The client used to interact with the proxy server.
6
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
7
- #
8
- class MockServer::ProxyClient < MockServer::AbstractClient
9
- end
@@ -1,59 +0,0 @@
1
- # encoding: UTF-8
2
- require 'active_support/inflector'
3
- require 'json'
4
-
5
- #
6
- # A module that has common utility methods used by this project
7
- # @author:: Nayyara Samuel (mailto: nayyara.samuel@opower.com)
8
- #
9
- module MockServer::UtilityMethods
10
- # Does the following filter/transform operations on a hash
11
- # - exclude null or empty valued keys from the hash
12
- # - camelize the keys of the hash
13
- # @param obj [Object] an object which will be used to create the hash. Must support :to_hash method
14
- # @return [Hash] the transformed hash
15
- # rubocop:disable Style/MethodLength
16
- # rubocop:disable Style/CyclomaticComplexity
17
- def camelized_hash(obj)
18
- obj = obj && obj.respond_to?(:to_hash) ? obj.to_hash : obj
19
-
20
- if obj.is_a?(Hash)
21
- obj.each_with_object({}) do |(k, v), acc|
22
- is_empty = v.nil? || (v.respond_to?(:empty?) ? v.empty? : false)
23
- acc[camelize(k)] = camelized_hash(v) unless is_empty
24
- end
25
- elsif obj.respond_to?(:map)
26
- obj.map { |element| camelized_hash(element) }
27
- else
28
- obj
29
- end
30
- end
31
-
32
- # Converts keys to symbols
33
- # @param hash [Hash] a hash
34
- # @return [Hash] a copy of the hash where keys are symbols
35
- def symbolize_keys(hash)
36
- if hash.is_a?(Hash)
37
- Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]
38
- elsif hash.respond_to?(:map)
39
- hash.map { |obj| symbolize_keys(obj) }
40
- else
41
- hash
42
- end
43
- end
44
-
45
- # @param str [Object] an object to camelize the string representation of
46
- # @return [String] the string converted to camelcase with first letter in lower case
47
- def camelize(str)
48
- str.to_s.camelize(:lower)
49
- end
50
-
51
- # Parse string response into JSON
52
- # @param response [Response] from RestClient response
53
- # @return [Hash] the parsed response or the object unmodified if parsing is not possible
54
- def parse_string_to_json(response)
55
- JSON.parse(response)
56
- rescue JSON::ParserError
57
- response
58
- end
59
- end
data/pom.xml DELETED
@@ -1,118 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
- <parent>
4
- <groupId>org.mock-server</groupId>
5
- <artifactId>mockserver</artifactId>
6
- <version>3.10.2-SNAPSHOT</version>
7
- </parent>
8
- <modelVersion>4.0.0</modelVersion>
9
-
10
- <artifactId>mockserver-client-ruby</artifactId>
11
- <name>MockServer Ruby Client</name>
12
- <description>A ruby client for the MockServer</description>
13
- <url>http://www.mock-server.com</url>
14
-
15
- <properties>
16
- <skipRubyRelease>true</skipRubyRelease>
17
- <skipRubyBuild>false</skipRubyBuild>
18
- </properties>
19
-
20
- <build>
21
- <plugins>
22
- <!-- run mock server for ruby client tests -->
23
- <plugin>
24
- <groupId>${project.groupId}</groupId>
25
- <artifactId>mockserver-maven-plugin</artifactId>
26
- <version>${project.version}</version>
27
- <configuration>
28
- <logLevel>WARN</logLevel>
29
- <serverPort>1080</serverPort>
30
- <proxyPort>1090</proxyPort>
31
- </configuration>
32
- <executions>
33
- <execution>
34
- <id>pre-test</id>
35
- <phase>generate-test-sources</phase>
36
- <goals>
37
- <goal>start</goal>
38
- </goals>
39
- </execution>
40
- <execution>
41
- <id>post-test</id>
42
- <phase>verify</phase>
43
- <goals>
44
- <goal>stop</goal>
45
- </goals>
46
- </execution>
47
- </executions>
48
- </plugin>
49
- <!-- run ruby bundle build and install -->
50
- <plugin>
51
- <groupId>org.codehaus.mojo</groupId>
52
- <artifactId>exec-maven-plugin</artifactId>
53
- <version>1.4.0</version>
54
- <executions>
55
- <execution>
56
- <id>bundle_install</id>
57
- <phase>prepare-package</phase>
58
- <goals>
59
- <goal>exec</goal>
60
- </goals>
61
- <configuration>
62
- <skip>${skipRubyBuild}</skip>
63
- <executable>bundle</executable>
64
- <arguments>
65
- <argument>install</argument>
66
- <argument>--path</argument>
67
- <argument>vendor/bundle</argument>
68
- </arguments>
69
- <environmentVariables>
70
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
71
- </environmentVariables>
72
- </configuration>
73
- </execution>
74
- <execution>
75
- <id>ruby_make</id>
76
- <phase>prepare-package</phase>
77
- <goals>
78
- <goal>exec</goal>
79
- </goals>
80
- <configuration>
81
- <skip>${skipRubyBuild}</skip>
82
- <executable>bundle</executable>
83
- <arguments>
84
- <argument>exec</argument>
85
- <argument>rake</argument>
86
- <argument>build</argument>
87
- <argument>spec</argument>
88
- </arguments>
89
- <environmentVariables>
90
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
91
- </environmentVariables>
92
- </configuration>
93
- </execution>
94
- <execution>
95
- <id>ruby_release</id>
96
- <phase>deploy</phase>
97
- <goals>
98
- <goal>exec</goal>
99
- </goals>
100
- <configuration>
101
- <skip>${skipRubyRelease}</skip>
102
- <executable>bundle</executable>
103
- <arguments>
104
- <argument>exec</argument>
105
- <argument>rake</argument>
106
- <argument>release</argument>
107
- </arguments>
108
- <environmentVariables>
109
- <BUNDLE_GEMFILE>${basedir}/Gemfile</BUNDLE_GEMFILE>
110
- </environmentVariables>
111
- </configuration>
112
- </execution>
113
- </executions>
114
- </plugin>
115
- </plugins>
116
- </build>
117
-
118
- </project>
@@ -1,7 +0,0 @@
1
- {
2
- "httpForward": {
3
- "host": "www.mock-server.com",
4
- "port": 80,
5
- "scheme": "HTTP"
6
- }
7
- }
@@ -1,20 +0,0 @@
1
- {
2
- "httpResponse": {
3
- "statusCode": 401,
4
- "headers": [
5
- {
6
- "name": "Content-Type",
7
- "values": ["application/json; charset=utf-8"]
8
- },
9
- {
10
- "name": "Cache-Control",
11
- "values": ["public, max-age=86400"]
12
- }
13
- ],
14
- "body": "incorrect username and password combination",
15
- "delay": {
16
- "timeUnit": "SECONDS",
17
- "value": 1
18
- }
19
- }
20
- }
@@ -1,22 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login",
5
- "queryStringParameters": [
6
- {
7
- "name": "returnUrl",
8
- "values": ["/account"]
9
- }
10
- ],
11
- "cookies": [
12
- {
13
- "name": "sessionId",
14
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
15
- }
16
- ],
17
- "body": {
18
- "type": "STRING",
19
- "value": "{username:'foo', password:'bar'}"
20
- }
21
- }
22
- }
@@ -1,50 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login",
5
- "queryStringParameters": [
6
- {
7
- "values": [
8
- "/account"
9
- ],
10
- "name": "returnUrl"
11
- }
12
- ],
13
- "cookies": [
14
- {
15
- "name": "sessionId",
16
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW"
17
- }
18
- ],
19
- "body": {
20
- "type": "STRING",
21
- "value": "{\"username\":\"foo\",\"password\":\"bar\"}"
22
- }
23
- },
24
- "httpResponse": {
25
- "statusCode": 401,
26
- "headers": [
27
- {
28
- "values": [
29
- "application/json; charset=utf-8"
30
- ],
31
- "name": "Content-Type"
32
- },
33
- {
34
- "values": [
35
- "public, max-age=86400"
36
- ],
37
- "name": "Cache-Control"
38
- }
39
- ],
40
- "body": "{\"message\":\"incorrect username and password combination\"}",
41
- "delay": {
42
- "timeUnit": "SECONDS",
43
- "value": 1
44
- }
45
- },
46
- "times": {
47
- "remainingTimes": 2,
48
- "unlimited": "false"
49
- }
50
- }
@@ -1,22 +0,0 @@
1
- {
2
- "method": "POST",
3
- "path": "/login",
4
- "queryStringParameters": [
5
- {
6
- "values": [
7
- "/account"
8
- ],
9
- "name": "returnUrl"
10
- }
11
- ],
12
- "cookies": [
13
- {
14
- "value": "2By8LOhBmaW5nZXJwcmludCIlMDAzMW",
15
- "name": "sessionId"
16
- }
17
- ],
18
- "body": {
19
- "type": "STRING",
20
- "value": "{\"username\":\"foo\",\"password\":\"bar\"}"
21
- }
22
- }
@@ -1,6 +0,0 @@
1
- {
2
- "httpRequest": {
3
- "method": "POST",
4
- "path": "/login"
5
- }
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "times": {
3
- "remainingTimes": 1,
4
- "unlimited": "false"
5
- }
6
- }
@@ -1,82 +0,0 @@
1
- # encoding: UTF-8
2
- require 'rspec'
3
- require 'net/http'
4
- require 'webmock/rspec'
5
- require_relative '../../lib/mockserver-client'
6
-
7
- RSpec.configure do |config|
8
- include WebMock::API
9
- include MockServer
10
- include MockServer::UtilityMethods
11
- include MockServer::Model::DSL
12
-
13
- # Only accept expect syntax do not allow old should syntax
14
- config.expect_with :rspec do |c|
15
- c.syntax = :expect
16
- end
17
- end
18
-
19
- describe MockServer::MockServerClient do
20
-
21
- let(:client) { MockServer::MockServerClient.new('localhost', 1080) }
22
-
23
- before do
24
- # To suppress logging output to standard output, write to a temporary file
25
- client.logger = LoggingFactory::DEFAULT_FACTORY.log('test', output: 'tmp.log', truncate: true)
26
- end
27
-
28
- def create_agent
29
- uri = URI('http://api.nsa.gov:1337/agent')
30
- http = Net::HTTP.new(uri.host, uri.port)
31
- req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
32
- req.body = { name: 'John Doe', role: 'agent' }.to_json
33
- res = http.request(req)
34
- puts "response #{res.body}"
35
- rescue => e
36
- puts "failed #{e}"
37
- end
38
-
39
- it 'setup complex expectation' do
40
- WebMock.allow_net_connect!
41
-
42
- # given
43
- mock_expectation = expectation do |expectation|
44
- expectation.request do |request|
45
- request.method = 'POST'
46
- request.path = '/somePath'
47
- request.query_string_parameters << parameter('param', 'someQueryStringValue')
48
- request.headers << header('Header', 'someHeaderValue')
49
- request.cookies << cookie('cookie', 'someCookieValue')
50
- request.body = exact('someBody')
51
- end
52
-
53
- expectation.response do |response|
54
- response.status_code = 201
55
- response.headers << header('header', 'someHeaderValue')
56
- response.body = body('someBody')
57
- response.delay = delay_by(:SECONDS, 1)
58
- end
59
-
60
- expectation.times = exactly(1)
61
- end
62
-
63
- # and
64
- expect(client.register(mock_expectation).code).to eq(201)
65
-
66
- # when
67
- uri = URI('http://localhost:1080/somePath')
68
- http = Net::HTTP.new(uri.host, uri.port)
69
- req = Net::HTTP::Post.new('/somePath?param=someQueryStringValue')
70
- req['Header'] = 'someHeaderValue'
71
- req['Cookie'] = 'cookie=someCookieValue'
72
- req.body = 'someBody'
73
- res = http.request(req)
74
-
75
- # then
76
- expect(res.code).to eq('201')
77
- expect(res.body).to eq('someBody')
78
-
79
- WebMock.disable_net_connect!
80
- end
81
-
82
- end
@@ -1,90 +0,0 @@
1
- # encoding: UTF-8
2
- require_relative '../spec_helper'
3
-
4
- describe MockServer::Model::DSL do
5
-
6
- it 'generates http requests correctly' do
7
- mock_request = http_request(:POST, '/login')
8
- mock_request.query_string_parameters = [parameter('returnUrl', '/account')]
9
- mock_request.cookies = [cookie('sessionId', '2By8LOhBmaW5nZXJwcmludCIlMDAzMW')]
10
- mock_request.body = exact("{username:'foo', password:'bar'}")
11
-
12
- expect(to_camelized_hash(HTTP_REQUEST => mock_request)).to eq(FIXTURES.read('post_login_request.json'))
13
-
14
- # Block style
15
- mock_request = request(:POST, '/login') do |request|
16
- request.query_string_parameters = [parameter('returnUrl', '/account')]
17
- request.cookies = [cookie('sessionId', '2By8LOhBmaW5nZXJwcmludCIlMDAzMW')]
18
- request.body = exact("{username:'foo', password:'bar'}")
19
- end
20
-
21
- expect(to_camelized_hash(HTTP_REQUEST => mock_request)).to eq(FIXTURES.read('post_login_request.json'))
22
- end
23
-
24
- it 'generates http responses correctly' do
25
- mock_response = http_response
26
- mock_response.status_code = 401
27
- mock_response.headers = [header('Content-Type', 'application/json; charset=utf-8')]
28
- mock_response.headers << header('Cache-Control', 'public, max-age=86400')
29
- mock_response.body = body('incorrect username and password combination')
30
- mock_response.delay = delay_by(:SECONDS, 1)
31
-
32
- expect(to_camelized_hash(HTTP_RESPONSE => mock_response)).to eq(FIXTURES.read('incorrect_login_response.json'))
33
-
34
- # Block style
35
- mock_response = response do |response|
36
- response.status_code = 401
37
- response.headers = [header('Content-Type', 'application/json; charset=utf-8')]
38
- response.headers << header('Cache-Control', 'public, max-age=86400')
39
- response.body = body('incorrect username and password combination')
40
- response.delay = delay_by(:SECONDS, 1)
41
- end
42
-
43
- expect(to_camelized_hash(HTTP_RESPONSE => mock_response)).to eq(FIXTURES.read('incorrect_login_response.json'))
44
- end
45
-
46
- it 'generates http forwards correctly' do
47
- mock_forward = http_forward
48
- mock_forward.host = 'www.mock-server.com'
49
- mock_forward.port = 80
50
-
51
- expect(to_camelized_hash(HTTP_FORWARD => mock_forward)).to eq(FIXTURES.read('forward_mockserver.json'))
52
-
53
- # Block style
54
- mock_forward = forward do |forward|
55
- forward.host = 'www.mock-server.com'
56
- forward.port = 80
57
- end
58
-
59
- expect(to_camelized_hash(HTTP_FORWARD => mock_forward)).to eq(FIXTURES.read('forward_mockserver.json'))
60
- end
61
-
62
- it 'generates times correctly' do
63
- expect(to_camelized_hash(HTTP_TIMES => exactly(1))).to eq(FIXTURES.read('times_once.json'))
64
-
65
- # Block style
66
- mock_times = times do |times|
67
- times.remaining_times = 1
68
- end
69
- expect(to_camelized_hash(HTTP_TIMES => mock_times)).to eq(FIXTURES.read('times_once.json'))
70
- end
71
-
72
- it 'generates expectation correctly from file' do
73
- payload = FIXTURES.read('register_expectation.json')
74
- mock_expectation = expectation_from_json(payload)
75
-
76
- expect(to_camelized_hash(mock_expectation.to_hash)).to eq(payload)
77
- end
78
-
79
- it 'generates body correctly' do
80
- expect(to_camelized_hash(regex('*/login'))).to eq('type' => 'REGEX', 'value' => '*/login')
81
- expect(to_camelized_hash(xpath('/login[1]'))).to eq('type' => 'XPATH', 'value' => '/login[1]')
82
- expect(to_camelized_hash(parameterized(parameter('token', '4jy5hh')))).to eq('type' => 'PARAMETERS', 'parameters' => [{ 'name' => 'token', 'values' => ['4jy5hh'] }])
83
- end
84
-
85
- it 'generates times object correctly' do
86
- expect(to_camelized_hash(unlimited)).to eq('unlimited' => 'true', 'remainingTimes' => 0)
87
- expect(to_camelized_hash(at_least(2))).to eq('unlimited' => 'true', 'remainingTimes' => 2)
88
- end
89
-
90
- end
@@ -1,80 +0,0 @@
1
- # encoding: UTF-8
2
- require_relative '../spec_helper'
3
-
4
- describe MockServer::MockServerClient do
5
-
6
- let(:client) { MockServer::MockServerClient.new('localhost', 8080) }
7
- let(:register_expectation_json) { FIXTURES.read('register_expectation.json').to_json }
8
- let(:search_request_json) { FIXTURES.read('search_request.json').to_json }
9
-
10
- before do
11
- # To suppress logging output to standard output, write to a temporary file
12
- client.logger = LoggingFactory::DEFAULT_FACTORY.log('test', output: 'tmp.log', truncate: true)
13
-
14
- # Stub requests
15
- stub_request(:put, /.+\/expectation/).with(body: register_expectation_json, headers: { 'Content-Type' => 'application/json' }).to_return(status: 201)
16
- stub_request(:put, /.+\/clear/).with(body: search_request_json, headers: { 'Content-Type' => 'application/json' }).to_return(status: 202)
17
- stub_request(:put, /.+\/reset/).with(headers: { 'Content-Type' => 'application/json' }).to_return(status: 202)
18
- stub_request(:put, /.+\/retrieve/).with(body: search_request_json, headers: { 'Content-Type' => 'application/json' }).to_return(
19
- body: '[]',
20
- status: 200
21
- )
22
- end
23
-
24
- it 'registers an expectation correctly' do
25
- mock_expectation = expectation do |expectation|
26
- expectation.request do |request|
27
- request.method = 'POST'
28
- request.path = '/login'
29
- request.query_string_parameters << parameter('returnUrl', '/account')
30
- request.cookies << cookie('sessionId', '2By8LOhBmaW5nZXJwcmludCIlMDAzMW')
31
- request.body = exact({ username: 'foo', password: 'bar' }.to_json)
32
- end
33
-
34
- expectation.response do |response|
35
- response.status_code = 401
36
- response.headers << header('Content-Type', 'application/json; charset=utf-8')
37
- response.headers << header('Cache-Control', 'public, max-age=86400')
38
- response.body = body({ message: 'incorrect username and password combination' }.to_json)
39
- response.delay = delay_by(:SECONDS, 1)
40
- end
41
-
42
- expectation.times = exactly(2)
43
- end
44
-
45
- response = client.register(mock_expectation)
46
- expect(response.code).to eq(201)
47
- end
48
-
49
- it 'raises an error when trying to set both forward and response' do
50
- mock_expectation = expectation do |expectation|
51
- expectation.request do |request|
52
- request.method = 'POST'
53
- request.path = '/login'
54
- end
55
-
56
- expectation.response do |response|
57
- response.status_code = 401
58
- end
59
-
60
- expectation.forward do |forward|
61
- forward.scheme = :HTTP
62
- end
63
- end
64
-
65
- expect { client.register(mock_expectation) }.to raise_error(RuntimeError, 'You can only set either of ["httpResponse", "httpForward"]. But not both')
66
- end
67
-
68
- it 'clears requests from the mock server' do
69
- expect(client.clear(request(:POST, '/login')).code).to eq(202)
70
- end
71
-
72
- it 'resets the mock server' do
73
- expect(client.reset.code).to eq(202)
74
- end
75
-
76
- it 'retrieves requests correctly' do
77
- expect(client.retrieve(request(:POST, '/login')).code).to eq(200)
78
- end
79
-
80
- end