fakeapi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +17 -11
- data/lib/fakeapi/app.rb +7 -0
- data/lib/fakeapi/version.rb +1 -1
- metadata +27 -54
- data/examples/fake_bitly/vcr/shorten.yml +0 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e683c053ee843a38535ccaf8b223d04464e82e4
|
4
|
+
data.tar.gz: 051e33a9f45122a1c8ed9b4cfba914c907d36006
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4dd110be1de1e034608448fcb8244ae05c223421a308d56802b8720f0bbe9b95408be58484becc7a8907c0f65e2d5b0845fe6b73ac833b996a6f1fda9480019
|
7
|
+
data.tar.gz: 927cfae81baa0f447b7c193adcb2d68b6d33858eaa602ec9efb8a8bd48128f5c0b2c786e996658d841f47fcea8fcd00910bdb76599c9e8d961be0e6a401d6c1f
|
data/README.md
CHANGED
@@ -22,20 +22,22 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Let's say you're building FakeBitly service.
|
24
24
|
|
25
|
-
0
|
26
|
-
|
25
|
+
### Step 0: (Optional) Install newer webmock
|
26
|
+
|
27
|
+
Due to incompatibility between webmock and artifice you have to use
|
28
|
+
newer version of webmock:
|
27
29
|
|
28
30
|
```ruby
|
29
31
|
# Gemfile
|
30
32
|
source :rubygems
|
31
33
|
|
32
|
-
gem 'fakeapi'
|
34
|
+
gem 'fakeapi'
|
33
35
|
gem 'webmock', github: 'bblimke/webmock', ref: '2c596f'
|
34
36
|
gem 'rspec'
|
35
37
|
gem 'bitly'
|
36
38
|
```
|
37
39
|
|
38
|
-
1
|
40
|
+
### Step 1: Create fake service
|
39
41
|
|
40
42
|
```ruby
|
41
43
|
# fake_bitly.rb
|
@@ -45,10 +47,12 @@ class FakeBitly < FakeAPI::App
|
|
45
47
|
end
|
46
48
|
```
|
47
49
|
|
48
|
-
2
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
### Step 2: Create spec
|
51
|
+
|
52
|
+
You don't want to test FakeBitly endpoints directly.
|
53
|
+
Instead use a client library. `FakeBitly.test` (inherited from
|
54
|
+
`FakeAPI::App`) will try to use your fake service (using `Artifice`)
|
55
|
+
and if that fails it will record the HTTP interaction (using `VCR`).
|
52
56
|
|
53
57
|
```ruby
|
54
58
|
# fake_bitly_spec.rb
|
@@ -68,7 +72,7 @@ describe FakeBitly do
|
|
68
72
|
end
|
69
73
|
```
|
70
74
|
|
71
|
-
3
|
75
|
+
### Step 3: Run spec
|
72
76
|
|
73
77
|
```bash
|
74
78
|
% bundle exec rspec fake_bitly_spec.rb
|
@@ -92,10 +96,12 @@ Failures:
|
|
92
96
|
NotImplementedError
|
93
97
|
```
|
94
98
|
|
95
|
-
4
|
99
|
+
### Step 4: Use generated code:
|
96
100
|
|
97
101
|
```ruby
|
98
102
|
# fake_bitly.rb
|
103
|
+
require 'fakeapi'
|
104
|
+
|
99
105
|
class FakeBitly < FakeAPI::App
|
100
106
|
get '/v3/shorten' do
|
101
107
|
status 200
|
@@ -105,7 +111,7 @@ class FakeBitly < FakeAPI::App
|
|
105
111
|
end
|
106
112
|
```
|
107
113
|
|
108
|
-
5
|
114
|
+
### Step 5: Run spec
|
109
115
|
|
110
116
|
```bash
|
111
117
|
% bundle exec rspec fake_bitly_spec.rb
|
data/lib/fakeapi/app.rb
CHANGED
data/lib/fakeapi/version.rb
CHANGED
metadata
CHANGED
@@ -1,158 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakeapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Wojciech Mach
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: vcr
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: webmock
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: artifice
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: term-ansicolor
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: sinatra
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rspec
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: dotenv
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: bitly
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- -
|
129
|
+
- - ">="
|
148
130
|
- !ruby/object:Gem::Version
|
149
131
|
version: '0'
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- -
|
136
|
+
- - ">="
|
156
137
|
- !ruby/object:Gem::Version
|
157
138
|
version: '0'
|
158
139
|
description: FakeAPI o
|
@@ -162,8 +143,8 @@ executables: []
|
|
162
143
|
extensions: []
|
163
144
|
extra_rdoc_files: []
|
164
145
|
files:
|
165
|
-
- .gitignore
|
166
|
-
- .rspec
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
167
148
|
- Gemfile
|
168
149
|
- LICENSE
|
169
150
|
- README.md
|
@@ -175,7 +156,6 @@ files:
|
|
175
156
|
- examples/fake_bitly/config.ru
|
176
157
|
- examples/fake_bitly/lib/fake_bitly.rb
|
177
158
|
- examples/fake_bitly/spec/fake_bitly_spec.rb
|
178
|
-
- examples/fake_bitly/vcr/shorten.yml
|
179
159
|
- fakeapi.gemspec
|
180
160
|
- lib/fakeapi.rb
|
181
161
|
- lib/fakeapi/app.rb
|
@@ -188,33 +168,26 @@ files:
|
|
188
168
|
- spec/fakeapi/test_run_spec.rb
|
189
169
|
homepage: ''
|
190
170
|
licenses: []
|
171
|
+
metadata: {}
|
191
172
|
post_install_message:
|
192
173
|
rdoc_options: []
|
193
174
|
require_paths:
|
194
175
|
- lib
|
195
176
|
required_ruby_version: !ruby/object:Gem::Requirement
|
196
|
-
none: false
|
197
177
|
requirements:
|
198
|
-
- -
|
178
|
+
- - ">="
|
199
179
|
- !ruby/object:Gem::Version
|
200
180
|
version: '0'
|
201
|
-
segments:
|
202
|
-
- 0
|
203
|
-
hash: 3057897862326571822
|
204
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
-
none: false
|
206
182
|
requirements:
|
207
|
-
- -
|
183
|
+
- - ">="
|
208
184
|
- !ruby/object:Gem::Version
|
209
185
|
version: '0'
|
210
|
-
segments:
|
211
|
-
- 0
|
212
|
-
hash: 3057897862326571822
|
213
186
|
requirements: []
|
214
187
|
rubyforge_project:
|
215
|
-
rubygems_version:
|
188
|
+
rubygems_version: 2.2.2
|
216
189
|
signing_key:
|
217
|
-
specification_version:
|
190
|
+
specification_version: 4
|
218
191
|
summary: FakeAPI
|
219
192
|
test_files:
|
220
193
|
- spec/fakeapi/generator_spec.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: http://api.bit.ly/v3/shorten?apiKey=R_09c2f2080b43230744cbac384b7ce0ca&login=wojtekmach&longUrl=http://google.com
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers: {}
|
10
|
-
response:
|
11
|
-
status:
|
12
|
-
code: 200
|
13
|
-
message: OK
|
14
|
-
headers:
|
15
|
-
Server:
|
16
|
-
- nginx
|
17
|
-
Date:
|
18
|
-
- Sun, 27 Jan 2013 09:17:20 GMT
|
19
|
-
Content-Type:
|
20
|
-
- application/json; charset=utf-8
|
21
|
-
Connection:
|
22
|
-
- keep-alive
|
23
|
-
Mime-Version:
|
24
|
-
- '1.0'
|
25
|
-
Content-Length:
|
26
|
-
- '182'
|
27
|
-
body:
|
28
|
-
encoding: US-ASCII
|
29
|
-
string: ! '{ "status_code": 200, "status_txt": "OK", "data": { "long_url": "http:\/\/google.com\/",
|
30
|
-
"url": "http:\/\/bit.ly\/ORN1fW", "hash": "ORN1fW", "global_hash": "LmvF",
|
31
|
-
"new_hash": 0 } }
|
32
|
-
|
33
|
-
'
|
34
|
-
http_version:
|
35
|
-
recorded_at: Sun, 27 Jan 2013 09:17:20 GMT
|
36
|
-
recorded_with: VCR 2.4.0
|