rest-assured 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +34 -26
- data/lib/rest-assured/routes/double.rb +6 -2
- data/lib/rest-assured/version.rb +1 -1
- metadata +14 -17
data/README.markdown
CHANGED
@@ -12,12 +12,32 @@ In a nutshell, here is how you can use it:
|
|
12
12
|
* verify requests to external services (spying)
|
13
13
|
* simulate different behavior of external services using web UI; useful in development
|
14
14
|
|
15
|
+
Here is how it works. REST-assured starts a webapp that can be instructed (via ruby client library or plain REST api) to respond to any request in any way. You configure api endpoints of the application under test to point to that webapp instead of real dependencies. Then in your tests create doubles to match whatever the app is supposed to be requesting. Double is more than just a data stub, it also keeps track of its request history. So that it can be verified.
|
16
|
+
|
15
17
|
Check out [example](https://github.com/artemave/REST-assured-example)
|
16
18
|
|
17
19
|
|
18
|
-
##
|
20
|
+
## Set up
|
21
|
+
|
22
|
+
You are going to need ruby >= 1.8.7 on Linux/MacOS. Also, either sqlite3, postgres or mysql is required.
|
23
|
+
|
24
|
+
### Ruby Client
|
19
25
|
|
20
|
-
|
26
|
+
```ruby
|
27
|
+
# Gemfile
|
28
|
+
gem 'sqlite3' # or mysql2 or pg
|
29
|
+
gem 'thin' # make it quick; optional
|
30
|
+
gem 'rest-assured'
|
31
|
+
|
32
|
+
# env.rb/spec_helper.rb
|
33
|
+
require 'rest-assured'
|
34
|
+
|
35
|
+
RestAssured::Server.start(database: ':memory:', port: 7899) # or any other option available on command line
|
36
|
+
# Alternatively, if you want to use existing server instance:
|
37
|
+
RestAssured::Server.address = 'http://localhost:4578' # or wherever it is
|
38
|
+
```
|
39
|
+
|
40
|
+
### Standalone instance
|
21
41
|
|
22
42
|
Rest-assured requires a database to run. Either sqlite, mysql or postgres. So, make sure there is one and its backed with corresponding client gem:
|
23
43
|
|
@@ -37,7 +57,7 @@ Then install gem and run:
|
|
37
57
|
Or clone and run:
|
38
58
|
|
39
59
|
bash$ git clone git://github.com/BBC/REST-assured.git
|
40
|
-
bash$ cd
|
60
|
+
bash$ cd REST-assured && bundle install
|
41
61
|
bash$ ./bin/rest-assured -d :memory: & # in-memory sqlite db
|
42
62
|
|
43
63
|
This starts up an instance of rest-assured on port 4578. It is accessible via REST or web interfaces on `http://localhost:4578`
|
@@ -47,7 +67,7 @@ Various options (such as ssl, port, db credentials, etc.) are available through
|
|
47
67
|
You can also deploy it to heroku:
|
48
68
|
|
49
69
|
bash$ git clone git://github.com/BBC/REST-assured.git
|
50
|
-
bash$ cd
|
70
|
+
bash$ cd REST-assured
|
51
71
|
|
52
72
|
bash$ gem install heroku
|
53
73
|
bash$ heroku login # assuming you already have an account
|
@@ -55,31 +75,15 @@ You can also deploy it to heroku:
|
|
55
75
|
|
56
76
|
bash$ git push heroku master
|
57
77
|
|
58
|
-
##
|
59
|
-
|
60
|
-
Double is a stub/spy of HTTP request. Create a double that has the same request fullpath and method as the one your app is sending to a dependant service and then convience your app that rest-assured is that dependency (hint: by making endpoints configurable).
|
61
|
-
|
62
|
-
### Ruby Client API
|
63
|
-
|
64
|
-
Rest-assured provides client library to work with doubles. Check out 'Ruby API' section in [live documentation](https://www.relishapp.com/artemave/rest-assured) for full reference.
|
78
|
+
## Usage
|
65
79
|
|
66
|
-
|
80
|
+
REST-assured is all about doubles. Double is a stub/spy of HTTP request. Create one that has the same request fullpath and method as the one your app is sending to a dependant service and then convience your app that REST-assured is that dependency (hint: by making endpoints configurable).
|
67
81
|
|
68
|
-
|
69
|
-
# env.rb/spec_helper.rb
|
70
|
-
require 'rest-assured'
|
82
|
+
### Ruby Client
|
71
83
|
|
72
|
-
|
73
|
-
```
|
74
|
-
This server will be automatically shut down when your tests are done.
|
84
|
+
REST-assured provides client library to work with doubles. Check out 'Ruby API' section in [live documentation](https://www.relishapp.com/artemave/rest-assured) for full reference.
|
75
85
|
|
76
|
-
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
RestAssured::Server.address = 'http://localhost:4578' # or wherever it is
|
80
|
-
```
|
81
|
-
|
82
|
-
You can now create doubles in your tests:
|
86
|
+
Create double:
|
83
87
|
|
84
88
|
```ruby
|
85
89
|
RestAssured::Double.create(fullpath: '/products', content: 'this is content')
|
@@ -116,7 +120,7 @@ RestClient.delete "#{RestAssured::Server.address}/doubles/all"
|
|
116
120
|
|
117
121
|
### Plain REST API
|
118
122
|
|
119
|
-
For those using
|
123
|
+
For those using REST-assured from non-ruby environments.
|
120
124
|
|
121
125
|
#### Create double
|
122
126
|
|
@@ -224,6 +228,10 @@ Tests require there to be mysql database `rest_assured_test` accessible by `root
|
|
224
228
|
|
225
229
|
## Changelog
|
226
230
|
|
231
|
+
#### 1.1.3 (21 Mar 2012)
|
232
|
+
|
233
|
+
* support long (>256 chars) fullpath
|
234
|
+
|
227
235
|
#### 1.1.2 (04 Mar 2012)
|
228
236
|
|
229
237
|
* support postgres
|
@@ -14,9 +14,13 @@ module RestAssured
|
|
14
14
|
redirect to('/doubles')
|
15
15
|
end
|
16
16
|
|
17
|
-
router.get
|
17
|
+
router.get %r{^/doubles(\.json)?$} do |is_json|
|
18
18
|
@doubles = Models::Double.all
|
19
|
-
|
19
|
+
if not is_json
|
20
|
+
haml :'doubles/index'
|
21
|
+
else
|
22
|
+
body @doubles.to_json
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
router.get '/doubles/new' do
|
data/lib/rest-assured/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-assured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157502440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.3.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157502440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: childprocess
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157501740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.3.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157501740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sinatra-flash
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157501360 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157501360
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: haml
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157500820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 3.1.3
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157500820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activerecord
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157500320 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 3.2.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157500320
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activeresource
|
71
|
-
requirement: &
|
71
|
+
requirement: &2157499860 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: 3.2.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2157499860
|
80
80
|
description:
|
81
81
|
email:
|
82
82
|
- artem.avetisyan@bbc.co.uk
|
@@ -208,9 +208,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
208
|
- - ! '>='
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
|
-
segments:
|
212
|
-
- 0
|
213
|
-
hash: 100501931747818753
|
214
211
|
requirements: []
|
215
212
|
rubyforge_project: rest-assured
|
216
213
|
rubygems_version: 1.8.10
|