pretender-rails 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 +4 -4
- data/README.md +18 -0
- data/lib/pretender/rails/server.rb +8 -5
- data/lib/pretender/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ec1ff6ecb58d8f0818f17bdce6fa7be134b5568
|
4
|
+
data.tar.gz: ba026fc420d75d51ba17233335b43d3ebd2b663a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f99b2b324c8d48811266538409e748e664e6a7b1a8031c8287db7df899a744b0e6aea796fa99eb7329c93bc15349f0e1ee6a819b6313a1f0b83f9627d5e941b
|
7
|
+
data.tar.gz: ce84d57e34a62cb124b0e737590bb31a8379d55d8614a0fd2b557c35840d1a6785f252fed2a66a84656dfb644e668fefebaeeb406addee46cab3c2dace5ec171
|
data/README.md
CHANGED
@@ -20,6 +20,24 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
### Cucumber
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# features/support/env.rb
|
27
|
+
require 'pretender/rails/cucumber'
|
28
|
+
|
29
|
+
# features/step_definitions/pretender.rb
|
30
|
+
Given(/^there is a "(.*?)" endpoint$/) do |url|
|
31
|
+
@stub = stub("get", url, [200, {}, ""])
|
32
|
+
end
|
33
|
+
|
34
|
+
Given(/^that endpoint returns "(.*?)"$/) do |response|
|
35
|
+
@stub.response = [200, {}, response]
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
### In development
|
40
|
+
|
23
41
|
```ruby
|
24
42
|
Pretender.server.stub('get', 'https://api.github.com/repos/code0100fun/pretender-rails', [200, {}, {name: "mock-repo"}.to_json])
|
25
43
|
```
|
@@ -18,7 +18,10 @@ module Pretender
|
|
18
18
|
|
19
19
|
def shutdown(page)
|
20
20
|
stubs.clear
|
21
|
-
page.execute_script
|
21
|
+
if page.driver.browser.respond_to? :execute_script
|
22
|
+
page.execute_script('typeof(server) !== "undefined" && server.shutdown();')
|
23
|
+
end
|
24
|
+
rescue Capybara::NotSupportedByDriver => e
|
22
25
|
end
|
23
26
|
|
24
27
|
def stub(method, route, response)
|
@@ -62,10 +65,10 @@ module Pretender
|
|
62
65
|
<script>
|
63
66
|
var server = new Pretender(function(){
|
64
67
|
#{routes}
|
65
|
-
this.get('
|
66
|
-
this.post('
|
67
|
-
this.put('
|
68
|
-
this.delete('
|
68
|
+
this.get('/*any', this.passthrough);
|
69
|
+
this.post('/*any', this.passthrough);
|
70
|
+
this.put('/*any', this.passthrough);
|
71
|
+
this.delete('/*any', this.passthrough);
|
69
72
|
});
|
70
73
|
</script>
|
71
74
|
JS
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretender-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chase McCarthy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|