rack-mock_json 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/example/rails-example/.gitignore +13 -0
- data/example/rails-example/Gemfile +45 -0
- data/example/rails-example/README.rdoc +28 -0
- data/example/rails-example/Rakefile +6 -0
- data/example/rails-example/app/assets/images/.keep +0 -0
- data/example/rails-example/app/assets/javascripts/application.js +16 -0
- data/example/rails-example/app/assets/stylesheets/application.css +15 -0
- data/example/rails-example/app/controllers/application_controller.rb +5 -0
- data/example/rails-example/app/controllers/concerns/.keep +0 -0
- data/example/rails-example/app/helpers/application_helper.rb +2 -0
- data/example/rails-example/app/mailers/.keep +0 -0
- data/example/rails-example/app/models/.keep +0 -0
- data/example/rails-example/app/models/concerns/.keep +0 -0
- data/example/rails-example/app/views/layouts/application.html.erb +14 -0
- data/example/rails-example/bin/bundle +3 -0
- data/example/rails-example/bin/rails +4 -0
- data/example/rails-example/bin/rake +4 -0
- data/example/rails-example/bin/setup +29 -0
- data/example/rails-example/config.ru +4 -0
- data/example/rails-example/config/application.rb +26 -0
- data/example/rails-example/config/boot.rb +3 -0
- data/example/rails-example/config/database.yml +54 -0
- data/example/rails-example/config/environment.rb +5 -0
- data/example/rails-example/config/environments/development.rb +43 -0
- data/example/rails-example/config/environments/production.rb +79 -0
- data/example/rails-example/config/environments/test.rb +42 -0
- data/example/rails-example/config/initializers/assets.rb +11 -0
- data/example/rails-example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails-example/config/initializers/cookies_serializer.rb +3 -0
- data/example/rails-example/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails-example/config/initializers/inflections.rb +16 -0
- data/example/rails-example/config/initializers/mime_types.rb +4 -0
- data/example/rails-example/config/initializers/session_store.rb +3 -0
- data/example/rails-example/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails-example/config/locales/en.yml +23 -0
- data/example/rails-example/config/mock_json.yml +5 -0
- data/example/rails-example/config/routes.rb +56 -0
- data/example/rails-example/config/secrets.yml +22 -0
- data/example/rails-example/db/seeds.rb +7 -0
- data/example/rails-example/lib/assets/.keep +0 -0
- data/example/rails-example/lib/tasks/.keep +0 -0
- data/example/rails-example/log/.keep +0 -0
- data/example/rails-example/public/404.html +67 -0
- data/example/rails-example/public/422.html +67 -0
- data/example/rails-example/public/500.html +66 -0
- data/example/rails-example/public/favicon.ico +0 -0
- data/example/rails-example/public/robots.txt +5 -0
- data/example/rails-example/test/controllers/.keep +0 -0
- data/example/rails-example/test/fixtures/.keep +0 -0
- data/example/rails-example/test/helpers/.keep +0 -0
- data/example/rails-example/test/integration/.keep +0 -0
- data/example/rails-example/test/mailers/.keep +0 -0
- data/example/rails-example/test/models/.keep +0 -0
- data/example/rails-example/test/test_helper.rb +10 -0
- data/example/rails-example/vendor/assets/javascripts/.keep +0 -0
- data/example/rails-example/vendor/assets/stylesheets/.keep +0 -0
- data/lib/rack-mock_json.rb +1 -0
- data/lib/rack/mock_json.rb +9 -0
- data/lib/rack/mock_json/mock.rb +18 -0
- data/lib/rack/mock_json/request_handler.rb +43 -0
- data/lib/rack/mock_json/version.rb +5 -0
- data/rack-mock_json.gemspec +27 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3acdb8bd831b25c12a19794312572a86a08000a
|
4
|
+
data.tar.gz: 0676acd9b1ecc26290a647d1cddcdaf7733b84ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b71d2fb3c36c416b3556b59073f4c066fc5c163325382375db1a25f8654a19c8986e4fd0c8b715e38eed5ac22601217e37022e22c1a798fb337c092b79c02d75
|
7
|
+
data.tar.gz: 90637fbf141d5b930d89a71bb0053daf874bf30e8c56b4cd745c78333a9bce277282f3395165bf0239a3ee754297918b434b8c5303174b4fcd55e4e0315a019d
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 fukuiretu
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
rack-mock_json
|
2
|
+
====================
|
3
|
+
|
4
|
+
## Overview
|
5
|
+
`rack-mock_json` is for any request in the rack layer, returns any json response(Content-Type: application/json) and http status.
|
6
|
+
|
7
|
+
Setting it defined in `yaml`.
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'rack-mock_json'
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Rails
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Rails.application.configure do
|
27
|
+
# ...
|
28
|
+
config.middleware.use Rack::MockJson::RequestHandler, config_file_path: "#{config.root}/config/mock_json.yml"
|
29
|
+
end
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
[Examples For more information, click here](example/rails-example/config/environments/development.rb)
|
34
|
+
|
35
|
+
### Config
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
- :request_path: 'GET /hoge/.*/foo'
|
39
|
+
:content: '{ "hoge": "foo", "bar" : "fuga" }'
|
40
|
+
- :request_path: 'POST /user'
|
41
|
+
:status: 201
|
42
|
+
:content: '{ "name": "taro", "age" : 17 }'
|
43
|
+
```
|
44
|
+
|
45
|
+
[Examples For more information, click here](example/rails-example/config/mock_json.yml)
|
46
|
+
|
47
|
+
| Propety | Required | Default |
|
48
|
+
| :------------- | :------------| :-----------|
|
49
|
+
| request_path | ○ | - |
|
50
|
+
| status | × | 200 |
|
51
|
+
| content | ○ | - |
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
## Future
|
56
|
+
- randomly pick the content you specify multiple.
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
## ToDo
|
61
|
+
- spec & CI
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rack/mock_json"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all logfiles and tempfiles.
|
11
|
+
/log/*
|
12
|
+
!/log/.keep
|
13
|
+
/tmp
|
@@ -0,0 +1,45 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
|
4
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'rails', '4.2.3'
|
6
|
+
# Use mysql as the database for Active Record
|
7
|
+
gem 'mysql2'
|
8
|
+
# Use SCSS for stylesheets
|
9
|
+
gem 'sass-rails', '~> 5.0'
|
10
|
+
# Use Uglifier as compressor for JavaScript assets
|
11
|
+
gem 'uglifier', '>= 1.3.0'
|
12
|
+
# Use CoffeeScript for .coffee assets and views
|
13
|
+
gem 'coffee-rails', '~> 4.1.0'
|
14
|
+
# See https://github.com/rails/execjs#readme for more supported runtimes
|
15
|
+
# gem 'therubyracer', platforms: :ruby
|
16
|
+
|
17
|
+
# Use jquery as the JavaScript library
|
18
|
+
gem 'jquery-rails'
|
19
|
+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
20
|
+
gem 'turbolinks'
|
21
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
22
|
+
gem 'jbuilder', '~> 2.0'
|
23
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
24
|
+
gem 'sdoc', '~> 0.4.0', group: :doc
|
25
|
+
|
26
|
+
# Use ActiveModel has_secure_password
|
27
|
+
# gem 'bcrypt', '~> 3.1.7'
|
28
|
+
|
29
|
+
# Use Unicorn as the app server
|
30
|
+
# gem 'unicorn'
|
31
|
+
|
32
|
+
# Use Capistrano for deployment
|
33
|
+
# gem 'capistrano-rails', group: :development
|
34
|
+
|
35
|
+
group :development, :test do
|
36
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
37
|
+
gem 'byebug'
|
38
|
+
|
39
|
+
# Access an IRB console on exception pages or by using <%= console %> in views
|
40
|
+
gem 'web-console', '~> 2.0'
|
41
|
+
|
42
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
43
|
+
gem 'spring'
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require turbolinks
|
16
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RailsExample</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(*Rails.groups)
|
8
|
+
|
9
|
+
module RailsExample
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
16
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
17
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
18
|
+
|
19
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
20
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
21
|
+
# config.i18n.default_locale = :de
|
22
|
+
|
23
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
24
|
+
config.active_record.raise_in_transactional_callbacks = true
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# MySQL. Versions 5.0+ are recommended.
|
2
|
+
#
|
3
|
+
# Install the MYSQL driver
|
4
|
+
# gem install mysql2
|
5
|
+
#
|
6
|
+
# Ensure the MySQL gem is defined in your Gemfile
|
7
|
+
# gem 'mysql2'
|
8
|
+
#
|
9
|
+
# And be sure to use new-style password hashing:
|
10
|
+
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
|
11
|
+
#
|
12
|
+
default: &default
|
13
|
+
adapter: mysql2
|
14
|
+
encoding: utf8
|
15
|
+
pool: 5
|
16
|
+
username: root
|
17
|
+
password:
|
18
|
+
socket: /tmp/mysql.sock
|
19
|
+
|
20
|
+
development:
|
21
|
+
<<: *default
|
22
|
+
database: rails-example_development
|
23
|
+
|
24
|
+
# Warning: The database defined as "test" will be erased and
|
25
|
+
# re-generated from your development database when you run "rake".
|
26
|
+
# Do not set this db to the same as development or production.
|
27
|
+
test:
|
28
|
+
<<: *default
|
29
|
+
database: rails-example_test
|
30
|
+
|
31
|
+
# As with config/secrets.yml, you never want to store sensitive information,
|
32
|
+
# like your database password, in your source code. If your source code is
|
33
|
+
# ever seen by anyone, they now have access to your database.
|
34
|
+
#
|
35
|
+
# Instead, provide the password as a unix environment variable when you boot
|
36
|
+
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
37
|
+
# for a full rundown on how to provide these environment variables in a
|
38
|
+
# production deployment.
|
39
|
+
#
|
40
|
+
# On Heroku and other platform providers, you may have a full connection URL
|
41
|
+
# available as an environment variable. For example:
|
42
|
+
#
|
43
|
+
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
|
44
|
+
#
|
45
|
+
# You can use this database configuration with:
|
46
|
+
#
|
47
|
+
# production:
|
48
|
+
# url: <%= ENV['DATABASE_URL'] %>
|
49
|
+
#
|
50
|
+
production:
|
51
|
+
<<: *default
|
52
|
+
database: rails-example_production
|
53
|
+
username: rails-example
|
54
|
+
password: <%= ENV['RAILS-EXAMPLE_DATABASE_PASSWORD'] %>
|