quinoa 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +46 -44
- data/README.md +5 -2
- data/changelog +4 -0
- data/lib/quinoa/service.rb +127 -5
- data/lib/quinoa/version.rb +1 -1
- data/quinoa.gemspec +8 -8
- data/spec/core_spec.rb +339 -0
- data/spec/report_spec.rb +126 -0
- data/spec/spec_helper.rb +2 -2
- metadata +47 -45
- data/spec/service_object_spec.rb +0 -310
data/spec/report_spec.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
+
require File.join(File.dirname(__FILE__), '../lib/quinoa/service.rb')
|
3
|
+
|
4
|
+
describe Quinoa do
|
5
|
+
describe "The service should have an api that supports the" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "reporting about the response" do
|
12
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
13
|
+
to_return(:status => 200, :body => "This request works fine")
|
14
|
+
|
15
|
+
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
16
|
+
@service.get!
|
17
|
+
|
18
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "health"
|
19
|
+
expect(JSON.parse(@service.report).to_hash["response"]["status_code"]).to eq 200
|
20
|
+
expect(JSON.parse(@service.report).to_hash["response"]["response_body"]).to eq "This request works fine"
|
21
|
+
expect(JSON.parse(@service.report).to_hash["response"]["response_time"]).to be < 0.1
|
22
|
+
|
23
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]).to be {}
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "execution of internao assertions" do
|
27
|
+
|
28
|
+
it "for a check with success for status code" do
|
29
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
30
|
+
to_return(:status => 200, :body => "This request works fine")
|
31
|
+
|
32
|
+
expect(@service.expectations).to eq Hash[]
|
33
|
+
@service.add_expected_status 200
|
34
|
+
|
35
|
+
@service.post!
|
36
|
+
@service.check!
|
37
|
+
|
38
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "health"
|
39
|
+
expect(JSON.parse(@service.report).to_hash["response"]["status_code"]).to eq 200
|
40
|
+
|
41
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["status"]).to eq "health"
|
42
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["assertion_result"]).to eq true
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
it "for a check with success for body contains string" do
|
47
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
48
|
+
to_return(:status => 200, :body => "This request works fine")
|
49
|
+
|
50
|
+
expect(@service.expectations).to eq Hash[]
|
51
|
+
@service.add_expected_body_string "works"
|
52
|
+
|
53
|
+
@service.post!
|
54
|
+
@service.check!
|
55
|
+
|
56
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "health"
|
57
|
+
|
58
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["body"]["status"]).to eq "health"
|
59
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["body"]["assertion_result"]).to eq true
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
it "for a check with success for response time under a threshold" do
|
64
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
65
|
+
to_return(:status => 200, :body => "This request works fine")
|
66
|
+
|
67
|
+
expect(@service.expectations).to eq Hash[]
|
68
|
+
@service.add_expected_max_response_time 1
|
69
|
+
|
70
|
+
@service.post!
|
71
|
+
@service.check!
|
72
|
+
|
73
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "health"
|
74
|
+
expect(JSON.parse(@service.report).to_hash["response"]["response_time"]).to be < 0.1
|
75
|
+
|
76
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["response_time"]["status"]).to eq "health"
|
77
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["response_time"]["assertion_result"]).to eq true
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
it "for a check with success for all checks" do
|
82
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
83
|
+
to_return(:status => 200, :body => "This request works fine")
|
84
|
+
|
85
|
+
expect(@service.expectations).to eq Hash[]
|
86
|
+
|
87
|
+
@service.add_expected_status 200
|
88
|
+
@service.add_expected_body_string "works"
|
89
|
+
@service.add_expected_max_response_time 1
|
90
|
+
|
91
|
+
@service.post!
|
92
|
+
@service.check!
|
93
|
+
|
94
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "health"
|
95
|
+
expect(JSON.parse(@service.report).to_hash["response"]["response_time"]).to be < 0.1
|
96
|
+
|
97
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["response_time"]["status"]).to eq "health"
|
98
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["response_time"]["assertion_result"]).to eq true
|
99
|
+
|
100
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["body"]["status"]).to eq "health"
|
101
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["body"]["assertion_result"]).to eq true
|
102
|
+
|
103
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["status"]).to eq "health"
|
104
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["assertion_result"]).to eq true
|
105
|
+
end
|
106
|
+
|
107
|
+
it "for a check with failure returning the right level" do
|
108
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
109
|
+
to_return(:status => 200, :body => "This request works fine")
|
110
|
+
|
111
|
+
expect(@service.expectations).to eq Hash[]
|
112
|
+
@service.add_expected_status 300
|
113
|
+
|
114
|
+
@service.post!
|
115
|
+
@service.check!
|
116
|
+
|
117
|
+
expect(JSON.parse(@service.report).to_hash["health"]).to eq "fail"
|
118
|
+
|
119
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["status"]).to eq "fail"
|
120
|
+
expect(JSON.parse(@service.report).to_hash["assertions"]["status_code"]["assertion_result"]).to eq false
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,141 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quinoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.12.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: codeclimate-test-reporter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.6.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.6.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.10.
|
47
|
+
version: 0.10.4
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.10.
|
54
|
+
version: 0.10.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 11.3.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 11.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: nyan-cat-formatter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.11'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.11'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: cucumber
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.
|
89
|
+
version: 2.4.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
96
|
+
version: 2.4.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 2.1.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 2.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rest-client
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 2.0.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 2.0.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 3.
|
131
|
+
version: 3.5.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 3.
|
138
|
+
version: 3.5.0
|
139
139
|
description: Quinoa is a light and nutritive framework that allows automate service
|
140
140
|
level tests using object model
|
141
141
|
email:
|
@@ -144,10 +144,10 @@ executables: []
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
-
- .gitignore
|
148
|
-
- .rspec
|
149
|
-
- .ruby-version
|
150
|
-
- .travis.yml
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".ruby-version"
|
150
|
+
- ".travis.yml"
|
151
151
|
- Gemfile
|
152
152
|
- Gemfile.lock
|
153
153
|
- LICENSE
|
@@ -159,7 +159,8 @@ files:
|
|
159
159
|
- lib/quinoa/version.rb
|
160
160
|
- quinoa.gemspec
|
161
161
|
- quinoa.jpg
|
162
|
-
- spec/
|
162
|
+
- spec/core_spec.rb
|
163
|
+
- spec/report_spec.rb
|
163
164
|
- spec/spec_helper.rb
|
164
165
|
homepage: http://github.com/camiloribeiro/quinoa
|
165
166
|
licenses:
|
@@ -171,20 +172,21 @@ require_paths:
|
|
171
172
|
- lib
|
172
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
174
|
requirements:
|
174
|
-
- -
|
175
|
+
- - ">="
|
175
176
|
- !ruby/object:Gem::Version
|
176
177
|
version: '0'
|
177
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
|
-
- -
|
180
|
+
- - ">="
|
180
181
|
- !ruby/object:Gem::Version
|
181
182
|
version: '0'
|
182
183
|
requirements: []
|
183
184
|
rubyforge_project: quinoa
|
184
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.4.6
|
185
186
|
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: Service-Object Model for Ruby
|
188
189
|
test_files:
|
189
|
-
- spec/
|
190
|
+
- spec/core_spec.rb
|
191
|
+
- spec/report_spec.rb
|
190
192
|
- spec/spec_helper.rb
|
data/spec/service_object_spec.rb
DELETED
@@ -1,310 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
require File.join(File.dirname(__FILE__), '../lib/quinoa/service.rb')
|
3
|
-
|
4
|
-
describe Quinoa do
|
5
|
-
describe "The service should have the basic items of a service under test" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "Should instantiate" do
|
12
|
-
expect(@service.url).to eq "http://www.camiloribeiro.com"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "Should have a authorizoation" do
|
16
|
-
expect(@service.content_type).to eq nil
|
17
|
-
|
18
|
-
@service.authorization = "token !#€%&/()="
|
19
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
20
|
-
end
|
21
|
-
|
22
|
-
it "Should have a Content-Type" do
|
23
|
-
expect(@service.content_type).to eq nil
|
24
|
-
|
25
|
-
@service.content_type = "application/json"
|
26
|
-
expect(@service.content_type).to eq "application/json"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "Should have a Accept" do
|
30
|
-
expect(@service.accept).to eq nil
|
31
|
-
|
32
|
-
@service.accept = "application/xml;q=0.9,*/*;q=0.8."
|
33
|
-
expect(@service.accept).to eq "application/xml;q=0.9,*/*;q=0.8."
|
34
|
-
end
|
35
|
-
|
36
|
-
it "Should have a body" do
|
37
|
-
expect(@service.body).to eq nil
|
38
|
-
|
39
|
-
@service.body = "text"
|
40
|
-
expect(@service.body).to eq "text"
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "Custom headers" do
|
44
|
-
|
45
|
-
it "Should be able to add a single custom header" do
|
46
|
-
|
47
|
-
expect(@service.custom_headers).to eq Hash[]
|
48
|
-
|
49
|
-
@service.add_custom_header "my-company-custom-header", "text"
|
50
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text"]
|
51
|
-
end
|
52
|
-
|
53
|
-
it "Should be able to add many custom headers" do
|
54
|
-
expect(@service.custom_headers).to eq Hash[]
|
55
|
-
|
56
|
-
@service.add_custom_header "my-company-custom-header", "text"
|
57
|
-
@service.add_custom_header "headerx", "bar"
|
58
|
-
@service.add_custom_header :"my-foo-custom-header", "foo"
|
59
|
-
|
60
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
|
61
|
-
end
|
62
|
-
|
63
|
-
it "Should be able to remove one among many custom headers" do
|
64
|
-
expect(@service.custom_headers).to eq Hash[]
|
65
|
-
|
66
|
-
@service.add_custom_header "my-company-custom-header", "text"
|
67
|
-
@service.add_custom_header "headerx", "bar"
|
68
|
-
@service.add_custom_header :"my-foo-custom-header", "foo"
|
69
|
-
|
70
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
|
71
|
-
|
72
|
-
@service.remove_custom_header "headerx"
|
73
|
-
|
74
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :"my-foo-custom-header" => "foo"]
|
75
|
-
end
|
76
|
-
|
77
|
-
["post", "get"].each do |method|
|
78
|
-
it "Should be present in the #{method} requests" do
|
79
|
-
# For this mock order matters
|
80
|
-
stub_request(:any, "http://www.camiloribeiro.com").
|
81
|
-
to_return(:status => 200, :body => "This request requires a 'my-company-custom-header' to work")
|
82
|
-
|
83
|
-
stub_request(:any, "http://www.camiloribeiro.com").
|
84
|
-
with(:headers => { 'my-company-custom-header' => "text" }).
|
85
|
-
to_return(:status => 200, :body => "This request works fine")
|
86
|
-
|
87
|
-
@other_service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
88
|
-
|
89
|
-
expect(@service.custom_headers).to eq Hash[]
|
90
|
-
expect(@other_service.custom_headers).to eq Hash[]
|
91
|
-
|
92
|
-
@service.add_custom_header "my-company-custom-header", "text"
|
93
|
-
@service.add_custom_header "headerx", "bar"
|
94
|
-
@service.add_custom_header :"my-foo-custom-header", "foo"
|
95
|
-
|
96
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
|
97
|
-
expect(@other_service.custom_headers).to eq Hash[]
|
98
|
-
|
99
|
-
@service.send "#{method}!"
|
100
|
-
@other_service.send "#{method}!"
|
101
|
-
|
102
|
-
expect(@service.response.body).to eq("This request works fine")
|
103
|
-
expect(@other_service.response.body).to eq("This request requires a 'my-company-custom-header' to work")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "overwiting the entire url to post and get" do
|
110
|
-
|
111
|
-
before(:each) do
|
112
|
-
stub_request(:any, "http://www.bugbang.com.br/foo").
|
113
|
-
to_return(:status => 200, :body => "simple response", :headers => {:accept=>"application/xml", :content_type => "application/json"})
|
114
|
-
|
115
|
-
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
116
|
-
@service.path = "/something"
|
117
|
-
@service.content_type = "application/json"
|
118
|
-
@service.authorization = "token !#€%&/()="
|
119
|
-
@service.body = "simple body"
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should overwite for get" do
|
124
|
-
@service.get! "http://www.bugbang.com.br/foo"
|
125
|
-
|
126
|
-
# explicity
|
127
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
128
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
129
|
-
expect(@service.response.body).to eq("simple response")
|
130
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
131
|
-
expect(@service.response.code).to eq(200)
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should overwite for post" do
|
135
|
-
@service.post! "http://www.bugbang.com.br/foo"
|
136
|
-
|
137
|
-
# explicity
|
138
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
139
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
140
|
-
expect(@service.response.body).to eq("simple response")
|
141
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
142
|
-
expect(@service.response.code).to eq(200)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
describe "defining a different paths" do
|
148
|
-
|
149
|
-
["/", "/path"].each do |path|
|
150
|
-
describe "should work for the path #{path}" do
|
151
|
-
|
152
|
-
before(:each) do
|
153
|
-
stub_request(:any, "http://www.camiloribeiro.com#{path}").
|
154
|
-
to_return(:status => 200, :body => "simple response", :headers => {:accept=>"application/xml", :content_type => "application/json"})
|
155
|
-
|
156
|
-
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
157
|
-
@service.path = path
|
158
|
-
@service.content_type = "application/json"
|
159
|
-
@service.authorization = "token !#€%&/()="
|
160
|
-
@service.body = "simple body"
|
161
|
-
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should post" do
|
165
|
-
@service.post!
|
166
|
-
|
167
|
-
# explicity
|
168
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
169
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
170
|
-
expect(@service.response.body).to eq("simple response")
|
171
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
172
|
-
expect(@service.response.code).to eq(200)
|
173
|
-
|
174
|
-
# natural
|
175
|
-
expect(@service.response_accept).to eq("application/xml")
|
176
|
-
expect(@service.response_content_type).to eq("application/json")
|
177
|
-
expect(@service.response_body).to eq("simple response")
|
178
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
179
|
-
expect(@service.response_code).to eq(200)
|
180
|
-
end
|
181
|
-
|
182
|
-
it "should get" do
|
183
|
-
@service.get!
|
184
|
-
|
185
|
-
# explicity
|
186
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
187
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
188
|
-
expect(@service.response.body).to eq("simple response")
|
189
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
190
|
-
expect(@service.response.code).to eq(200)
|
191
|
-
|
192
|
-
# natural
|
193
|
-
expect(@service.response_accept).to eq("application/xml")
|
194
|
-
expect(@service.response_content_type).to eq("application/json")
|
195
|
-
expect(@service.response_body).to eq("simple response")
|
196
|
-
expect(@service.authorization).to eq "token !#€%&/()="
|
197
|
-
expect(@service.response_code).to eq(200)
|
198
|
-
end
|
199
|
-
|
200
|
-
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
describe "the service should have the basic behaviours of a service" do
|
207
|
-
|
208
|
-
# 303 post and get, 301 get, 302 get and 307 get failing
|
209
|
-
[100,101,102,200,201,202,203,204,205,206,207,208,226,300,304,305,306,308,308,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,420,421,422,423,424,426,428,429,431,440,444,449,450,451,451,494,495,496,497,498,499,499,500,501,502,503,504,505,506,507,508,509,510,511,520,522,598,599].each do |code|
|
210
|
-
describe "when returning code #{code}" do
|
211
|
-
before(:each) do
|
212
|
-
stub_request(:any, "http://www.camiloribeiro.com/").
|
213
|
-
to_return(:status => code, :body => "simple response", :headers => {:accept=>"application/xml", :content_type => "application/json"})
|
214
|
-
|
215
|
-
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
216
|
-
@service.content_type = "application/json"
|
217
|
-
@service.body = "simple body"
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
it "should post" do
|
222
|
-
@service.post!
|
223
|
-
|
224
|
-
# explicity
|
225
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
226
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
227
|
-
expect(@service.response.body).to eq("simple response")
|
228
|
-
expect(@service.response.code).to eq(code)
|
229
|
-
|
230
|
-
# natural
|
231
|
-
expect(@service.response_accept).to eq("application/xml")
|
232
|
-
expect(@service.response_content_type).to eq("application/json")
|
233
|
-
expect(@service.response_body).to eq("simple response")
|
234
|
-
expect(@service.response_code).to eq(code)
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should get" do
|
238
|
-
@service.get!
|
239
|
-
|
240
|
-
# explicity
|
241
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
242
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
243
|
-
expect(@service.response.body).to eq("simple response")
|
244
|
-
expect(@service.response.code).to eq(code)
|
245
|
-
|
246
|
-
# natural
|
247
|
-
expect(@service.response_accept).to eq("application/xml")
|
248
|
-
expect(@service.response_content_type).to eq("application/json")
|
249
|
-
expect(@service.response_body).to eq("simple response")
|
250
|
-
expect(@service.response_code).to eq(code)
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
# 303 post and get, 301 get, 302 get and 307 get failing
|
257
|
-
[301,302,307].each do |code|
|
258
|
-
describe "when returning code #{code}" do
|
259
|
-
before(:each) do
|
260
|
-
stub_request(:any, "http://www.camiloribeiro.com/").
|
261
|
-
to_return(:status => code, :body => "simple response", :headers => {:accept=>"application/xml", :content_type => "application/json", :location => "http://www.bugbang.com.br"})
|
262
|
-
|
263
|
-
stub_request(:any, "http://www.bugbang.com.br/").
|
264
|
-
to_return(:status => 200, :body => "followed redirect", :headers => {:accept=>"application/xml", :content_type => "application/json"})
|
265
|
-
|
266
|
-
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
267
|
-
@service.content_type = "application/json"
|
268
|
-
@service.body = "simple body"
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
it "should post" do
|
273
|
-
@service.post!
|
274
|
-
|
275
|
-
# explicity
|
276
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
277
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
278
|
-
expect(@service.response.body).to eq("simple response")
|
279
|
-
expect(@service.response.headers[:location]).to eq("http://www.bugbang.com.br")
|
280
|
-
expect(@service.response.code).to eq(code)
|
281
|
-
|
282
|
-
# natural
|
283
|
-
expect(@service.response_accept).to eq("application/xml")
|
284
|
-
expect(@service.response_content_type).to eq("application/json")
|
285
|
-
expect(@service.response_body).to eq("simple response")
|
286
|
-
expect(@service.response_location).to eq("http://www.bugbang.com.br")
|
287
|
-
expect(@service.response_code).to eq(code)
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should get" do
|
291
|
-
|
292
|
-
@service.get!
|
293
|
-
|
294
|
-
# explicity
|
295
|
-
expect(@service.response.headers[:accept]).to eq("application/xml")
|
296
|
-
expect(@service.response.headers[:content_type]).to eq("application/json")
|
297
|
-
expect(@service.response.body).to eq("followed redirect")
|
298
|
-
expect(@service.response.code).to eq(200)
|
299
|
-
|
300
|
-
# natural
|
301
|
-
expect(@service.response_accept).to eq("application/xml")
|
302
|
-
expect(@service.response_content_type).to eq("application/json")
|
303
|
-
expect(@service.response_body).to eq("followed redirect")
|
304
|
-
expect(@service.response_code).to eq(200)
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|