rest-assured 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +1 -1
- data/db/migrate/20110620161740_add_fixtures.rb +1 -1
- data/db/migrate/20110625155332_add_redirects_table.rb +1 -1
- data/db/migrate/20110709150645_add_description_to_fixtures.rb +1 -1
- data/db/migrate/20110807222522_add_active_bit_to_fixtures.rb +1 -1
- data/db/migrate/20110818155555_add_position_to_redirects.rb +1 -1
- data/db/migrate/20110823132023_add_method_to_fixtures.rb +1 -1
- data/db/migrate/20110912162948_rename_url_to_fullpath.rb +1 -1
- data/db/migrate/20110912163705_rename_fixtures_to_doubles.rb +1 -1
- data/db/migrate/20111013122857_create_requests.rb +1 -1
- data/db/migrate/20111016174101_rename_method_to_verb.rb +1 -1
- data/db/migrate/20111021113953_add_status_to_doubles.rb +1 -1
- data/db/migrate/20111208155906_add_response_headers_to_doubles.rb +1 -1
- data/db/migrate/20120320200820_change_fullpath_to_text.rb +1 -1
- data/db/migrate/20170713000515_add_delay_to_doubles.rb +1 -1
- data/db/migrate/20170818001158_add_pathpattern_to_doubles.rb +1 -1
- data/db/test.db +0 -0
- data/features/rest_api/doubles.feature +2 -2
- data/features/ruby_api/wait_for_requests.feature +1 -1
- data/features/step_definitions/doubles_steps.rb +15 -7
- data/features/step_definitions/ruby_api_steps.rb +2 -3
- data/features/support/env.rb +0 -1
- data/lib/rest-assured/routes/double.rb +3 -3
- data/lib/rest-assured/routes/redirect.rb +1 -1
- data/lib/rest-assured/version.rb +1 -1
- data/spec/functional/response_spec.rb +1 -3
- data/spec/models/double_spec.rb +0 -5
- data/spec/models/redirect_spec.rb +5 -13
- data/spec/models/request_spec.rb +0 -3
- data/spec/spec_helper.rb +0 -1
- metadata +35 -13
- data/features/step_definitions/support/numeric_transforms.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6dbb2567ce9b78bddff115b00f57999052f0bfc
|
4
|
+
data.tar.gz: 69f443e6bfd47995fd8c1d29a674702f3ebf4e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaef1f201d5063cc4e7de3f1f827b6be2e24c14c18a4781f904fb1301b4f0814fb67ecdfbaabac13090892d603192b7d1a350505f3787ac2e325adc83f3048c1
|
7
|
+
data.tar.gz: a1ae1c24692c74ff7fe007e444d2d1bc4f681927375f2b2b6866acd2cf2e71cdc176fac3afa74dd2d723ba055299fa2df9a0180c6a08b9b519696393b1ef650b
|
data/README.markdown
CHANGED
@@ -32,7 +32,7 @@ But why not to use [VCR](https://github.com/vcr/vcr) or [WebMock](https://github
|
|
32
32
|
|
33
33
|
## Set up
|
34
34
|
|
35
|
-
You are going to need ruby >=
|
35
|
+
You are going to need ruby >= 2.2.2 and either sqlite3, postgres or mysql. Use 2.x version of this gem if you need to support an older ruby version (>= 1.9.3).
|
36
36
|
|
37
37
|
### In ruby project
|
38
38
|
|
data/db/test.db
CHANGED
Binary file
|
@@ -34,7 +34,7 @@ Feature: use doubles via api
|
|
34
34
|
Scenario Outline: request fullpath that matches double
|
35
35
|
Given there is double with "<fullpath>" as fullpath, "<content>" as response content, "<verb>" as request verb and "<status>" as status
|
36
36
|
When I "<verb>" "<fullpath>"
|
37
|
-
Then I should get
|
37
|
+
Then I should get <status> as response status and "<content>" in response content
|
38
38
|
|
39
39
|
Examples:
|
40
40
|
| fullpath | content | verb | status |
|
@@ -48,7 +48,7 @@ Feature: use doubles via api
|
|
48
48
|
Scenario Outline: request a path that matches double a path pattern
|
49
49
|
Given there is double with "<pathpattern>" as pathpattern, "<content>" as response content, "<verb>" as request verb and "<status>" as status
|
50
50
|
When I "<verb>" "<fullpath>"
|
51
|
-
Then I should get
|
51
|
+
Then I should get <status> as response status and "<content>" in response content
|
52
52
|
|
53
53
|
Examples:
|
54
54
|
| pathpattern | fullpath | content | verb | status |
|
@@ -24,7 +24,7 @@ Feature: wait for requests on double to happen
|
|
24
24
|
@double.wait_for_requests(3)
|
25
25
|
"""
|
26
26
|
And that double gets requested 2 times
|
27
|
-
Then it should wait for 5 seconds
|
27
|
+
Then it should wait for default timeout of 5 seconds
|
28
28
|
And it should raise MoreRequestsExpected error after with the following message:
|
29
29
|
"""
|
30
30
|
Expected 3 requests. Got 2.
|
@@ -24,16 +24,16 @@ Then /^I should be able to get json representation of that double from response$
|
|
24
24
|
JSON.load( @create_a_double_response ).should == MultiJson.load( d.to_json )
|
25
25
|
end
|
26
26
|
|
27
|
-
Then /^I should get
|
27
|
+
Then /^I should get {int} in response status$/ do |status|
|
28
28
|
last_response.status.should == status
|
29
29
|
end
|
30
30
|
|
31
|
-
Then
|
32
|
-
RestAssured::Models::Double.where(:fullpath => fullpath, :content => content, :verb => verb, :status => status, :delay => delay).count.should == n
|
31
|
+
Then "there should be {int} double with {string} as fullpath, {string} as response content, {string} as request verb, status as {string} and delay as {string}" do |n, fullpath, content, verb, status, delay|
|
32
|
+
RestAssured::Models::Double.where(:fullpath => fullpath, :content => content, :verb => verb, :status => status.to_i, :delay => delay.to_i).count.should == n
|
33
33
|
end
|
34
34
|
|
35
|
-
Then
|
36
|
-
RestAssured::Models::Double.where(:pathpattern => pathpattern, :content => content, :verb => verb, :status => status, :delay => delay).count.should == n
|
35
|
+
Then "there should be {int} double with {string} as pathpattern, {string} as response content, {string} as request verb, status as {string} and delay as {string}" do |n, pathpattern, content, verb, status, delay|
|
36
|
+
RestAssured::Models::Double.where(:pathpattern => pathpattern, :content => content, :verb => verb, :status => status.to_i, :delay => delay.to_i).count.should == n
|
37
37
|
end
|
38
38
|
|
39
39
|
Given /^there is double with "([^"]*)" as fullpath and "([^"]*)" as response content$/ do |fullpath, content|
|
@@ -64,8 +64,16 @@ When /^I "([^"]*)" "([^"]*)"$/ do |verb, fullpath|
|
|
64
64
|
send(verb.downcase, fullpath)
|
65
65
|
end
|
66
66
|
|
67
|
-
Then
|
68
|
-
last_response.
|
67
|
+
Then "I should get {string} in response content" do |content|
|
68
|
+
last_response.body.should == content
|
69
|
+
end
|
70
|
+
|
71
|
+
Then "I should get {int} in response status" do |status|
|
72
|
+
last_response.status.should == status
|
73
|
+
end
|
74
|
+
|
75
|
+
Then "I should get {int} as response status and {string} in response content" do |status, content|
|
76
|
+
last_response.status.should == status
|
69
77
|
last_response.body.should == content
|
70
78
|
end
|
71
79
|
|
@@ -24,7 +24,7 @@ Given /^I created? a double:$/ do |string|
|
|
24
24
|
eval string
|
25
25
|
end
|
26
26
|
|
27
|
-
When
|
27
|
+
When "that double gets requested {int} times" do |num|
|
28
28
|
num.times do
|
29
29
|
sleep 0.5
|
30
30
|
send(@double.verb.downcase, @double.fullpath)
|
@@ -50,10 +50,9 @@ Then /^it should let me through$/ do
|
|
50
50
|
@more_reqs_exc.should == nil
|
51
51
|
end
|
52
52
|
|
53
|
-
Then
|
53
|
+
Then 'it should wait for (default timeout of ){int} seconds' do |timeout|
|
54
54
|
@t.join
|
55
55
|
wait_time = Time.now - @wait_start
|
56
|
-
#(timeout..(timeout+1)).should cover(wait_time) # cover() only avilable in 1.9
|
57
56
|
wait_time.should >= timeout
|
58
57
|
wait_time.should < timeout + 1.5
|
59
58
|
end
|
data/features/support/env.rb
CHANGED
@@ -17,7 +17,7 @@ module RestAssured
|
|
17
17
|
redirect to('/doubles')
|
18
18
|
end
|
19
19
|
|
20
|
-
router.get %r{
|
20
|
+
router.get %r{/doubles(\.json)?} do |needs_json|
|
21
21
|
@doubles = Models::Double.all
|
22
22
|
if needs_json
|
23
23
|
body @doubles.to_json
|
@@ -40,7 +40,7 @@ module RestAssured
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
router.post
|
43
|
+
router.post /\/doubles(\.json)?/ do |needs_json|
|
44
44
|
begin
|
45
45
|
data = request.body.read
|
46
46
|
d = JSON.load(data)
|
@@ -101,7 +101,7 @@ module RestAssured
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
router.delete %r{/doubles/(\d+)(\.json)
|
104
|
+
router.delete %r{/doubles/(\d+)(\.json)?} do |id, needs_json|
|
105
105
|
if Models::Double.destroy(id)
|
106
106
|
flash[:notice] = 'Double deleted'
|
107
107
|
redirect '/doubles' unless needs_json
|
@@ -11,7 +11,7 @@ module RestAssured
|
|
11
11
|
haml :'redirects/new'
|
12
12
|
end
|
13
13
|
|
14
|
-
router.post
|
14
|
+
router.post /\/redirects(.json)?/ do |needs_json|
|
15
15
|
@redirect = Models::Redirect.create(params['redirect'] || { :pattern => params['pattern'], :to => params['to'] })
|
16
16
|
|
17
17
|
if needs_json
|
data/lib/rest-assured/version.rb
CHANGED
@@ -57,8 +57,6 @@ module RestAssured
|
|
57
57
|
fullpath = '/some/other/path'
|
58
58
|
allow(request).to receive(:fullpath).and_return(fullpath)
|
59
59
|
allow(Models::Redirect).to receive(:find_redirect_url_for).with(fullpath).and_return(path)
|
60
|
-
puts "PATH"
|
61
|
-
puts path
|
62
60
|
|
63
61
|
expect(rest_assured_app).to receive(:body).with(@double.content)
|
64
62
|
expect(rest_assured_app).to receive(:status).with(@double.status)
|
@@ -133,7 +131,7 @@ module RestAssured
|
|
133
131
|
requests = double.as_null_object
|
134
132
|
allow(Models::Double).to receive(:where).and_return(double(:requests => requests, :delay => 10).as_null_object)
|
135
133
|
|
136
|
-
Response.
|
134
|
+
allow(Response).to receive(:sleep)
|
137
135
|
expect(Response).to receive(:sleep).with(10)
|
138
136
|
|
139
137
|
Response.perform(rest_assured_app)
|
data/spec/models/double_spec.rb
CHANGED
@@ -17,11 +17,6 @@ module RestAssured::Models
|
|
17
17
|
valid_params.except(:fullpath).merge(:pathpattern => /^\/api\/.*\/[a-zA-Z]\?nocache=true/)
|
18
18
|
end
|
19
19
|
|
20
|
-
it { is_expected.to validate_inclusion_of(:verb).in_array Double::VERBS }
|
21
|
-
it { is_expected.to validate_inclusion_of(:status).in_array Double::STATUSES }
|
22
|
-
|
23
|
-
it { is_expected.to have_many(:requests) }
|
24
|
-
|
25
20
|
it 'rejects double with neither fullpath or pathpattern' do
|
26
21
|
d = Double.new valid_params.except(:fullpath)
|
27
22
|
expect(d).to_not be_valid
|
@@ -2,14 +2,6 @@ require File.expand_path('../../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module RestAssured::Models
|
4
4
|
describe Redirect do
|
5
|
-
# this is solely to get through 'Can't find first XXX' shoulda crap
|
6
|
-
#before do
|
7
|
-
#Redirect.create :pattern => 'sdfsdf', :to => 'sdfsffdf'
|
8
|
-
#end
|
9
|
-
|
10
|
-
it { is_expected.to validate_presence_of(:pattern) }
|
11
|
-
it { is_expected.to validate_presence_of(:to) }
|
12
|
-
|
13
5
|
it 'assigns incremental position on create' do
|
14
6
|
r1 = Redirect.create :pattern => '.*', :to => 'someurl'
|
15
7
|
expect(r1.position).to eq(0)
|
@@ -38,20 +30,20 @@ module RestAssured::Models
|
|
38
30
|
context 'redirect url' do
|
39
31
|
it 'constructs url to redirect to' do
|
40
32
|
path = rand(1000)
|
41
|
-
|
33
|
+
Redirect.create :pattern => '/api/(.*)\?.*', :to => 'http://external.com/some/url/\1?p=5'
|
42
34
|
expect(Redirect.find_redirect_url_for("/api/#{path}?param=1")).to eq("http://external.com/some/url/#{path}?p=5")
|
43
35
|
end
|
44
36
|
|
45
37
|
it 'returns the one that matches the substring' do
|
46
|
-
|
47
|
-
|
38
|
+
Redirect.create :pattern => '/ai/path', :to => 'someurl'
|
39
|
+
Redirect.create :pattern => '/api/path', :to => 'someurl'
|
48
40
|
|
49
41
|
expect(Redirect.find_redirect_url_for('/api/path')).to eq('someurl')
|
50
42
|
end
|
51
43
|
|
52
44
|
it 'returns the oldest one that match' do
|
53
|
-
|
54
|
-
|
45
|
+
Redirect.create :pattern => '/api', :to => 'someurl'
|
46
|
+
Redirect.create :pattern => '/api/path', :to => 'otherurl'
|
55
47
|
|
56
48
|
expect(Redirect.find_redirect_url_for('/api/path')).to eq('someurl/path')
|
57
49
|
end
|
data/spec/models/request_spec.rb
CHANGED
@@ -2,9 +2,6 @@ require File.expand_path('../../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module RestAssured::Models
|
4
4
|
describe Request do
|
5
|
-
it { is_expected.to belong_to(:double) }
|
6
|
-
it { is_expected.to validate_presence_of(:rack_env) }
|
7
|
-
|
8
5
|
it 'knows when it has been created' do
|
9
6
|
now = Time.now
|
10
7
|
allow(Time).to receive(:now).and_return(now)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-assured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Avetisyan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.4.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.4.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: childprocess
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,44 +62,62 @@ dependencies:
|
|
56
62
|
name: haml
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '4.0'
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '5.0'
|
62
71
|
type: :runtime
|
63
72
|
prerelease: false
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
65
74
|
requirements:
|
66
|
-
- - "
|
75
|
+
- - ">="
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '4.0'
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '5.0'
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: activerecord
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
|
-
- - "
|
85
|
+
- - ">="
|
74
86
|
- !ruby/object:Gem::Version
|
75
87
|
version: '4.0'
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '5.0'
|
76
91
|
type: :runtime
|
77
92
|
prerelease: false
|
78
93
|
version_requirements: !ruby/object:Gem::Requirement
|
79
94
|
requirements:
|
80
|
-
- - "
|
95
|
+
- - ">="
|
81
96
|
- !ruby/object:Gem::Version
|
82
97
|
version: '4.0'
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '5.0'
|
83
101
|
- !ruby/object:Gem::Dependency
|
84
102
|
name: activeresource
|
85
103
|
requirement: !ruby/object:Gem::Requirement
|
86
104
|
requirements:
|
87
|
-
- - "
|
105
|
+
- - ">="
|
88
106
|
- !ruby/object:Gem::Version
|
89
107
|
version: '4.0'
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.0'
|
90
111
|
type: :runtime
|
91
112
|
prerelease: false
|
92
113
|
version_requirements: !ruby/object:Gem::Requirement
|
93
114
|
requirements:
|
94
|
-
- - "
|
115
|
+
- - ">="
|
95
116
|
- !ruby/object:Gem::Version
|
96
117
|
version: '4.0'
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '5.0'
|
97
121
|
- !ruby/object:Gem::Dependency
|
98
122
|
name: thin
|
99
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +173,6 @@ files:
|
|
149
173
|
- features/step_definitions/doubles_steps.rb
|
150
174
|
- features/step_definitions/redirect_rules_steps.rb
|
151
175
|
- features/step_definitions/ruby_api_steps.rb
|
152
|
-
- features/step_definitions/support/numeric_transforms.rb
|
153
176
|
- features/support/env.rb
|
154
177
|
- features/support/world_helpers.rb
|
155
178
|
- features/web_ui/doubles.feature
|
@@ -223,7 +246,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
246
|
requirements:
|
224
247
|
- - ">="
|
225
248
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
249
|
+
version: 2.2.2
|
227
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
251
|
requirements:
|
229
252
|
- - ">="
|
@@ -263,7 +286,6 @@ test_files:
|
|
263
286
|
- features/step_definitions/doubles_steps.rb
|
264
287
|
- features/step_definitions/redirect_rules_steps.rb
|
265
288
|
- features/step_definitions/ruby_api_steps.rb
|
266
|
-
- features/step_definitions/support/numeric_transforms.rb
|
267
289
|
- features/support/env.rb
|
268
290
|
- features/support/world_helpers.rb
|
269
291
|
- features/web_ui/doubles.feature
|