http_sim 0.0.1 → 0.0.2
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/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.txt +2 -0
- data/README.md +23 -21
- data/Rakefile +3 -0
- data/example.rb +3 -1
- data/http_sim.gemspec +3 -2
- data/lib/http_sim.rb +3 -1
- data/lib/index.html.erb +44 -36
- data/lib/request.html.erb +24 -14
- data/lib/response.html.erb +13 -5
- data/spec/features/request_spec.rb +7 -0
- data/spec/spec_helper.rb +4 -0
- metadata +26 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40fc54a545f139236b562056d355c1f8898bbf6
|
4
|
+
data.tar.gz: 13bbe767fa4ef669f50cc3b36e7762bc23e159f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4398472b9e3756812169137b48cdd84d54ac06e24981fe12bd8f1c747ad117bca73ac653a8f9535b24b0afbdca7b418887e72da57f56b3ba7ae4a9d1d70d51dd
|
7
|
+
data.tar.gz: fd269b2b9e182435e3225599c447c83bbea1aed2a8ec8f03463c8036c8a1c3884d962b33b071714a94a1b8b72aff7fbce5ed2b33eee3d04bb0460032af7a55ed
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.txt
ADDED
data/README.md
CHANGED
@@ -1,31 +1,33 @@
|
|
1
|
-
#
|
1
|
+
# http_sim - Easy HTTP Simulators
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/jadekler/http_sim)
|
4
4
|
|
5
|
-
|
5
|
+
Simulate your external HTTP integrations.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'scaffold'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install scaffold
|
7
|
+
**Contributions and issues very welcome**.
|
20
8
|
|
21
9
|
## Usage
|
22
10
|
|
23
|
-
|
11
|
+
1. Add `gem 'http_sim'` to your `Gemfile`
|
12
|
+
1. `bundle install`
|
13
|
+
1. Use this code somewhere:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'http_sim'
|
17
|
+
|
18
|
+
HttpSimulator.register_endpoint 'GET', '/hi', read_file('fixtures/some_page.html')
|
19
|
+
HttpSimulator.register_endpoint 'POST', '/bye', read_file('fixtures/some_response.json')
|
20
|
+
HttpSimulator.run!(port:6565)
|
21
|
+
```
|
22
|
+
|
23
|
+
1. The endpoints `GET /hi` and `POST /bye` are now set up. Visit `http://localhost:6565/` to see an index of running simulators and their helpers.
|
24
24
|
|
25
25
|
## Contributing
|
26
26
|
|
27
27
|
1. Fork it ( https://github.com/[my-github-username]/scaffold/fork )
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
1. Please **add a test**
|
31
|
+
1. Run tests with `bundle install && rspec`
|
32
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
1. Create a new Pull Request
|
data/Rakefile
CHANGED
data/example.rb
CHANGED
data/http_sim.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'http_sim'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.2'
|
8
8
|
spec.authors = ['Jean de Klerk']
|
9
9
|
spec.email = ['jadekler@gmail.com']
|
10
10
|
spec.summary = 'Simulate your external HTTP integrations.'
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'sinatra', '~> 1.4'
|
20
|
+
spec.add_runtime_dependency 'sinatra', '~> 1.4.0'
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
end
|
data/lib/http_sim.rb
CHANGED
@@ -39,12 +39,14 @@ module HttpSimulator
|
|
39
39
|
}
|
40
40
|
@@endpoints = []
|
41
41
|
|
42
|
-
def self.run!
|
42
|
+
def self.run!(port: 4567)
|
43
43
|
Sinatra::Base.get '/' do
|
44
44
|
ERB.new(@@erb_files[:index]).result binding
|
45
45
|
end
|
46
46
|
|
47
47
|
Class.new(Sinatra::Base) {
|
48
|
+
set :port, port
|
49
|
+
|
48
50
|
include HttpSimulator
|
49
51
|
}.run!
|
50
52
|
end
|
data/lib/index.html.erb
CHANGED
@@ -1,40 +1,48 @@
|
|
1
1
|
<html>
|
2
|
-
<head>
|
3
|
-
|
4
|
-
body {
|
5
|
-
padding: 20px;
|
6
|
-
}
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
}
|
5
|
+
<!-- Optional theme -->
|
6
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
</
|
39
|
-
</
|
8
|
+
<!-- Latest compiled and minified JavaScript -->
|
9
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
10
|
+
|
11
|
+
<style>
|
12
|
+
body {
|
13
|
+
padding: 20px;
|
14
|
+
}
|
15
|
+
|
16
|
+
table {
|
17
|
+
border-collapse: collapse;
|
18
|
+
}
|
19
|
+
|
20
|
+
td, th {
|
21
|
+
padding: 10px;
|
22
|
+
text-align: left;
|
23
|
+
border: 1px solid gray;
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<h2>Simulators</h2>
|
29
|
+
<table>
|
30
|
+
<thead>
|
31
|
+
<tr>
|
32
|
+
<th>Simulated endpoint</th>
|
33
|
+
<th>Response</th>
|
34
|
+
<th>Requests</th>
|
35
|
+
</tr>
|
36
|
+
</thead>
|
37
|
+
<tbody>
|
38
|
+
<% @@endpoints.each do |endpoint| %>
|
39
|
+
<tr>
|
40
|
+
<td><%= endpoint.method %> <%= endpoint.path %></td>
|
41
|
+
<td><a href="<%= endpoint.path %>/response"><%= endpoint.path %>/response</a></td>
|
42
|
+
<td><a href="<%= endpoint.path %>/requests"><%= endpoint.path %>/requests</a></td>
|
43
|
+
</tr>
|
44
|
+
<% end %>
|
45
|
+
</tbody>
|
46
|
+
</table>
|
47
|
+
</body>
|
40
48
|
</html>
|
data/lib/request.html.erb
CHANGED
@@ -1,17 +1,27 @@
|
|
1
1
|
<html>
|
2
|
-
<head
|
3
|
-
<
|
4
|
-
<h2>Requests for: <%= endpoint.method %> <%= endpoint.path %></h2>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
<!-- Optional theme -->
|
6
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
|
7
|
+
|
8
|
+
<!-- Latest compiled and minified JavaScript -->
|
9
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h2>Requests for: <%= endpoint.method %> <%= endpoint.path %></h2>
|
13
|
+
|
14
|
+
<table>
|
15
|
+
<tbody>
|
16
|
+
<% endpoint.requests.each_with_index do |request, index| %>
|
17
|
+
<tr>
|
18
|
+
<td><%= index %>:</td>
|
19
|
+
<td>
|
20
|
+
<pre><%= request %></pre>
|
21
|
+
</td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</tbody>
|
25
|
+
</table>
|
26
|
+
</body>
|
17
27
|
</html>
|
data/lib/response.html.erb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
<html>
|
2
|
-
<head
|
3
|
-
<
|
4
|
-
<h2>Response for: <%= endpoint.method %> <%= endpoint.path %></h2>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
<!-- Optional theme -->
|
6
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
|
7
|
+
|
8
|
+
<!-- Latest compiled and minified JavaScript -->
|
9
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h2>Response for: <%= endpoint.method %> <%= endpoint.path %></h2>
|
13
|
+
|
14
|
+
<div>Response stuff goes here</div>
|
15
|
+
</body>
|
8
16
|
</html>
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_sim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean de Klerk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
55
69
|
description: A set of utilities for creating simulators for your external HTTP integrations,
|
56
70
|
great for acceptance tests and fallback services.
|
57
71
|
email:
|
@@ -62,6 +76,9 @@ extra_rdoc_files: []
|
|
62
76
|
files:
|
63
77
|
- ".gitignore"
|
64
78
|
- ".rbenv-gemsets"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- CHANGELOG.txt
|
65
82
|
- Gemfile
|
66
83
|
- LICENSE.txt
|
67
84
|
- README.md
|
@@ -72,6 +89,8 @@ files:
|
|
72
89
|
- lib/index.html.erb
|
73
90
|
- lib/request.html.erb
|
74
91
|
- lib/response.html.erb
|
92
|
+
- spec/features/request_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
75
94
|
homepage: http://github.com/jadekler/http_sim
|
76
95
|
licenses:
|
77
96
|
- MIT
|
@@ -96,4 +115,6 @@ rubygems_version: 2.4.5.1
|
|
96
115
|
signing_key:
|
97
116
|
specification_version: 4
|
98
117
|
summary: Simulate your external HTTP integrations.
|
99
|
-
test_files:
|
118
|
+
test_files:
|
119
|
+
- spec/features/request_spec.rb
|
120
|
+
- spec/spec_helper.rb
|