rest-assured 0.2.0.rc8 → 0.2.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.
- data/Gemfile.lock +2 -2
- data/LICENSE +4 -19
- data/README.markdown +123 -36
- data/bin/console +1 -2
- data/bin/rest-assured +12 -0
- data/features/command_line_options.feature +20 -1
- data/features/{doubles_via_api.feature → rest_api/doubles.feature} +0 -0
- data/features/{redirect_rules_via_api.feature → rest_api/redirects.feature} +11 -8
- data/features/{call_history.feature → ruby_api/verify_requests.feature} +0 -0
- data/features/ruby_api/wait_for_requests.feature +39 -0
- data/features/step_definitions/command_line_options_steps.rb +12 -0
- data/features/step_definitions/doubles_steps.rb +10 -10
- data/features/step_definitions/redirect_rules_steps.rb +24 -5
- data/features/step_definitions/ruby_api_steps.rb +69 -0
- data/features/support/env.rb +3 -1
- data/features/{doubles_via_ui.feature → web_ui/doubles.feature} +0 -0
- data/features/{redirect_rules_via_ui.feature → web_ui/redirects.feature} +0 -0
- data/lib/rest-assured.rb +2 -1
- data/lib/rest-assured/client/resources.rb +12 -2
- data/lib/rest-assured/config.rb +24 -0
- data/lib/rest-assured/models/double.rb +32 -28
- data/lib/rest-assured/models/redirect.rb +28 -24
- data/lib/rest-assured/models/request.rb +11 -7
- data/lib/rest-assured/routes/double.rb +8 -8
- data/lib/rest-assured/routes/redirect.rb +8 -8
- data/lib/rest-assured/routes/response.rb +16 -14
- data/lib/rest-assured/version.rb +1 -1
- data/lib/sinatra/handler_options_patch.rb +25 -0
- data/spec/client/resource_double_spec.rb +42 -6
- data/spec/config_spec.rb +35 -0
- data/spec/functional/double_routes_spec.rb +109 -107
- data/spec/functional/redirect_routes_spec.rb +86 -75
- data/spec/functional/response_spec.rb +57 -55
- data/spec/models/double_spec.rb +67 -65
- data/spec/models/redirect_spec.rb +28 -26
- data/spec/models/request_spec.rb +10 -8
- data/ssl/localhost.crt +14 -0
- data/ssl/localhost.key +15 -0
- metadata +25 -24
- data/features/step_definitions/call_history_steps.rb +0 -24
@@ -1,39 +1,41 @@
|
|
1
1
|
require File.expand_path('../../spec_helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module RestAssured::Models
|
4
|
+
describe Redirect do
|
5
|
+
# this is solely to get through 'Can't find first XXX' shoulda crap
|
6
|
+
#before do
|
6
7
|
#Redirect.create :pattern => 'sdfsdf', :to => 'sdfsffdf'
|
7
|
-
|
8
|
+
#end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
it { should validate_presence_of(:pattern) }
|
11
|
+
it { should validate_presence_of(:to) }
|
12
|
+
it { should allow_mass_assignment_of(:pattern) }
|
13
|
+
it { should allow_mass_assignment_of(:to) }
|
14
|
+
it { should allow_mass_assignment_of(:position) }
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
it 'assigns incremental position on create' do
|
17
|
+
r1 = Redirect.create :pattern => '.*', :to => 'someurl'
|
18
|
+
r1.position.should == 0
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
r2 = Redirect.create :pattern => '.*', :to => 'someurl'
|
21
|
+
r2.position.should == 1
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
r2.position = 4
|
24
|
+
r2.save
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
r3 = Redirect.create :pattern => '.*', :to => 'someurl'
|
27
|
+
r3.position.should == 5
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
it 'updates order (with which redirects picked up for matching request)' do
|
31
|
+
r1 = Redirect.create :pattern => '.*', :to => 'somewhere', :position => 0
|
32
|
+
r2 = Redirect.create :pattern => '.*', :to => 'somewhere', :position => 1
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
Redirect.update_order([r2.id, r1.id]).should be true
|
35
|
+
r1.reload.position.should == 1
|
36
|
+
r2.reload.position.should == 0
|
36
37
|
|
37
|
-
|
38
|
+
Redirect.update_order([nil, 34]).should == false
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
data/spec/models/request_spec.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require File.expand_path('../../spec_helper', __FILE__)
|
2
2
|
require 'rest-assured/models/request'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module RestAssured::Models
|
5
|
+
describe Request do
|
6
|
+
it { should belong_to(:double) }
|
7
|
+
it { should validate_presence_of(:rack_env) }
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
it 'knows when it has been created' do
|
10
|
+
now = Time.now
|
11
|
+
Time.stub(:now).and_return(now)
|
12
|
+
r = Request.create(:body => 'sdfsd', :rack_env => 'headers')
|
12
13
|
|
13
|
-
|
14
|
+
r.created_at.should == now
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
data/ssl/localhost.crt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIICKTCCAZICCQDCY/yokcLRgTANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJV
|
3
|
+
SzETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
|
4
|
+
cyBQdHkgTHRkMRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTExMTEwMTUzMTM0WhcN
|
5
|
+
MzkwMzI4MTUzMTM0WjBZMQswCQYDVQQGEwJVSzETMBEGA1UECBMKU29tZS1TdGF0
|
6
|
+
ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRIwEAYDVQQDEwls
|
7
|
+
b2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMhGqUPAvhEHTrhX
|
8
|
+
iSdEZjaajuz3H4x/VaVGf7pPitk6JRSO4z7vcEoc9roaUn+9E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JlWChOThrd3mvc92m/VPkCQFHKL/1G1sTV48jv1t0tdnZJuwiz
|
11
|
+
R9z/pROPhw23P0PRhEJawSsUuJiDfKph12R42Df0sqwKq57A/6eZG+sQu9MCQHgn
|
12
|
+
uNySynlJE28U8VH3NldogxiZTriJFMUw1QXu9tO8MtztqLrtC6VME085NLGDIV/6
|
13
|
+
rUZvK40k3xa/abppQvkCQQCnJEZ/9ofxvdTHrDzvnkHy3ki+Bfre8/yAK94NAcL0
|
14
|
+
FaMkgFmGTSEAMMl8RipzuGE6BZVNNruvlsyhoyN3uop2
|
15
|
+
-----END RSA PRIVATE KEY-----
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-assured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 8
|
12
|
-
version: 0.2.0.rc8
|
10
|
+
version: 0.2.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Artem Avetisyan
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-14 00:00:00 Z
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
23
21
|
name: sinatra
|
@@ -130,21 +128,22 @@ files:
|
|
130
128
|
- db/migrate/20111013122857_create_requests.rb
|
131
129
|
- db/migrate/20111016174101_rename_method_to_verb.rb
|
132
130
|
- db/migrate/20111021113953_add_status_to_doubles.rb
|
133
|
-
- features/call_history.feature
|
134
131
|
- features/command_line_options.feature
|
135
|
-
- features/
|
136
|
-
- features/
|
137
|
-
- features/
|
138
|
-
- features/
|
139
|
-
- features/step_definitions/call_history_steps.rb
|
132
|
+
- features/rest_api/doubles.feature
|
133
|
+
- features/rest_api/redirects.feature
|
134
|
+
- features/ruby_api/verify_requests.feature
|
135
|
+
- features/ruby_api/wait_for_requests.feature
|
140
136
|
- features/step_definitions/command_line_options_steps.rb
|
141
137
|
- features/step_definitions/doubles_steps.rb
|
142
138
|
- features/step_definitions/redirect_rules_steps.rb
|
139
|
+
- features/step_definitions/ruby_api_steps.rb
|
143
140
|
- features/step_definitions/support/numeric_transforms.rb
|
144
141
|
- features/support/env.rb
|
145
142
|
- features/support/selenium-fix.rb
|
146
143
|
- features/support/test-server.rb
|
147
144
|
- features/support/world_helpers.rb
|
145
|
+
- features/web_ui/doubles.feature
|
146
|
+
- features/web_ui/redirects.feature
|
148
147
|
- lib/active_record/leaky_connections_patch.rb
|
149
148
|
- lib/rest-assured.rb
|
150
149
|
- lib/rest-assured/client.rb
|
@@ -157,6 +156,7 @@ files:
|
|
157
156
|
- lib/rest-assured/routes/redirect.rb
|
158
157
|
- lib/rest-assured/routes/response.rb
|
159
158
|
- lib/rest-assured/version.rb
|
159
|
+
- lib/sinatra/handler_options_patch.rb
|
160
160
|
- lib/sinatra/partials.rb
|
161
161
|
- public/css/base.css
|
162
162
|
- public/css/grid.inuit.css
|
@@ -185,6 +185,8 @@ files:
|
|
185
185
|
- spec/models/redirect_spec.rb
|
186
186
|
- spec/models/request_spec.rb
|
187
187
|
- spec/spec_helper.rb
|
188
|
+
- ssl/localhost.crt
|
189
|
+
- ssl/localhost.key
|
188
190
|
- views/doubles/_form.haml
|
189
191
|
- views/doubles/edit.haml
|
190
192
|
- views/doubles/index.haml
|
@@ -216,14 +218,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
219
|
none: false
|
218
220
|
requirements:
|
219
|
-
- - "
|
221
|
+
- - ">="
|
220
222
|
- !ruby/object:Gem::Version
|
221
|
-
hash:
|
223
|
+
hash: 3
|
222
224
|
segments:
|
223
|
-
-
|
224
|
-
|
225
|
-
- 1
|
226
|
-
version: 1.3.1
|
225
|
+
- 0
|
226
|
+
version: "0"
|
227
227
|
requirements: []
|
228
228
|
|
229
229
|
rubyforge_project: rest-assured
|
@@ -232,21 +232,22 @@ signing_key:
|
|
232
232
|
specification_version: 3
|
233
233
|
summary: A tool for high level mocking/stubbing HTTP based REST services
|
234
234
|
test_files:
|
235
|
-
- features/call_history.feature
|
236
235
|
- features/command_line_options.feature
|
237
|
-
- features/
|
238
|
-
- features/
|
239
|
-
- features/
|
240
|
-
- features/
|
241
|
-
- features/step_definitions/call_history_steps.rb
|
236
|
+
- features/rest_api/doubles.feature
|
237
|
+
- features/rest_api/redirects.feature
|
238
|
+
- features/ruby_api/verify_requests.feature
|
239
|
+
- features/ruby_api/wait_for_requests.feature
|
242
240
|
- features/step_definitions/command_line_options_steps.rb
|
243
241
|
- features/step_definitions/doubles_steps.rb
|
244
242
|
- features/step_definitions/redirect_rules_steps.rb
|
243
|
+
- features/step_definitions/ruby_api_steps.rb
|
245
244
|
- features/step_definitions/support/numeric_transforms.rb
|
246
245
|
- features/support/env.rb
|
247
246
|
- features/support/selenium-fix.rb
|
248
247
|
- features/support/test-server.rb
|
249
248
|
- features/support/world_helpers.rb
|
249
|
+
- features/web_ui/doubles.feature
|
250
|
+
- features/web_ui/redirects.feature
|
250
251
|
- spec/client/resource_double_spec.rb
|
251
252
|
- spec/config_spec.rb
|
252
253
|
- spec/custom_matchers.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Given /^there is a double$/ do
|
2
|
-
@double = RestAssured::Client::Double.create(:fullpath => '/some/path', :content => 'some content', :verb => 'POST')
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^that double gets requested$/ do
|
6
|
-
post @double.fullpath, { :foo => 'bar' }.to_json, "CONTENT_TYPE" => "application/json"
|
7
|
-
post @double.fullpath, { :fooz => 'baaz'}, 'SOME_HEADER' => 'header_data'
|
8
|
-
end
|
9
|
-
|
10
|
-
When /^I request call history for that double$/ do
|
11
|
-
@requests = @double.reload.requests
|
12
|
-
end
|
13
|
-
|
14
|
-
Then /^I should see history records for those requests$/ do
|
15
|
-
@requests.first.body.should == { :foo => 'bar' }.to_json
|
16
|
-
JSON.parse( @requests.first.rack_env )["CONTENT_TYPE"].should == 'application/json'
|
17
|
-
|
18
|
-
JSON.parse( @requests.last.params ).should == { 'fooz' => 'baaz' }
|
19
|
-
JSON.parse( @requests.last.rack_env )["SOME_HEADER"].should == 'header_data'
|
20
|
-
end
|
21
|
-
|
22
|
-
Then /^it should be empty$/ do
|
23
|
-
@requests.size.should == 0
|
24
|
-
end
|