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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d34b11fafc50dc00080712a9a8486e65c8e3d1a
4
- data.tar.gz: bad07a227278bfefc44dcdd0599a5671a9970e99
3
+ metadata.gz: b40fc54a545f139236b562056d355c1f8898bbf6
4
+ data.tar.gz: 13bbe767fa4ef669f50cc3b36e7762bc23e159f0
5
5
  SHA512:
6
- metadata.gz: 0de209fcf1debc3225379e2443ee6dc91607cddd318a1cdb24ffe41928dc500cc7db114f5535f80e81bc0017ece02e81c5e7f66c254659f2c1d12eae99486fa2
7
- data.tar.gz: 1c412c2dc5197e70dbe0690c11ed5ac83ded8892493869e23a8526c7d39ab38ccab39d2ead6929312cb45084236dca12118144adbe97827937f967e7613b6b5f
6
+ metadata.gz: 4398472b9e3756812169137b48cdd84d54ac06e24981fe12bd8f1c747ad117bca73ac653a8f9535b24b0afbdca7b418887e72da57f56b3ba7ae4a9d1d70d51dd
7
+ data.tar.gz: fd269b2b9e182435e3225599c447c83bbea1aed2a8ec8f03463c8036c8a1c3884d962b33b071714a94a1b8b72aff7fbce5ed2b33eee3d04bb0460032af7a55ed
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
data/CHANGELOG.txt ADDED
@@ -0,0 +1,2 @@
1
+ Version 0.0.1 http_sim is released
2
+ Version 0.0.2 Allow changing port
data/README.md CHANGED
@@ -1,31 +1,33 @@
1
- # Scaffold
1
+ # http_sim - Easy HTTP Simulators
2
2
 
3
- TODO: Write a gem description
3
+ [![Build Status](https://travis-ci.org/jadekler/http_sim.svg?branch=master)](https://travis-ci.org/jadekler/http_sim)
4
4
 
5
- ## Installation
5
+ Simulate your external HTTP integrations.
6
6
 
7
- Add this line to your application's Gemfile:
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
- TODO: Write usage instructions here
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
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
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
@@ -1,2 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
+ task :default do
4
+ puts system('bundle exec rspec')
5
+ end
data/example.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # Run me with `ruby example.rb`
2
+
1
3
  require_relative 'lib/http_sim'
2
4
 
3
5
  HttpSimulator.register_endpoint 'GET', '/hi', 'yasssss'
4
6
  HttpSimulator.register_endpoint 'POST', '/bye', 'byeeeee'
5
- HttpSimulator.run!
7
+ HttpSimulator.run!(port: 6565)
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.1'
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
- <style>
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
- table {
9
- border-collapse: collapse;
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
- td, th {
13
- padding: 10px;
14
- text-align: left;
15
- border: 1px solid gray;
16
- }
17
- </style>
18
- </head>
19
- <body>
20
- <h2>Simulators</h2>
21
- <table>
22
- <thead>
23
- <tr>
24
- <th>Simulated endpoint</th>
25
- <th>Response</th>
26
- <th>Requests</th>
27
- </tr>
28
- </thead>
29
- <tbody>
30
- <% @@endpoints.each do |endpoint| %>
31
- <tr>
32
- <td><%= endpoint.method %> <%= endpoint.path %></td>
33
- <td><a href="<%= endpoint.path %>/response"><%= endpoint.path %>/response</a></td>
34
- <td><a href="<%= endpoint.path %>/requests"><%= endpoint.path %>/requests</a></td>
35
- </tr>
36
- <% end %>
37
- </tbody>
38
- </table>
39
- </body>
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></head>
3
- <body>
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
- <table>
7
- <tbody>
8
- <% endpoint.requests.each_with_index do |request, index| %>
9
- <tr>
10
- <td><%= index %>:</td>
11
- <td><pre><%= request %></pre></td>
12
- </tr>
13
- <% end %>
14
- </tbody>
15
- </table>
16
- </body>
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>
@@ -1,8 +1,16 @@
1
1
  <html>
2
- <head></head>
3
- <body>
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
- <div>Response stuff goes here</div>
7
- </body>
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>
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'request' do
4
+ it 'works' do
5
+ expect(true).to eq true
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |c|
2
+ c.order = :random
3
+ c.default_formatter = 'doc'
4
+ end
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.1
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-03-16 00:00:00.000000000 Z
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: '1.4'
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: '1.4'
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