rest-assured 2.0.0 → 2.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.markdown +12 -19
- data/db/development.db +0 -0
- data/db/test.db +0 -0
- data/features/ruby_api/test_server.feature +4 -4
- data/features/step_definitions/command_line_options_steps.rb +1 -1
- data/features/step_definitions/doubles_steps.rb +1 -1
- data/features/support/env.rb +3 -3
- data/features/support/world_helpers.rb +2 -8
- data/lib/rest-assured/api/app_session.rb +6 -1
- data/lib/rest-assured/api/server.rb +2 -14
- data/lib/rest-assured/config.rb +10 -3
- data/lib/rest-assured/models/double.rb +0 -2
- data/lib/rest-assured/models/redirect.rb +1 -3
- data/lib/rest-assured/routes/double.rb +2 -2
- data/lib/rest-assured/version.rb +1 -1
- data/spec/api/app_session_spec.rb +11 -5
- data/spec/api/resource_double_spec.rb +14 -13
- data/spec/api/server_spec.rb +38 -43
- data/spec/config_spec.rb +3 -3
- data/spec/functional/double_routes_spec.rb +53 -53
- data/spec/functional/redirect_routes_spec.rb +27 -27
- data/spec/functional/response_spec.rb +18 -18
- data/spec/models/double_spec.rb +22 -27
- data/spec/models/redirect_spec.rb +12 -15
- data/spec/models/request_spec.rb +4 -4
- data/spec/port_explorer_spec.rb +3 -3
- data/spec/spec_helper.rb +30 -22
- metadata +24 -37
- data/.gitignore +0 -9
- data/.rspec +0 -1
- data/.travis.yml +0 -15
- data/Gemfile +0 -36
- data/Gemfile.lock +0 -176
- data/Guardfile +0 -10
- data/Procfile +0 -1
- data/Rakefile +0 -2
- data/bin/console +0 -11
- data/bin/heroku_runner +0 -27
- data/cucumber.yml +0 -3
- data/features/support/test-server.rb +0 -35
- data/rest-assured.gemspec +0 -31
data/spec/models/double_spec.rb
CHANGED
@@ -12,35 +12,30 @@ module RestAssured::Models
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it { should allow_mass_assignment_of(:fullpath) }
|
19
|
-
it { should allow_mass_assignment_of(:content) }
|
20
|
-
it { should allow_mass_assignment_of(:verb) }
|
21
|
-
it { should allow_mass_assignment_of(:status) }
|
22
|
-
it { should allow_mass_assignment_of(:response_headers) }
|
15
|
+
it { is_expected.to validate_presence_of(:fullpath) }
|
16
|
+
it { is_expected.to validate_inclusion_of(:verb).in_array Double::VERBS }
|
17
|
+
it { is_expected.to validate_inclusion_of(:status).in_array Double::STATUSES }
|
23
18
|
|
24
|
-
it {
|
19
|
+
it { is_expected.to have_many(:requests) }
|
25
20
|
|
26
21
|
it 'creates double with valid params' do
|
27
22
|
d = Double.new valid_params
|
28
|
-
d.
|
23
|
+
expect(d).to be_valid
|
29
24
|
end
|
30
25
|
|
31
26
|
it "defaults verb to GET" do
|
32
27
|
f = Double.create valid_params.except(:verb)
|
33
|
-
f.verb.
|
28
|
+
expect(f.verb).to eq('GET')
|
34
29
|
end
|
35
30
|
|
36
31
|
it "defaults status to 200" do
|
37
32
|
f = Double.create valid_params.except(:status)
|
38
|
-
f.status.
|
33
|
+
expect(f.status).to eq(200)
|
39
34
|
end
|
40
35
|
|
41
36
|
it "makes double active by default" do
|
42
37
|
f = Double.create valid_params.except(:active)
|
43
|
-
f.active.
|
38
|
+
expect(f.active).to be true
|
44
39
|
end
|
45
40
|
|
46
41
|
describe 'when created' do
|
@@ -50,10 +45,10 @@ module RestAssured::Models
|
|
50
45
|
f3 = Double.create valid_params.merge(:fullpath => '/some/other/api')
|
51
46
|
f4 = Double.create valid_params.merge(:verb => 'POST')
|
52
47
|
|
53
|
-
f1.reload.active.
|
54
|
-
f2.reload.active.
|
55
|
-
f3.reload.active.
|
56
|
-
f4.reload.active.
|
48
|
+
expect(f1.reload.active).to be false
|
49
|
+
expect(f2.reload.active).to be true
|
50
|
+
expect(f3.reload.active).to be true
|
51
|
+
expect(f4.reload.active).to be true
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
@@ -67,9 +62,9 @@ module RestAssured::Models
|
|
67
62
|
f1.active = true
|
68
63
|
f1.save
|
69
64
|
|
70
|
-
f2.reload.active.
|
71
|
-
f3.reload.active.
|
72
|
-
f4.reload.active.
|
65
|
+
expect(f2.reload.active).to be false
|
66
|
+
expect(f3.reload.active).to be true
|
67
|
+
expect(f4.reload.active).to be true
|
73
68
|
end
|
74
69
|
|
75
70
|
it "makes other doubles inactive only when active bit set to true" do
|
@@ -81,17 +76,17 @@ module RestAssured::Models
|
|
81
76
|
f1.reload.save
|
82
77
|
f2.reload.save
|
83
78
|
|
84
|
-
f1.reload.active.
|
85
|
-
f2.reload.active.
|
86
|
-
f3.reload.active.
|
87
|
-
f4.reload.active.
|
79
|
+
expect(f1.reload.active).to be false
|
80
|
+
expect(f2.reload.active).to be true
|
81
|
+
expect(f3.reload.active).to be true
|
82
|
+
expect(f4.reload.active).to be true
|
88
83
|
end
|
89
84
|
|
90
85
|
it "handles long paths (more than 255 characters)" do
|
91
86
|
long_path = 'a' * 260
|
92
87
|
f1 = Double.create valid_params.merge(:fullpath => long_path)
|
93
88
|
f1.reload.save
|
94
|
-
f1.reload.fullpath.
|
89
|
+
expect(f1.reload.fullpath).to eq(long_path)
|
95
90
|
end
|
96
91
|
end
|
97
92
|
|
@@ -103,8 +98,8 @@ module RestAssured::Models
|
|
103
98
|
f3 = Double.create valid_params.merge(:fullpath => '/some/other/api')
|
104
99
|
|
105
100
|
f2.destroy
|
106
|
-
f1.reload.active.
|
107
|
-
f3.reload.active.
|
101
|
+
expect(f1.reload.active).to be true
|
102
|
+
expect(f3.reload.active).to be true
|
108
103
|
end
|
109
104
|
end
|
110
105
|
end
|
@@ -7,56 +7,53 @@ module RestAssured::Models
|
|
7
7
|
#Redirect.create :pattern => 'sdfsdf', :to => 'sdfsffdf'
|
8
8
|
#end
|
9
9
|
|
10
|
-
it {
|
11
|
-
it {
|
12
|
-
it { should allow_mass_assignment_of(:pattern) }
|
13
|
-
it { should allow_mass_assignment_of(:to) }
|
14
|
-
it { should allow_mass_assignment_of(:position) }
|
10
|
+
it { is_expected.to validate_presence_of(:pattern) }
|
11
|
+
it { is_expected.to validate_presence_of(:to) }
|
15
12
|
|
16
13
|
it 'assigns incremental position on create' do
|
17
14
|
r1 = Redirect.create :pattern => '.*', :to => 'someurl'
|
18
|
-
r1.position.
|
15
|
+
expect(r1.position).to eq(0)
|
19
16
|
|
20
17
|
r2 = Redirect.create :pattern => '.*', :to => 'someurl'
|
21
|
-
r2.position.
|
18
|
+
expect(r2.position).to eq(1)
|
22
19
|
|
23
20
|
r2.position = 4
|
24
21
|
r2.save
|
25
22
|
|
26
23
|
r3 = Redirect.create :pattern => '.*', :to => 'someurl'
|
27
|
-
r3.position.
|
24
|
+
expect(r3.position).to eq(5)
|
28
25
|
end
|
29
26
|
|
30
27
|
it 'updates order (with which redirects picked up for matching request)' do
|
31
28
|
r1 = Redirect.create :pattern => '.*', :to => 'somewhere', :position => 0
|
32
29
|
r2 = Redirect.create :pattern => '.*', :to => 'somewhere', :position => 1
|
33
30
|
|
34
|
-
Redirect.update_order([r2.id, r1.id]).
|
35
|
-
r1.reload.position.
|
36
|
-
r2.reload.position.
|
31
|
+
expect(Redirect.update_order([r2.id, r1.id])).to be true
|
32
|
+
expect(r1.reload.position).to eq(1)
|
33
|
+
expect(r2.reload.position).to eq(0)
|
37
34
|
|
38
|
-
Redirect.update_order([nil, 34]).
|
35
|
+
expect(Redirect.update_order([nil, 34])).to eq(false)
|
39
36
|
end
|
40
37
|
|
41
38
|
context 'redirect url' do
|
42
39
|
it 'constructs url to redirect to' do
|
43
40
|
path = rand(1000)
|
44
41
|
r = Redirect.create :pattern => '/api/(.*)\?.*', :to => 'http://external.com/some/url/\1?p=5'
|
45
|
-
Redirect.find_redirect_url_for("/api/#{path}?param=1").
|
42
|
+
expect(Redirect.find_redirect_url_for("/api/#{path}?param=1")).to eq("http://external.com/some/url/#{path}?p=5")
|
46
43
|
end
|
47
44
|
|
48
45
|
it 'returns the one that matches the substring' do
|
49
46
|
r1 = Redirect.create :pattern => '/ai/path', :to => 'someurl'
|
50
47
|
r2 = Redirect.create :pattern => '/api/path', :to => 'someurl'
|
51
48
|
|
52
|
-
Redirect.find_redirect_url_for('/api/path').
|
49
|
+
expect(Redirect.find_redirect_url_for('/api/path')).to eq('someurl')
|
53
50
|
end
|
54
51
|
|
55
52
|
it 'returns the oldest one that match' do
|
56
53
|
r1 = Redirect.create :pattern => '/api', :to => 'someurl'
|
57
54
|
r2 = Redirect.create :pattern => '/api/path', :to => 'otherurl'
|
58
55
|
|
59
|
-
Redirect.find_redirect_url_for('/api/path').
|
56
|
+
expect(Redirect.find_redirect_url_for('/api/path')).to eq('someurl/path')
|
60
57
|
end
|
61
58
|
end
|
62
59
|
end
|
data/spec/models/request_spec.rb
CHANGED
@@ -2,15 +2,15 @@ require File.expand_path('../../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module RestAssured::Models
|
4
4
|
describe Request do
|
5
|
-
it {
|
6
|
-
it {
|
5
|
+
it { is_expected.to belong_to(:double) }
|
6
|
+
it { is_expected.to validate_presence_of(:rack_env) }
|
7
7
|
|
8
8
|
it 'knows when it has been created' do
|
9
9
|
now = Time.now
|
10
|
-
Time.
|
10
|
+
allow(Time).to receive(:now).and_return(now)
|
11
11
|
r = Request.create(:body => 'sdfsd', :rack_env => 'headers')
|
12
12
|
|
13
|
-
r.created_at.
|
13
|
+
expect(r.created_at).to eq(now)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/spec/port_explorer_spec.rb
CHANGED
@@ -5,7 +5,7 @@ module RestAssured::Utils
|
|
5
5
|
describe PortExplorer do
|
6
6
|
it 'finds free tcp port' do
|
7
7
|
free_port = PortExplorer.free_port
|
8
|
-
|
8
|
+
expect { Net::HTTP.get('127.0.0.1', '/', free_port) }.to raise_error(Errno::ECONNREFUSED)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'knows if port is in use' do
|
@@ -20,13 +20,13 @@ module RestAssured::Utils
|
|
20
20
|
end
|
21
21
|
sleep 0.5
|
22
22
|
|
23
|
-
PortExplorer.port_free?(port).
|
23
|
+
expect(PortExplorer.port_free?(port)).to eq(false)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'knows that port is free' do
|
27
27
|
port = PortExplorer.free_port
|
28
28
|
|
29
|
-
PortExplorer.port_free?(port).
|
29
|
+
expect(PortExplorer.port_free?(port)).to eq(true)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
1
3
|
if ENV['COVERAGE']
|
2
4
|
begin
|
3
5
|
require 'simplecov'
|
@@ -15,13 +17,26 @@ $:.unshift(File.expand_path('../../lib'), __FILE__)
|
|
15
17
|
require 'rspec'
|
16
18
|
require 'capybara/rspec'
|
17
19
|
require 'rack/test'
|
18
|
-
require 'database_cleaner'
|
19
20
|
require 'awesome_print'
|
21
|
+
require 'rest-assured/config'
|
22
|
+
|
23
|
+
DB_OPTS = { :adapter => 'postgresql' }
|
24
|
+
RestAssured::Config.build(DB_OPTS)
|
25
|
+
|
26
|
+
require 'rest-assured'
|
27
|
+
require 'rest-assured/application'
|
28
|
+
require 'shoulda/matchers'
|
29
|
+
|
30
|
+
Capybara.app = RestAssured::Application
|
31
|
+
|
32
|
+
def app
|
33
|
+
RestAssured::Application
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'database_cleaner'
|
20
37
|
require File.expand_path('../support/custom_matchers', __FILE__)
|
21
38
|
require File.expand_path('../support/reset-singleton', __FILE__)
|
22
39
|
|
23
|
-
ENV['RACK_ENV'] = 'test'
|
24
|
-
|
25
40
|
module XhrHelpers
|
26
41
|
def xhr(path, params = {})
|
27
42
|
verb = params.delete(:as) || :get
|
@@ -35,12 +50,20 @@ RSpec.configure do |c|
|
|
35
50
|
c.include Rack::Test::Methods
|
36
51
|
c.include XhrHelpers
|
37
52
|
|
38
|
-
c.before(:
|
39
|
-
DatabaseCleaner.
|
53
|
+
c.before(:suite) do
|
54
|
+
DatabaseCleaner.strategy = :truncation
|
55
|
+
DatabaseCleaner.clean_with(:truncation)
|
40
56
|
end
|
41
57
|
|
42
|
-
c.
|
43
|
-
|
58
|
+
c.around(:each) do |example|
|
59
|
+
begin
|
60
|
+
DatabaseCleaner.cleaning do
|
61
|
+
example.run
|
62
|
+
end
|
63
|
+
rescue ActiveRecord::StatementInvalid
|
64
|
+
ActiveRecord::Base.connection.reconnect!
|
65
|
+
DatabaseCleaner.clean_with :truncation
|
66
|
+
end
|
44
67
|
end
|
45
68
|
|
46
69
|
c.before(:each, :ui => true) do
|
@@ -57,18 +80,3 @@ RSpec.configure do |c|
|
|
57
80
|
end
|
58
81
|
end
|
59
82
|
end
|
60
|
-
require 'rest-assured/config'
|
61
|
-
DB_OPTS = { :adapter => 'mysql' }
|
62
|
-
RestAssured::Config.build(DB_OPTS)
|
63
|
-
|
64
|
-
require 'rest-assured'
|
65
|
-
require 'rest-assured/application'
|
66
|
-
require 'shoulda-matchers'
|
67
|
-
|
68
|
-
Capybara.app = RestAssured::Application
|
69
|
-
|
70
|
-
def app
|
71
|
-
RestAssured::Application
|
72
|
-
end
|
73
|
-
|
74
|
-
DatabaseCleaner.strategy = :truncation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-assured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Avetisyan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activeresource
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '4.0'
|
90
90
|
type: :runtime
|
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: '
|
96
|
+
version: '4.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: thin
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,21 +116,11 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
- ".gitignore"
|
120
|
-
- ".rspec"
|
121
|
-
- ".travis.yml"
|
122
119
|
- CHANGELOG
|
123
|
-
- Gemfile
|
124
|
-
- Gemfile.lock
|
125
|
-
- Guardfile
|
126
120
|
- LICENSE
|
127
|
-
- Procfile
|
128
121
|
- README.markdown
|
129
|
-
- Rakefile
|
130
|
-
- bin/console
|
131
|
-
- bin/heroku_runner
|
132
122
|
- bin/rest-assured
|
133
|
-
-
|
123
|
+
- db/development.db
|
134
124
|
- db/migrate/20110620161740_add_fixtures.rb
|
135
125
|
- db/migrate/20110625155332_add_redirects_table.rb
|
136
126
|
- db/migrate/20110709150645_add_description_to_fixtures.rb
|
@@ -144,6 +134,7 @@ files:
|
|
144
134
|
- db/migrate/20111021113953_add_status_to_doubles.rb
|
145
135
|
- db/migrate/20111208155906_add_response_headers_to_doubles.rb
|
146
136
|
- db/migrate/20120320200820_change_fullpath_to_text.rb
|
137
|
+
- db/test.db
|
147
138
|
- features/command_line_options.feature
|
148
139
|
- features/rest_api/doubles.feature
|
149
140
|
- features/rest_api/redirects.feature
|
@@ -159,7 +150,6 @@ files:
|
|
159
150
|
- features/step_definitions/ruby_api_steps.rb
|
160
151
|
- features/step_definitions/support/numeric_transforms.rb
|
161
152
|
- features/support/env.rb
|
162
|
-
- features/support/test-server.rb
|
163
153
|
- features/support/world_helpers.rb
|
164
154
|
- features/web_ui/doubles.feature
|
165
155
|
- features/web_ui/redirects.feature
|
@@ -196,7 +186,6 @@ files:
|
|
196
186
|
- public/javascript/application.js
|
197
187
|
- public/javascript/jquery.jgrowl_minimized.js
|
198
188
|
- public/javascript/jquery.simulate.drag-sortable.js
|
199
|
-
- rest-assured.gemspec
|
200
189
|
- spec/api/app_session_spec.rb
|
201
190
|
- spec/api/resource_double_spec.rb
|
202
191
|
- spec/api/server_spec.rb
|
@@ -233,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
222
|
requirements:
|
234
223
|
- - ">="
|
235
224
|
- !ruby/object:Gem::Version
|
236
|
-
version: 1.
|
225
|
+
version: 1.9.3
|
237
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
227
|
requirements:
|
239
228
|
- - ">="
|
@@ -241,11 +230,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
230
|
version: '0'
|
242
231
|
requirements: []
|
243
232
|
rubyforge_project: rest-assured
|
244
|
-
rubygems_version: 2.
|
233
|
+
rubygems_version: 2.4.5
|
245
234
|
signing_key:
|
246
235
|
specification_version: 4
|
247
236
|
summary: Real stubs and spies for HTTP(S) services
|
248
237
|
test_files:
|
238
|
+
- spec/api/app_session_spec.rb
|
239
|
+
- spec/api/resource_double_spec.rb
|
240
|
+
- spec/api/server_spec.rb
|
241
|
+
- spec/config_spec.rb
|
242
|
+
- spec/functional/double_routes_spec.rb
|
243
|
+
- spec/functional/redirect_routes_spec.rb
|
244
|
+
- spec/functional/response_spec.rb
|
245
|
+
- spec/models/double_spec.rb
|
246
|
+
- spec/models/redirect_spec.rb
|
247
|
+
- spec/models/request_spec.rb
|
248
|
+
- spec/port_explorer_spec.rb
|
249
|
+
- spec/spec_helper.rb
|
250
|
+
- spec/support/custom_matchers.rb
|
251
|
+
- spec/support/reset-singleton.rb
|
249
252
|
- features/command_line_options.feature
|
250
253
|
- features/rest_api/doubles.feature
|
251
254
|
- features/rest_api/redirects.feature
|
@@ -261,22 +264,6 @@ test_files:
|
|
261
264
|
- features/step_definitions/ruby_api_steps.rb
|
262
265
|
- features/step_definitions/support/numeric_transforms.rb
|
263
266
|
- features/support/env.rb
|
264
|
-
- features/support/test-server.rb
|
265
267
|
- features/support/world_helpers.rb
|
266
268
|
- features/web_ui/doubles.feature
|
267
269
|
- features/web_ui/redirects.feature
|
268
|
-
- spec/api/app_session_spec.rb
|
269
|
-
- spec/api/resource_double_spec.rb
|
270
|
-
- spec/api/server_spec.rb
|
271
|
-
- spec/config_spec.rb
|
272
|
-
- spec/functional/double_routes_spec.rb
|
273
|
-
- spec/functional/redirect_routes_spec.rb
|
274
|
-
- spec/functional/response_spec.rb
|
275
|
-
- spec/models/double_spec.rb
|
276
|
-
- spec/models/redirect_spec.rb
|
277
|
-
- spec/models/request_spec.rb
|
278
|
-
- spec/port_explorer_spec.rb
|
279
|
-
- spec/spec_helper.rb
|
280
|
-
- spec/support/custom_matchers.rb
|
281
|
-
- spec/support/reset-singleton.rb
|
282
|
-
has_rdoc:
|