├── .gitignore
├── .rspec
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── Gemfile
├── LICENSE.txt
├── LISENCE.txt
├── README.md
├── Rakefile
├── automock.gemspec
├── automock
└── data
│ ├── test.json
│ └── test2.json
├── bin
├── console
├── server
└── setup
├── lib
├── automock.rb
├── automock
│ ├── response_mock.rb
│ ├── rspec.rb
│ └── version.rb
└── tasks
│ └── automock.rake
├── server
├── .babelrc
├── .eslintrc
├── .gitignore
├── bin
│ └── server
├── gulpfile.coffee
├── migrations
│ ├── 20160101185711-add-selected-files.js
│ └── 20160102233558-add-columns-to-selected-files.js
├── package.json
├── src
│ ├── assets
│ │ ├── index.html
│ │ ├── javascripts
│ │ │ ├── actions
│ │ │ │ ├── mock_files_actions.js
│ │ │ │ └── selected_files_actions.js
│ │ │ ├── components
│ │ │ │ ├── file_list.react.js
│ │ │ │ ├── json_viewer.react.js
│ │ │ │ ├── select_buttons.react.js
│ │ │ │ └── selectable_lists.react.js
│ │ │ ├── containers
│ │ │ │ └── app.react.js
│ │ │ ├── index.js
│ │ │ └── reducers
│ │ │ │ ├── index.js
│ │ │ │ ├── mock_files.js
│ │ │ │ └── selected_files.js
│ │ └── stylesheets
│ │ │ ├── application.scss
│ │ │ └── components
│ │ │ ├── _file_list.scss
│ │ │ ├── _json_viewer.scss
│ │ │ ├── _select_buttons.scss
│ │ │ └── _selectable_list.scss
│ ├── db
│ │ ├── database.json
│ │ └── sequelize.js
│ ├── index.js
│ ├── models
│ │ └── selected_file.js
│ └── proxy_server.js
└── test
│ ├── fixtures
│ └── mock
│ │ ├── api
│ │ └── v1
│ │ │ └── api_test.json
│ │ └── test.json
│ └── request
│ ├── common_hooks.js
│ ├── mock_files_test.js
│ ├── proxy_server_test.js
│ └── selected_files_test.js
└── spec
├── automock_spec.rb
├── dummy
├── .gitignore
├── .rspec
├── Gemfile
├── Gemfile.lock
├── README.rdoc
├── Rakefile
├── app
│ ├── assets
│ │ ├── images
│ │ │ └── .keep
│ │ ├── javascripts
│ │ │ └── application.js
│ │ └── stylesheets
│ │ │ └── application.css
│ ├── controllers
│ │ ├── application_controller.rb
│ │ ├── concerns
│ │ │ └── .keep
│ │ └── dummy_api_controller.rb
│ ├── helpers
│ │ └── application_helper.rb
│ ├── mailers
│ │ └── .keep
│ ├── models
│ │ ├── .keep
│ │ └── concerns
│ │ │ └── .keep
│ └── views
│ │ └── layouts
│ │ └── application.html.erb
├── bin
│ ├── bundle
│ ├── rails
│ ├── rake
│ ├── setup
│ └── spring
├── config.ru
├── config
│ ├── application.rb
│ ├── boot.rb
│ ├── database.yml
│ ├── environment.rb
│ ├── environments
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── initializers
│ │ ├── assets.rb
│ │ ├── backtrace_silencers.rb
│ │ ├── cookies_serializer.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── mime_types.rb
│ │ ├── session_store.rb
│ │ └── wrap_parameters.rb
│ ├── locales
│ │ └── en.yml
│ ├── routes.rb
│ └── secrets.yml
├── db
│ └── seeds.rb
├── lib
│ ├── assets
│ │ └── .keep
│ ├── automock
│ └── tasks
│ │ └── .keep
├── log
│ └── .keep
├── public
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ ├── favicon.ico
│ └── robots.txt
├── spec
│ ├── rails_helper.rb
│ └── requests
│ │ └── dummy_api.rb
└── vendor
│ └── assets
│ ├── javascripts
│ └── .keep
│ └── stylesheets
│ └── .keep
└── spec_helper.rb
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle/
2 | /.yardoc
3 | /Gemfile.lock
4 | /_yardoc/
5 | /coverage/
6 | /doc/
7 | /pkg/
8 | /spec/reports/
9 | /tmp/
10 | /spec/fixtures/
11 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --format documentation
2 | --color
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: ruby
2 | rvm:
3 | - 2.3.0
4 | sudo: false
5 | before_install: gem install bundler -v 1.11.2
6 | before_install: nvm install 4.2.3
7 | install:
8 | - ./bin/setup
9 | script:
10 | - bundle exec rake spec
11 | - cd server && npm test
12 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, and in the interest of
4 | fostering an open and welcoming community, we pledge to respect all people who
5 | contribute through reporting issues, posting feature requests, updating
6 | documentation, submitting pull requests or patches, and other activities.
7 |
8 | We are committed to making participation in this project a harassment-free
9 | experience for everyone, regardless of level of experience, gender, gender
10 | identity and expression, sexual orientation, disability, personal appearance,
11 | body size, race, ethnicity, age, religion, or nationality.
12 |
13 | Examples of unacceptable behavior by participants include:
14 |
15 | * The use of sexualized language or imagery
16 | * Personal attacks
17 | * Trolling or insulting/derogatory comments
18 | * Public or private harassment
19 | * Publishing other's private information, such as physical or electronic
20 | addresses, without explicit permission
21 | * Other unethical or unprofessional conduct
22 |
23 | Project maintainers have the right and responsibility to remove, edit, or
24 | reject comments, commits, code, wiki edits, issues, and other contributions
25 | that are not aligned to this Code of Conduct, or to ban temporarily or
26 | permanently any contributor for other behaviors that they deem inappropriate,
27 | threatening, offensive, or harmful.
28 |
29 | By adopting this Code of Conduct, project maintainers commit themselves to
30 | fairly and consistently applying these principles to every aspect of managing
31 | this project. Project maintainers who do not follow or enforce the Code of
32 | Conduct may be permanently removed from the project team.
33 |
34 | This code of conduct applies both within project spaces and in public spaces
35 | when an individual is representing the project or its community.
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
38 | reported by contacting a project maintainer at joe.tialtngo@gmail.com. All
39 | complaints will be reviewed and investigated and will result in a response that
40 | is deemed necessary and appropriate to the circumstances. Maintainers are
41 | obligated to maintain confidentiality with regard to the reporter of an
42 | incident.
43 |
44 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45 | version 1.3.0, available at
46 | [http://contributor-covenant.org/version/1/3/0/][version]
47 |
48 | [homepage]: http://contributor-covenant.org
49 | [version]: http://contributor-covenant.org/version/1/3/0/
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Specify your gem's dependencies in automock.gemspec
4 | gemspec
5 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 joe-re
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.
22 |
--------------------------------------------------------------------------------
/LISENCE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Masato Noguchi
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Automock
2 | [](https://travis-ci.org/joe-re/automock)
3 |
4 | Generate WebAPI mocking response data from your rails application's request-spec.
5 |
6 | And run proxy server for mocking response.
7 |
8 | Inspired by [autodoc](https://github.com/r7kamura/autodoc).
9 |
10 | ## Installation
11 |
12 | Add this line to your rails application's Gemfile:
13 |
14 | ```ruby
15 | gem "automock", group: :test
16 | ```
17 |
18 | Download and install by running:
19 |
20 | ```
21 | $ bundle install
22 | ```
23 |
24 | And setup mocking server.
25 |
26 | ```
27 | $ rake automock:setup
28 | ```
29 |
30 | This generate `automock` directory under your rails root.
31 | Mocking server is inside it.
32 | I recommend adding automock directory to .gitignore.
33 |
34 | Then run mocking server.
35 |
36 | ```
37 | $ rake automock:server
38 | ```
39 |
40 | By default, proxy server use 8001 port and target application using 3000 port.
41 | Mocking management server use 8000 port.
42 | Now you can access it, localhost:8000.
43 | And access localhost:8001, you can receive response by proxy.
44 |
45 | ## Usage
46 |
47 | ### Generate data for mocking response
48 | Run rspec with AUTOMOCK=1 to generate mocking data for your request-specs tagged with :automock.
49 |
50 | ```
51 | AUTOMOCK=1 rspec
52 | ```
53 |
54 | #### Example
55 |
56 | ```ruby
57 | describe 'GET /api/v1/users' do
58 | context 'This is test API', automock: true do
59 | before do
60 | get '/api/v1/users'
61 | end
62 | it 'receives 200 and users json' do
63 | expect(response.status).to eq 200
64 | end
65 | # and more example...
66 | end
67 | end
68 | ```
69 |
70 | ### Mocking response
71 |
72 | You can manage mocking data, on or off, by mocking response management server.
73 | By default, mocking management server use 8000 port.
74 | So you can access it.
75 |
76 | 
77 |
78 | Selected mocking data is used by proxy.
79 | Unselected api is passed through normally.
80 |
81 | ### Configration
82 |
83 | You can change automock's using port by rake args.
84 |
85 | - automock_port
86 | - rails_port
87 | - proxy_port
88 |
89 | Example:
90 | ```
91 | $ rake automock:server automock_port=3001 rails_port=3002 proxy_port=3003
92 | ```
93 | ## Development
94 |
95 | After checking out the repo, run `bin/setup` to install dependencies.
96 | If you run mocking server, run `bin/server` to start it.
97 |
98 | ### spec
99 |
100 | Then, run `rake spec` to run the tests for ruby code.
101 | And change directory to `server`, then run `npm run test` to run the tests for mocking server.
102 |
103 | ## Contributing
104 |
105 | Bug reports and pull requests are welcome on GitHub at https://github.com/joe-re/automock. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106 |
107 |
108 | ## License
109 |
110 | The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
111 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler/gem_tasks'
2 | require 'rspec/core/rake_task'
3 |
4 | RSpec::Core::RakeTask.new(:spec)
5 |
6 | task default: :spec
7 | task :update_mockdata_fixtures do
8 | system('rm -rf spec/dummy/automock')
9 | system('AUTOMOCK=1 bundle exec rspec spec/dummy/spec/requests/dummy_api.rb')
10 | FileUtils.mkdir_p('spec/fixtures/data')
11 | FileUtils.cp_r('spec/dummy/automock/data/', 'spec/fixtures/', remove_destination: true)
12 | end
13 |
--------------------------------------------------------------------------------
/automock.gemspec:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | lib = File.expand_path('../lib', __FILE__)
3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4 | require 'automock/version'
5 |
6 | Gem::Specification.new do |spec|
7 | spec.name = 'automock'
8 | spec.version = Automock::VERSION
9 | spec.authors = ['joe-re']
10 | spec.email = ['joe.tialtngo@gmail.com']
11 |
12 | spec.summary = 'Auto-generate mock_data of JSON API response from your request-specs.'
13 | spec.homepage = 'https://github.com/joe-re/automock'
14 | spec.license = 'MIT'
15 |
16 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17 | spec.bindir = 'exe'
18 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19 | spec.require_paths = ['lib']
20 | spec.add_dependency 'rspec', '~> 3.0'
21 | spec.add_dependency 'rails', '~> 4.0'
22 |
23 | spec.add_development_dependency 'bundler', '~> 1.11'
24 | spec.add_development_dependency 'rake', '~> 10.0'
25 | spec.add_development_dependency 'rspec-rails'
26 | spec.add_development_dependency 'sqlite3'
27 | end
28 |
--------------------------------------------------------------------------------
/automock/data/test.json:
--------------------------------------------------------------------------------
1 | {"description":"1 receives 200 and users json","method":"GET","uri":"/api/v1/users","status":200,"response_header":{"X-Frame-Options":"SAMEORIGIN","X-XSS-Protection":"1; mode=block","X-Content-Type-Options":"nosniff","Content-Type":"application/json; charset=utf-8","ETag":"W/\"e224cce5657514dd4f022471dc9261c6\"","Cache-Control":"max-age=0, private, must-revalidate","X-Request-Id":"dc872bfa-ebc0-447e-ad5c-4c7932897bb2","X-Runtime":"0.008449","Content-Length":"42"},"response_body":"{\"users\":[{\"user\":{\"name\":\"dummy user\"}}]}"}
2 |
--------------------------------------------------------------------------------
/automock/data/test2.json:
--------------------------------------------------------------------------------
1 | {"description":"2 receives 200 and users json","method":"GET","uri":"/api/v1/users2","status":200,"response_header":{"X-Frame-Options":"SAMEORIGIN","X-XSS-Protection":"1; mode=block","X-Content-Type-Options":"nosniff","Content-Type":"application/json; charset=utf-8","ETag":"W/\"e224cce5657514dd4f022471dc9261c6\"","Cache-Control":"max-age=0, private, must-revalidate","X-Request-Id":"dc872bfa-ebc0-447e-ad5c-4c7932897bb2","X-Runtime":"0.008449","Content-Length":"42"},"response_body":"{\"users\":[{\"user\":{\"name\":\"dummy user\"}}]}"}
2 |
--------------------------------------------------------------------------------
/bin/console:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require "bundler/setup"
4 | require "automock"
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
15 |
--------------------------------------------------------------------------------
/bin/server:
--------------------------------------------------------------------------------
1 | export AUTOMOCK_DATA_PATH=${PWD}/automock/data
2 | cd server
3 | node dist/index.js
4 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euo pipefail
3 | IFS=$'\n\t'
4 | set -vx
5 |
6 | bundle install --path vendor/bundle
7 |
8 | # Do any other automated setup that you need to do here
9 | cd server
10 | npm install
11 | npm run build
12 | node node_modules/db-migrate/bin/db-migrate up --config src/db/database.json -e dev
13 |
--------------------------------------------------------------------------------
/lib/automock.rb:
--------------------------------------------------------------------------------
1 | require 'rails'
2 | require 'automock/version'
3 | require 'automock/response_mock'
4 | require 'automock/rspec'
5 |
6 | module Automock
7 | class << self
8 | def append(context, example)
9 | return unless ENV["AUTOMOCK"]
10 | @mocks ||= []
11 | @mocks << ResponseMock.new(context.clone, example.clone)
12 | end
13 |
14 | def write
15 | @mocks && @mocks.each(&:write)
16 | end
17 | end
18 |
19 | class Railtie < ::Rails::Railtie
20 | rake_tasks do
21 | load 'tasks/automock.rake'
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/lib/automock/response_mock.rb:
--------------------------------------------------------------------------------
1 | require 'pathname'
2 |
3 | module Automock
4 | class ResponseMock
5 | def initialize(context, example)
6 | @context = context
7 | @example = example
8 | end
9 |
10 | def description
11 | @example.try(:example_group).try(:description) || @example.description
12 | end
13 |
14 | def method
15 | @context.request.method
16 | end
17 |
18 | def uri
19 | @context.request.env['PATH_INFO']
20 | end
21 |
22 | def response_header
23 | @context.response.try(:header)
24 | end
25 |
26 | def status
27 | @context.response.try(:status)
28 | end
29 |
30 | def response_body
31 | @context.response.try(:body)
32 | end
33 |
34 | def filename
35 | "#{method}_#{description.gsub(/\s/, '_').gsub(/[?"\\\<>*|]/, '')}.json"
36 | end
37 |
38 | def mock_data
39 | {
40 | description: description,
41 | method: method,
42 | uri: uri,
43 | status: status,
44 | response_header: response_header,
45 | response_body: response_body
46 | }.to_json
47 | end
48 |
49 | def write
50 | pathname = Pathname.new("#{Rails.root}/automock/data/#{uri}/#{filename}")
51 | pathname.parent.mkpath
52 | pathname.open('w') { |file| file << mock_data }
53 | end
54 | end
55 | end
56 |
--------------------------------------------------------------------------------
/lib/automock/rspec.rb:
--------------------------------------------------------------------------------
1 | require 'rspec'
2 |
3 | RSpec.configure do |c|
4 | c.after(:each, automock: true) do |example|
5 | Automock.append(self, example)
6 | end
7 |
8 | c.after(:suite) do
9 | Automock.write
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/lib/automock/version.rb:
--------------------------------------------------------------------------------
1 | module Automock
2 | VERSION = "0.0.6"
3 | end
4 |
--------------------------------------------------------------------------------
/lib/tasks/automock.rake:
--------------------------------------------------------------------------------
1 | require 'pathname'
2 | require 'fileutils'
3 |
4 | namespace :automock do
5 | desc 'Setup automock'
6 | task :setup, :options do |_, _args|
7 | dist = Pathname.new('automock')
8 | dist.mkpath
9 | src = [
10 | "#{File.dirname(__FILE__)}/../../server"
11 | ]
12 | FileUtils.cp_r(src, dist, remove_destination: true)
13 | puts "created #{dist}"
14 | Rake::Task['automock:install'].execute
15 | end
16 |
17 | task :install, :options do |_, _args|
18 | Dir.chdir "#{Rails.root}/automock/server"
19 | sh 'npm install && npm run build'
20 | sh 'node node_modules/db-migrate/bin/db-migrate up --config app/db/database.json -e dev'
21 | end
22 |
23 | task :server, :options do |_, _args|
24 | ap = ENV['automock_port'] || 8000
25 | rp = ENV['rails_port'] || 3000
26 | pp = ENV['proxy_port'] || 8001
27 | mock_data_path = "#{Rails.root}/automock/data"
28 | Dir.chdir "#{Rails.root}/automock/server"
29 | sh "./bin/server #{mock_data_path} #{ap} #{rp} #{pp}"
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/server/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | presets: [ 'es2015', 'react', 'stage-3' ]
3 | }
4 |
--------------------------------------------------------------------------------
/server/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "env": {
4 | "browser": true,
5 | "node": false
6 | },
7 | "ecmaFeatures": {
8 | "jsx": true
9 | },
10 | "plugins": [
11 | "react"
12 | ],
13 | "rules": {
14 | "strict": 0,
15 |
16 | "comma-dangle": 2,
17 | "comma-style": [2, "last"],
18 | "comma-spacing": [2, {"before": false, "after": true}],
19 | "semi": [2, "always"],
20 | "indent": [2, 2],
21 | "key-spacing": [0],
22 | "quotes": [2, "single", "avoid-escape"],
23 | "brace-style": [2, "1tbs", { "allowSingleLine": false }],
24 | "curly": 2,
25 | "object-curly-spacing": [2, "always"],
26 | "array-bracket-spacing": [2, "always"],
27 | "dot-location": [2, "object"],
28 | "camelcase": [2, {"properties": "never"}],
29 | "dot-notation": 2,
30 | "yoda": [2, "never", { "exceptRange": true }],
31 |
32 | "no-alert": 2,
33 | "no-array-constructor": 2,
34 | "no-caller": 2,
35 | "no-catch-shadow": 2,
36 | "no-dupe-args": 2,
37 | "no-else-return": 2,
38 | "no-empty-label": 2,
39 | "no-eval": 2,
40 | "no-extend-native": 2,
41 | "no-extra-bind": 2,
42 | "no-implied-eval": 2,
43 | "no-iterator": 2,
44 | "no-label-var": 2,
45 | "no-labels": 2,
46 | "no-lone-blocks": 2,
47 | "no-lonely-if": 2,
48 | "no-loop-func": 2,
49 | "no-multi-spaces": [2, {
50 | "exceptions":{
51 | "Property": true,
52 | "ImportDeclaration": true,
53 | "VariableDeclarator": true,
54 | "AssignmentExpression": true
55 | }
56 | }],
57 | "no-multi-str": 2,
58 | "no-multiple-empty-lines": [2, {max: 2}],
59 | "no-native-reassign": 2,
60 | "no-nested-ternary": 2,
61 | "no-new": 0,
62 | "no-new-func": 2,
63 | "no-new-object": 2,
64 | "no-new-wrappers": 2,
65 | "no-octal-escape": 2,
66 | "no-process-exit": 2,
67 | "no-proto": 2,
68 | "no-return-assign": 2,
69 | "no-script-url": 2,
70 | "no-sequences": 2,
71 | "no-shadow": 2,
72 | "no-shadow-restricted-names": 2,
73 | "no-spaced-func": 2,
74 | "no-throw-literal": 2,
75 | "no-trailing-spaces": 2,
76 | "no-undef": 0,
77 | "no-undef-init": 2,
78 | "no-underscore-dangle": 2,
79 | "no-unneeded-ternary": 2,
80 | "no-unused-expressions": 2,
81 | "no-unused-vars": [2, {"vars": "all", "args": "all", "argsIgnorePattern": "^_"}],
82 | "no-use-before-define": 2,
83 | "no-void": 2,
84 | "no-with": 2,
85 |
86 | "max-len": [1, 120, 2],
87 | "max-params": [1, 3],
88 | "max-depth": [1, 3],
89 | "max-statements": [1, 50],
90 |
91 | "new-cap": 0,
92 | "eqeqeq": 2,
93 |
94 | "no-var": 2,
95 | "object-shorthand": [2, "always"],
96 | "prefer-const": 2,
97 | "constructor-super": 2,
98 | "no-this-before-super": 2,
99 | "space-after-keywords": 2,
100 | "arrow-spacing": 2,
101 |
102 | "react/jsx-uses-vars": 1
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/server/.gitignore:
--------------------------------------------------------------------------------
1 | /app/assets/
2 | /node_modules/
3 | /npm-debug.log
4 | /*.db
5 | /dist/
6 |
--------------------------------------------------------------------------------
/server/bin/server:
--------------------------------------------------------------------------------
1 | # starting server from rake task
2 |
3 | if [ $# -ne 4 ]; then
4 | echo "empty args!" 1>&2
5 | exit 1
6 | fi
7 |
8 | export AUTOMOCK_DATA_PATH=$1
9 | export AUTOMOCK_PORT=$2
10 | export AUTOMOCK_TARGET_PORT=$3
11 | export AUTOMOCK_PROXY_PORT=$4
12 |
13 | node dist/index.js
14 |
--------------------------------------------------------------------------------
/server/gulpfile.coffee:
--------------------------------------------------------------------------------
1 | gulp = require 'gulp'
2 | babelify = require 'babelify'
3 | browserify = require 'browserify'
4 | source = require 'vinyl-source-stream'
5 | sass = require 'gulp-sass'
6 | seq = require 'run-sequence'
7 | babel = require 'gulp-babel'
8 |
9 | gulp.path =
10 | assetSrc: 'src/assets'
11 | assetDist: 'dist/assets'
12 | src: 'src'
13 | dist: 'dist'
14 |
15 | gulp.task 'build', ->
16 | seq ['build:html', 'build:server', 'build:browserify', 'build:scss']
17 |
18 | gulp.task 'build:html', ->
19 | gulp.src "#{@path.assetSrc}/**/*.html"
20 | .pipe gulp.dest(@path.assetDist)
21 |
22 | gulp.task 'build:server', ->
23 | gulp.src ["#{@path.src}/**/*.js", "!#{@path.assetSrc}/**/*.js"]
24 | .pipe babel()
25 | .pipe gulp.dest(@path.dist)
26 |
27 | gulp.task 'build:browserify', ->
28 | browserify(
29 | entries: ["#{@path.assetSrc}/javascripts/index.js"]
30 | extensions: ['.js', '.react.js']
31 | ).transform(babelify)
32 | .bundle()
33 | .pipe source 'bundle.js'
34 | .pipe gulp.dest(@path.assetDist)
35 |
36 | gulp.task 'build:scss', ->
37 | gulp.src "#{@path.assetSrc}/**/*.scss"
38 | .pipe sass({ includePaths: [ 'node_modules' ] }).on('error', sass.logError)
39 | .pipe gulp.dest(@path.assetDist)
40 |
41 | gulp.task 'watch', ['build'], ->
42 | gulp.watch("#{@path.src}/**/*.js", ['build:browserify', 'build:server'])
43 | gulp.watch("#{@path.src}/**/*.scss", ['build:scss'])
44 |
--------------------------------------------------------------------------------
/server/migrations/20160101185711-add-selected-files.js:
--------------------------------------------------------------------------------
1 | var dbm = global.dbm || require('db-migrate');
2 | var type = dbm.dataType;
3 |
4 | exports.up = function(db, callback) {
5 | db.createTable('selected_files', {
6 | id: { type: 'int', primaryKey: true, autoIncrement: true },
7 | name: { type: 'string', unique: true, notNull: 'true' },
8 | createdAt: { type: 'datetime' },
9 | updatedAt: { type: 'datetime' }
10 | }, callback);
11 | };
12 |
13 | exports.down = function(db, callback) {
14 | callback();
15 | };
16 |
--------------------------------------------------------------------------------
/server/migrations/20160102233558-add-columns-to-selected-files.js:
--------------------------------------------------------------------------------
1 | var dbm = global.dbm || require('db-migrate');
2 | var type = dbm.dataType;
3 | var async = require('async');
4 |
5 | exports.up = function(db, callback) {
6 | async.series([
7 | db.addColumn.bind(db, 'selected_files', 'method', { type: 'string', notNull: true, defaultValue: 'dummy' }),
8 | db.addColumn.bind(db, 'selected_files', 'uri', { type: 'string', notNull: true, defaultValue: 'dummy' })
9 | ], callback);
10 | };
11 |
12 | exports.down = function(db, callback) {
13 | async.series([
14 | db.removeColumn.bind(db, 'selected_files', 'method'),
15 | db.removeColumn.bind(db, 'selected_files', 'uri')
16 | ], callback);
17 | };
18 |
--------------------------------------------------------------------------------
/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automock",
3 | "engines" : {
4 | "node": ">=4.0.0",
5 | "npm": ">=2.0.0"
6 | },
7 | "devDependencies": {
8 | "async": "^1.5.1",
9 | "babel": "^6.1.18",
10 | "babel-cli": "^6.2.0",
11 | "babel-core": "^6.3.26",
12 | "babel-polyfill": "^6.3.14",
13 | "babel-preset-es2015": "^6.1.18",
14 | "babel-preset-react": "^6.3.13",
15 | "babel-preset-stage-3": "^6.3.13",
16 | "babelify": "^7.2.0",
17 | "browserify": "^12.0.1",
18 | "coffee-script": "^1.10.0",
19 | "db-migrate": "^0.9.23",
20 | "gulp": "^3.9.0",
21 | "gulp-babel": "^6.1.1",
22 | "gulp-sass": "^2.1.1",
23 | "http-proxy": "^1.12.0",
24 | "mocha": "^2.3.4",
25 | "power-assert": "^1.2.0",
26 | "redux-devtools": "^3.0.1",
27 | "run-sequence": "^1.1.5",
28 | "supertest": "^1.1.0",
29 | "vinyl-source-stream": "^1.1.0"
30 | },
31 | "dependencies": {
32 | "body-parser": "^1.14.2",
33 | "bootstrap": "^4.0.0-alpha.2",
34 | "express": "^4.13.3",
35 | "immutable": "^3.7.6",
36 | "object-assign": "^4.0.1",
37 | "react": "^0.14.3",
38 | "react-dom": "^0.14.3",
39 | "react-json-tree": "^0.4.0",
40 | "react-redux": "^4.0.5",
41 | "recursive-readdir": "^1.3.0",
42 | "redux": "^3.0.5",
43 | "redux-logger": "^2.3.1",
44 | "redux-thunk": "^1.0.2",
45 | "sequelize": "^3.15.1",
46 | "sqlite3": "^3.1.1",
47 | "superagent": "^1.6.1",
48 | "underscore": "^1.8.3"
49 | },
50 | "scripts": {
51 | "test": "mocha --require babel-core/register --recursive test",
52 | "build": "gulp build",
53 | "watch": "gulp watch"
54 | },
55 | "repository": {
56 | "type": "git",
57 | "url": "git+https://github.com/joe-re/automock.git"
58 | },
59 | "keywords": [],
60 | "author": "",
61 | "license": "MIT",
62 | "bugs": {
63 | "url": "https://github.com/joe-re/automock/issues"
64 | },
65 | "homepage": "https://github.com/joe-re/automock#readme"
66 | }
67 |
--------------------------------------------------------------------------------
/server/src/assets/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | automock
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/actions/mock_files_actions.js:
--------------------------------------------------------------------------------
1 | /* flow */
2 |
3 | import request from 'superagent';
4 | export const GET_MOCK_FILES = 'GET_MOCK_FILES';
5 |
6 | export function getMockFiles() {
7 | return (dispatch) => {
8 | request.
9 | get('./mock_files').
10 | end((_err, res) => {
11 | dispatch({
12 | type: GET_MOCK_FILES,
13 | mockFiles: res.body
14 | });
15 | }
16 | );
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/actions/selected_files_actions.js:
--------------------------------------------------------------------------------
1 | /* flow */
2 |
3 | import request from 'superagent';
4 | export const GET_SELECTED_FILES = 'GET_SELECTED_FILES';
5 | export const CREATE_SELECTED_FILES = 'CREATE_SELECTED_FILES';
6 | export const DELETE_SELECTED_FILES = 'DELETE_SELECTED_FILES';
7 |
8 | export function getSelectedFiles() {
9 | return (dispatch) => {
10 | request.
11 | get('/selected_files').
12 | end((_err, res) => {
13 | dispatch({
14 | type: GET_SELECTED_FILES,
15 | selectedFiles: res.body
16 | });
17 | }
18 | );
19 | };
20 | }
21 |
22 | export function createSelectedFile(file) {
23 | return (dispatch) => {
24 | request.
25 | post('/selected_files').
26 | send(file).
27 | end((_err, res) => {
28 | dispatch({
29 | type: CREATE_SELECTED_FILES,
30 | selectedFile: res.body
31 | });
32 | }
33 | );
34 | };
35 | }
36 |
37 | export function deleteSelectedFile(id) {
38 | return (dispatch) => {
39 | request.
40 | delete(`/selected_files/${id}`).
41 | end((_err, _res) => {
42 | dispatch({ type: DELETE_SELECTED_FILES, id });
43 | }
44 | );
45 | };
46 | }
47 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/components/file_list.react.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | export default class FileList extends React.Component {
4 | constructor() {
5 | super();
6 | this.state = { searchingValue: '' };
7 |
8 | }
9 | handleSelect(file) {
10 | this.props.onChange(file);
11 | }
12 | handleChangeIncrementalSearchInput(e) {
13 | this.setState({ searchingValue: e.target.value });
14 | }
15 | render() {
16 | const options = this.props.files.map((file) => {
17 | const { searchingValue } = this.state;
18 | if (searchingValue && file.name.indexOf(searchingValue) < 0) {
19 | return;
20 | }
21 | let className = 'item';
22 | if (file === this.props.viewingFile) {
23 | className += ' active';
24 | }
25 | return (
26 |
31 | {file.name}
32 |
33 | );
34 | });
35 | return(
36 |
37 |
{this.props.title}
38 |
39 |
40 | {options}
41 |
42 |
43 | );
44 | }
45 | };
46 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/components/json_viewer.react.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import JSONTree from 'react-json-tree';
3 | import assign from 'object-assign';
4 |
5 | export default class JsonViewer extends React.Component {
6 | parseJson() {
7 | const srcJson = this.props.dataSource;
8 | const distJson = assign({}, srcJson);
9 | if (!distJson.name) {
10 | return distJson;
11 | }
12 | distJson.response_body = JSON.parse(srcJson.response_body);
13 | delete distJson.id; // don't show id
14 | return distJson;
15 | }
16 |
17 | render(){
18 | const json = this.parseJson();
19 |
20 | let jsonTree;
21 | if (json.name) {
22 | jsonTree =
;
23 | }
24 |
25 | return (
26 | { jsonTree }
27 | );
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/components/select_buttons.react.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | export default class SelectButtons extends React.Component {
4 | handleClickSelectButton() {
5 | this.props.onClickSelectButton(this.props.selectedFromNotSelectedFiles);
6 | }
7 | handleClickUnselectButton() {
8 | this.props.onClickUnselectButton(this.props.selectedFromSelectedFiles.id);
9 | }
10 | render() {
11 | return(
12 |
13 |
14 |
15 |
16 | );
17 | }
18 | };
19 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/components/selectable_lists.react.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import FileList from './file_list';
3 | import SelectButtons from './select_buttons';
4 | import JsonViewer from './json_viewer';
5 |
6 | export default class SelectableLists extends React.Component {
7 | constructor() {
8 | super();
9 | this.state = {
10 | selectedFromNotSelectedFiles: {},
11 | selectedFromSelectedFiles: {},
12 | viewingFile: {}
13 | };
14 | }
15 |
16 | handleSelectFromNotSelectedFiles(selectedFile) {
17 | this.setState({
18 | viewingFile: selectedFile,
19 | selectedFromNotSelectedFiles: selectedFile
20 | });
21 | }
22 |
23 | handleSelectFromSelectedFiles(selectedFile) {
24 | this.setState({
25 | viewingFile: selectedFile,
26 | selectedFromSelectedFiles: selectedFile
27 | });
28 | }
29 |
30 | render() {
31 | const { selectedFiles, unselectedFiles } = this.props;
32 | return(
33 |
34 |
35 |
41 |
46 |
52 |
53 |
54 |
55 |
56 |
57 | );
58 | }
59 | };
60 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/containers/app.react.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { bindActionCreators } from 'redux';
3 | import { connect } from 'react-redux';
4 | import * as SelectedFilesActions from '../actions/selected_files_actions';
5 | import * as MockFilesActions from '../actions/mock_files_actions';
6 | import SelectableLists from './../components/selectable_lists';
7 | import assign from 'object-assign';
8 | import _ from 'underscore';
9 |
10 | class AppContainer extends React.Component {
11 | componentDidMount() {
12 | const { getSelectedFiles, getMockFiles } = this.props;
13 | getSelectedFiles();
14 | getMockFiles();
15 | }
16 |
17 | handleCreateSelectedFile(file) {
18 | const { createSelectedFile } = this.props;
19 | createSelectedFile(file);
20 | }
21 |
22 | handleDeleteSelectedFile(id) {
23 | const { deleteSelectedFile } = this.props;
24 | deleteSelectedFile(id);
25 | }
26 |
27 | computeFileContents() {
28 | const { selectedFiles, mockFiles } = this.props;
29 | const selectedFileNames = selectedFiles.map((file) => file.name).toArray();
30 | const splited = _.partition(mockFiles.toArray(), (file) => _.includes(selectedFileNames, file.name));
31 | splited[0] = splited[0].map((file) => {
32 | file.id = _.find(selectedFiles.toArray(), (selectedFile) => selectedFile.name === file.name).id;
33 | return file;
34 | });
35 | return({ selectedFiles: splited[0], unselectedFiles: splited[1] });
36 | }
37 |
38 | render() {
39 | const { selectedFiles, unselectedFiles } = this.computeFileContents();
40 | return (
41 |
42 |
48 |
49 | );
50 | }
51 | }
52 |
53 | function mapStateToProps(state) {
54 | return {
55 | selectedFiles: state.selectedFiles,
56 | mockFiles: state.mockFiles
57 | };
58 | }
59 |
60 | function mapDispatchToProps(dispatch) {
61 | const actions = assign({}, SelectedFilesActions, MockFilesActions);
62 | return bindActionCreators(actions, dispatch);
63 | }
64 |
65 | export default connect(mapStateToProps, mapDispatchToProps)(AppContainer);
66 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { render } from 'react-dom';
3 | import { createStore, applyMiddleware } from 'redux';
4 | import { Provider } from 'react-redux';
5 | import App from './containers/app';
6 | import reducers from './reducers';
7 | import thunk from 'redux-thunk';
8 | import logger from 'redux-logger';
9 |
10 | const middleware = process.env.NODE_ENV === 'production' ?
11 | [ thunk ] :
12 | [ thunk, logger() ];
13 |
14 | const createStoreWithMiddleware = applyMiddleware(...middleware)(createStore);
15 | const store = createStoreWithMiddleware(reducers);
16 |
17 | const rootElement = document.getElementById('application');
18 | render(
19 |
20 |
21 | ,
22 | rootElement
23 | );
24 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/reducers/index.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 | import selectedFiles from './selected_files';
3 | import mockFiles from './mock_files';
4 |
5 | const rootReducer = combineReducers({ selectedFiles, mockFiles });
6 |
7 | export default rootReducer;
8 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/reducers/mock_files.js:
--------------------------------------------------------------------------------
1 | import { List } from 'immutable';
2 | import { GET_MOCK_FILES } from '../actions/mock_files_actions';
3 |
4 | export default function mockFiles(state = List(), action) {
5 | switch (action.type) {
6 | case GET_MOCK_FILES:
7 | return List(action.mockFiles);
8 | default:
9 | return state;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/server/src/assets/javascripts/reducers/selected_files.js:
--------------------------------------------------------------------------------
1 | import { List } from 'immutable';
2 | import { GET_SELECTED_FILES, CREATE_SELECTED_FILES, DELETE_SELECTED_FILES } from '../actions/selected_files_actions';
3 |
4 | export default function selectedFiles(state = List(), action) {
5 | switch (action.type) {
6 | case GET_SELECTED_FILES:
7 | return List(action.selectedFiles);
8 | case CREATE_SELECTED_FILES:
9 | return state.push(action.selectedFile);
10 | case DELETE_SELECTED_FILES:
11 | return state.filter((file) => file.id !== action.id);
12 | default:
13 | return state;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/server/src/assets/stylesheets/application.scss:
--------------------------------------------------------------------------------
1 | @import 'bootstrap/scss/bootstrap';
2 | @import './components/selectable_list';
3 | @import './components/file_list';
4 | @import './components/select_buttons';
5 | @import './components/json_viewer';
6 |
--------------------------------------------------------------------------------
/server/src/assets/stylesheets/components/_file_list.scss:
--------------------------------------------------------------------------------
1 | .selectable-lists {
2 | height: 300px;
3 | }
4 |
5 | .file-list {
6 | margin-bottom: 8px;
7 | height: 100%;
8 | .file-select-box {
9 | border: grey solid 1px;
10 | height: 260px;
11 | overflow-y: auto;
12 | overflow-x: hidden;
13 | }
14 |
15 | .item {
16 | color: #555;
17 | display: block;
18 | padding: 10px 15px;
19 | margin-bottom: -1px;
20 | background-color: #fff;
21 | border: 1px solid #ddd;
22 | cursor: pointer;
23 | &:hover {
24 | background-color: #f5f5f5;
25 | }
26 | }
27 |
28 | .item.active {
29 | color: #fff;
30 | background-color: #337ab7;
31 | border-color: #337ab7;
32 | }
33 |
34 | .incremental-search-input {
35 | width: 100%;
36 | margin-bottom: 4px;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/server/src/assets/stylesheets/components/_json_viewer.scss:
--------------------------------------------------------------------------------
1 | .json-viewer {
2 | border: gray solid 1px;
3 | li > div, li > div ~ label {
4 | cursor: pointer;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/server/src/assets/stylesheets/components/_select_buttons.scss:
--------------------------------------------------------------------------------
1 | .select-buttons {
2 | display: flex;
3 | flex-direction: column;
4 | height: 320px;
5 | justify-content: space-around;
6 |
7 | button { display: block; }
8 | }
9 |
--------------------------------------------------------------------------------
/server/src/assets/stylesheets/components/_selectable_list.scss:
--------------------------------------------------------------------------------
1 | .selectable-lists {
2 | margin-top: 60px;
3 | }
4 |
--------------------------------------------------------------------------------
/server/src/db/database.json:
--------------------------------------------------------------------------------
1 | {
2 | "dev": {
3 | "driver": "sqlite3",
4 | "filename": "automock.db"
5 | },
6 | "test": {
7 | "driver": "sqlite3",
8 | "filename": "automock_test.db"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/server/src/db/sequelize.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const storage = process.env.NODE_ENV === 'test' ? './automock_test.db' : './automock.db';
3 | const sequelize = new Sequelize('automock', '', '', { dialect:'sqlite', storage });
4 | module.exports = sequelize;
5 |
--------------------------------------------------------------------------------
/server/src/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import 'babel-polyfill';
4 |
5 | const express = require('express');
6 | const app = express();
7 | const recursive = require('recursive-readdir');
8 | const path = require('path');
9 | const SelectedFile = require('./models/selected_file');
10 | const bodyParser = require('body-parser');
11 | const fs = require('fs');
12 | const _ = require('underscore');
13 |
14 | app.use(express.static(__dirname + '/assets'));
15 | app.use(bodyParser.urlencoded());
16 | app.use(bodyParser.json());
17 | let proxyServer;
18 |
19 | app.get('/mock_files', async function(_req, res){
20 | const filePaths = await new Promise((resolve) =>
21 | recursive(process.env.AUTOMOCK_DATA_PATH, (_err, v) => resolve(v))
22 | );
23 | const files = await Promise.all(filePaths.map((filePath) =>
24 | new Promise((resolve) => {
25 | fs.readFile(filePath, 'utf8', (_err2, text) => {
26 | const mockData = JSON.parse(text);
27 | mockData.name = path.relative(process.env.AUTOMOCK_DATA_PATH, filePath);
28 | resolve(mockData);
29 | });
30 | })
31 | ));
32 | res.status(200).send(files);
33 | });
34 |
35 | app.get('/selected_files', function(_req, res){
36 | SelectedFile.findAll().
37 | then((files) =>
38 | files.map((file) => {
39 | return { id: file.id, name: file.name };
40 | })
41 | ).then((selectedFiles) =>
42 | new Promise((resolve) => {
43 | recursive(process.env.AUTOMOCK_DATA_PATH, (_err, filePaths) => {
44 | const fileNames = filePaths.map((filePath) => path.relative(process.env.AUTOMOCK_DATA_PATH, filePath));
45 | resolve(selectedFiles.filter((selectedFile) => _.includes(fileNames, selectedFile.name)));
46 | });
47 | })
48 | ).then((response) =>
49 | res.status(200).send(response)
50 | );
51 | });
52 |
53 | app.post('/selected_files', function(req, res){
54 | SelectedFile.create({
55 | name: req.body.name,
56 | uri: req.body.uri,
57 | method: req.body.method
58 | }).then((selectedFile) => {
59 | res.status(201).send(selectedFile);
60 | if (proxyServer) {
61 | proxyServer.loadSelectedFiles();
62 | }
63 | });
64 | });
65 |
66 | app.delete('/selected_files/:id', function(req, res){
67 | SelectedFile.destroy({ where: { id: req.params.id } }).then(() => {
68 | res.status(204).send();
69 | if (proxyServer) {
70 | proxyServer.loadSelectedFiles();
71 | }
72 | });
73 | });
74 |
75 | if (!module.parent) {
76 | app.listen(process.env.AUTOMOCK_PORT || 8000);
77 | const ProxyServer = require('./proxy_server');
78 | proxyServer = new ProxyServer();
79 | proxyServer.start();
80 | }
81 |
82 |
83 | module.exports = app;
84 |
--------------------------------------------------------------------------------
/server/src/models/selected_file.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | const sequelize = require('./../db/sequelize');
3 | const SelectedFile = sequelize.define('selected_files', {
4 | name: { type: Sequelize.STRING },
5 | method: { type: Sequelize.STRING },
6 | uri: { type: Sequelize.STRING }
7 | }, {
8 | freezeTableName: true
9 | });
10 |
11 | module.exports = SelectedFile;
12 |
--------------------------------------------------------------------------------
/server/src/proxy_server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const httpProxy = require('http-proxy');
4 | const SelectedFile = require('./models/selected_file');
5 | const _ = require('underscore');
6 | const fs = require('fs');
7 |
8 | class ProxyServer {
9 | constructor() {
10 | const targetPort = process.env.AUTOMOCK_TARGET_PORT || 3000;
11 | const proxyPort = process.env.AUTOMOCK_PROXY_PORT || 8001;
12 | this.server = httpProxy.createProxyServer({ target:`http://localhost:${targetPort}` }).listen(proxyPort);
13 | this.selectedFiles = [];
14 | }
15 |
16 | loadSelectedFiles() {
17 | return SelectedFile.findAll().then((records) => {
18 | this.selectedFiles = records;
19 | });
20 | }
21 |
22 | start() {
23 | this.server.on('proxyRes', (_proxyRes, req, res) => {
24 | const lookupedSelectedFile = _.find(this.selectedFiles, (selectedFile) =>
25 | (selectedFile.uri === req.url) && (selectedFile.method === req.method)
26 | );
27 | if (lookupedSelectedFile) {
28 | const write = res.write, writeHead = res.writeHead, end = res.end, bufs = [];
29 | res.writeHead = (_status, _headers) => {
30 | res.write = (body) => {
31 | bufs.push(body);
32 | };
33 | res.end = () => {
34 | fs.readFile(`${process.env.AUTOMOCK_DATA_PATH}/${lookupedSelectedFile.name}`, 'utf8', (_err, text) => {
35 | const mockData = JSON.parse(text);
36 | writeHead.call(res, mockData.status, mockData.response_header);
37 | write.call(res, mockData.response_body);
38 | end.call(res);
39 | });
40 | };
41 | };
42 | }
43 | });
44 | return this.loadSelectedFiles();
45 | }
46 | }
47 |
48 | module.exports = ProxyServer;
49 |
--------------------------------------------------------------------------------
/server/test/fixtures/mock/api/v1/api_test.json:
--------------------------------------------------------------------------------
1 | {"description":"description","method":"GET","uri":"/api/v1/users","status": "200","response_body":"{\"users\":[{\"username\":\"sample\",\"email\":\"sample@ggg.com\"}]}"}
2 |
--------------------------------------------------------------------------------
/server/test/fixtures/mock/test.json:
--------------------------------------------------------------------------------
1 | {"description":"This is test API","method":"GET","uri":"/test.json","status":200,"response_header":{"X-Frame-Options":"SAMEORIGIN","X-XSS-Protection":"1; mode=block","X-Content-Type-Options":"nosniff","Content-Type":"application/json; charset=utf-8","ETag":"W/\"e224cce5657514dd4f022471dc9261c6\"","Cache-Control":"max-age=0, private, must-revalidate","X-Request-Id":"fbdd7722-e642-4a49-8837-f3c14cc72a4e","X-Runtime":"0.009382","Content-Length":"42"},"response_body":"{\"users\":[{\"user\":{\"name\":\"dummy user\"}}]}"}
2 |
--------------------------------------------------------------------------------
/server/test/request/common_hooks.js:
--------------------------------------------------------------------------------
1 | process.env.AUTOMOCK_DATA_PATH=__dirname + '/../fixtures/mock';
2 | process.env.NODE_ENV='test';
3 |
4 | const sequelize = require('../../dist/db/sequelize');
5 | const SelectedFile = require('../../dist/models/selected_file');
6 |
7 | before(function() {
8 | const execSync = require('child_process').execSync;
9 | execSync('node ./node_modules/db-migrate/bin/db-migrate up --config src/db/database.json -e test');
10 | });
11 |
12 | beforeEach(function (done) {
13 | SelectedFile.truncate().then(() => done());
14 | });
15 |
16 | after(function(done) {
17 | sequelize.
18 | getQueryInterface().
19 | dropAllTables().then(() => done());
20 | });
21 |
--------------------------------------------------------------------------------
/server/test/request/mock_files_test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('./common_hooks');
4 | const request = require('supertest');
5 |
6 | let server;
7 | describe('GET /mock_files', function () {
8 | beforeEach(function () {
9 | server = require('./../../dist/index');
10 | });
11 | it('receives mock_files and 200', function testSlash(done) {
12 | request(server).
13 | get('/mock_files').
14 | expect(200, [
15 | {
16 | "description": "This is test API",
17 | "method": "GET",
18 | "name": "test.json",
19 | "response_body": "{\"users\":[{\"user\":{\"name\":\"dummy user\"}}]}",
20 | "response_header": {
21 | "Cache-Control": "max-age=0, private, must-revalidate",
22 | "Content-Length": "42",
23 | "Content-Type": "application/json; charset=utf-8",
24 | "ETag": "W/\"e224cce5657514dd4f022471dc9261c6\"",
25 | "X-Content-Type-Options": "nosniff",
26 | "X-Frame-Options": "SAMEORIGIN",
27 | "X-Request-Id": "fbdd7722-e642-4a49-8837-f3c14cc72a4e",
28 | "X-Runtime": "0.009382",
29 | "X-XSS-Protection": "1; mode=block"
30 | },
31 | "status": 200,
32 | "uri": "/test.json"
33 | },
34 | {
35 | description: 'description',
36 | method: 'GET',
37 | name: 'api/v1/api_test.json',
38 | status: '200',
39 | response_body: '{\"users\":[{\"username\":\"sample\",\"email\":\"sample@ggg.com\"}]}',
40 | uri: '/api/v1/users'
41 | }
42 | ], done);
43 | });
44 | });
45 |
46 |
--------------------------------------------------------------------------------
/server/test/request/proxy_server_test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('./common_hooks');
4 | const request = require('superagent');
5 | const assert = require('power-assert');
6 |
7 | const http = require('http');
8 | const ProxyServer = require('../../src/proxy_server');
9 | const SelectedFile = require('../../dist/models/selected_file');
10 | const fs = require('fs');
11 |
12 | let targetServer;
13 | let proxy;
14 | describe('ProxyServer', () => {
15 | before(() => {
16 | process.env.AUTOMOCK_PROXY_PORT = 9999;
17 | process.env.AUTOMOCK_TARGET_PORT = 9998;
18 | targetServer = http.createServer((_req, res) => {
19 | res.writeHead(200, { 'Content-Type': 'text/plain' });
20 | res.end('Hello World');
21 | });
22 | targetServer.listen(process.env.AUTOMOCK_TARGET_PORT, '127.0.0.1');
23 | proxy = new ProxyServer();
24 | });
25 | after(() => {
26 | targetServer.close();
27 | });
28 |
29 | context('has generated mock_data', () => {
30 | beforeEach((done) => {
31 | SelectedFile.create({ name: 'test.json', uri: '/test.json', method: 'GET' }).then(() => {
32 | proxy.start().then(done);
33 | });
34 | });
35 | it('receives mocked response data.', (done) => {
36 | request.get('http://127.0.0.1:9999/test.json').
37 | end((_err, res) => {
38 | fs.readFile(`${process.env.AUTOMOCK_DATA_PATH}/test.json`, 'utf8', (__err, text) => {
39 | const expected = JSON.parse(text);
40 | assert.equal(res.text, expected.response_body);
41 | assert.equal(res.header['Content-Length'], expected.response_header['content-length']);
42 | done();
43 | });
44 | });
45 | });
46 | });
47 | context("doesn't have generated mock_data", () => {
48 | beforeEach((done) => {
49 | proxy.start().then(done);
50 | });
51 | it('passes through response.', (done) => {
52 | request.get('http://127.0.0.1:9999/test.json').
53 | end((_err, res) => {
54 | assert.equal(res.text, 'Hello World');
55 | done();
56 | });
57 | });
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/server/test/request/selected_files_test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | require('./common_hooks');
4 | const request = require('supertest');
5 | const SelectedFile = require('../../dist/models/selected_file');
6 | const assert = require('power-assert');
7 |
8 | let server;
9 | describe('GET /selected_files', function () {
10 | context('has existing mock_data', () => {
11 | beforeEach(function () {
12 | server = require('./../../dist/index');
13 | SelectedFile.create({ name: 'test.json' });
14 | });
15 | it('get selectedFiles and receives 200', function testSlash(done) {
16 | request(server).
17 | get('/selected_files').
18 | expect(200).
19 | end((_err, response) => {
20 | assert(response.body.length === 1);
21 | assert(response.body[0].name === 'test.json');
22 | assert(!!response.body[0].id);
23 | done();
24 | });
25 | });
26 | });
27 |
28 | context("hasn't existing mock_data", () => {
29 | beforeEach(function (done) {
30 | server = require('./../../dist/index');
31 | SelectedFile.create({ name: 'not_exist_file.json' }).then(done());
32 | });
33 | it('get [] and receives 200', function testSlash(done) {
34 | request(server).
35 | get('/selected_files').
36 | expect(200).
37 | end((_err, response) => {
38 | assert(response.body.length === 0);
39 | done();
40 | });
41 | });
42 | });
43 | });
44 |
45 | describe('POST /selected_files', function () {
46 | beforeEach(function () {
47 | server = require('./../../dist/index');
48 | });
49 | it('creates new selectedFile and receives 201', function testSlash(done) {
50 | request(server).
51 | post('/selected_files').
52 | send({ name: 'bar', method: 'GET', uri: '/api/v1/test' }).
53 | expect(201).
54 | end(() => {
55 | SelectedFile.findAll().then((result) => {
56 | assert(result.length === 1);
57 | assert(result[0].name === 'bar');
58 | assert(result[0].method === 'GET');
59 | assert(result[0].uri === '/api/v1/test');
60 | done();
61 | });
62 | });
63 | });
64 | });
65 |
66 |
67 | describe('DELETE /selected_files/:id', function () {
68 | beforeEach(function () {
69 | server = require('./../../dist/index');
70 | });
71 | it('delete the selectedFile and receives 204', function testSlash(done) {
72 | SelectedFile.create({ name: 'api/v1/joes_secret_file' }).then((result) => {
73 | request(server).delete('/selected_files/' + result.id).expect(204).end(() => {
74 | SelectedFile.count().then((count) => {
75 | assert(count === 0);
76 | done();
77 | });
78 | });
79 | });
80 | });
81 | });
82 |
--------------------------------------------------------------------------------
/spec/automock_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'json'
3 |
4 | describe Automock do
5 | before(:all) do
6 | @file_text = File.open(
7 | File.expand_path(
8 | './fixtures/data/api/v1/users/GET_This_is_test_API.json', File.dirname(__FILE__)
9 | )
10 | ).read
11 | end
12 |
13 | describe 'make correct file content' do
14 | it 'has description' do
15 | expect(JSON.parse(@file_text)['description']).to eq 'This is test API'
16 | end
17 |
18 | it 'has HTTP method' do
19 | expect(JSON.parse(@file_text)['method']).to eq 'GET'
20 | end
21 |
22 | it 'has uri' do
23 | expect(JSON.parse(@file_text)['uri']).to eq '/api/v1/users'
24 | end
25 |
26 | it 'has response header' do
27 | expect(JSON.parse(@file_text)['response_header']).to include 'Content-Type'
28 | end
29 |
30 | let(:expected_body) { { users: [{ user: { name: 'dummy user' } }] }.to_json }
31 | it 'has response body' do
32 | expect(JSON.parse(@file_text)['response_body']).to eq expected_body
33 | end
34 |
35 | it 'has status_code' do
36 | expect(JSON.parse(@file_text)['status']).to eq 200
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/spec/dummy/.gitignore:
--------------------------------------------------------------------------------
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 the default SQLite database.
11 | /db/*.sqlite3
12 | /db/*.sqlite3-journal
13 |
14 | # Ignore all logfiles and tempfiles.
15 | /log/*
16 | !/log/.keep
17 | /tmp
18 | /automock
19 |
--------------------------------------------------------------------------------
/spec/dummy/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | --require spec_helper
3 |
--------------------------------------------------------------------------------
/spec/dummy/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 |
4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5 | gem 'rails', '4.2.5'
6 | # Use sqlite3 as the database for Active Record
7 | gem 'sqlite3'
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 | gem 'rspec'
39 | gem 'rspec-rails', '~> 3.0'
40 | end
41 |
42 | group :development do
43 | # Access an IRB console on exception pages or by using <%= console %> in views
44 | gem 'web-console', '~> 2.0'
45 |
46 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
47 | gem 'spring'
48 | end
49 |
50 |
--------------------------------------------------------------------------------
/spec/dummy/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actionmailer (4.2.5)
5 | actionpack (= 4.2.5)
6 | actionview (= 4.2.5)
7 | activejob (= 4.2.5)
8 | mail (~> 2.5, >= 2.5.4)
9 | rails-dom-testing (~> 1.0, >= 1.0.5)
10 | actionpack (4.2.5)
11 | actionview (= 4.2.5)
12 | activesupport (= 4.2.5)
13 | rack (~> 1.6)
14 | rack-test (~> 0.6.2)
15 | rails-dom-testing (~> 1.0, >= 1.0.5)
16 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
17 | actionview (4.2.5)
18 | activesupport (= 4.2.5)
19 | builder (~> 3.1)
20 | erubis (~> 2.7.0)
21 | rails-dom-testing (~> 1.0, >= 1.0.5)
22 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
23 | activejob (4.2.5)
24 | activesupport (= 4.2.5)
25 | globalid (>= 0.3.0)
26 | activemodel (4.2.5)
27 | activesupport (= 4.2.5)
28 | builder (~> 3.1)
29 | activerecord (4.2.5)
30 | activemodel (= 4.2.5)
31 | activesupport (= 4.2.5)
32 | arel (~> 6.0)
33 | activesupport (4.2.5)
34 | i18n (~> 0.7)
35 | json (~> 1.7, >= 1.7.7)
36 | minitest (~> 5.1)
37 | thread_safe (~> 0.3, >= 0.3.4)
38 | tzinfo (~> 1.1)
39 | arel (6.0.3)
40 | binding_of_caller (0.7.2)
41 | debug_inspector (>= 0.0.1)
42 | builder (3.2.2)
43 | byebug (8.2.1)
44 | coffee-rails (4.1.1)
45 | coffee-script (>= 2.2.0)
46 | railties (>= 4.0.0, < 5.1.x)
47 | coffee-script (2.4.1)
48 | coffee-script-source
49 | execjs
50 | coffee-script-source (1.10.0)
51 | concurrent-ruby (1.0.0)
52 | debug_inspector (0.0.2)
53 | diff-lcs (1.2.5)
54 | erubis (2.7.0)
55 | execjs (2.6.0)
56 | globalid (0.3.6)
57 | activesupport (>= 4.1.0)
58 | i18n (0.7.0)
59 | jbuilder (2.4.0)
60 | activesupport (>= 3.0.0, < 5.1)
61 | multi_json (~> 1.2)
62 | jquery-rails (4.0.5)
63 | rails-dom-testing (~> 1.0)
64 | railties (>= 4.2.0)
65 | thor (>= 0.14, < 2.0)
66 | json (1.8.3)
67 | loofah (2.0.3)
68 | nokogiri (>= 1.5.9)
69 | mail (2.6.3)
70 | mime-types (>= 1.16, < 3)
71 | mime-types (2.99)
72 | mini_portile2 (2.0.0)
73 | minitest (5.8.3)
74 | multi_json (1.11.2)
75 | nokogiri (1.6.7.1)
76 | mini_portile2 (~> 2.0.0.rc2)
77 | rack (1.6.4)
78 | rack-test (0.6.3)
79 | rack (>= 1.0)
80 | rails (4.2.5)
81 | actionmailer (= 4.2.5)
82 | actionpack (= 4.2.5)
83 | actionview (= 4.2.5)
84 | activejob (= 4.2.5)
85 | activemodel (= 4.2.5)
86 | activerecord (= 4.2.5)
87 | activesupport (= 4.2.5)
88 | bundler (>= 1.3.0, < 2.0)
89 | railties (= 4.2.5)
90 | sprockets-rails
91 | rails-deprecated_sanitizer (1.0.3)
92 | activesupport (>= 4.2.0.alpha)
93 | rails-dom-testing (1.0.7)
94 | activesupport (>= 4.2.0.beta, < 5.0)
95 | nokogiri (~> 1.6.0)
96 | rails-deprecated_sanitizer (>= 1.0.1)
97 | rails-html-sanitizer (1.0.2)
98 | loofah (~> 2.0)
99 | railties (4.2.5)
100 | actionpack (= 4.2.5)
101 | activesupport (= 4.2.5)
102 | rake (>= 0.8.7)
103 | thor (>= 0.18.1, < 2.0)
104 | rake (10.4.2)
105 | rdoc (4.2.1)
106 | json (~> 1.4)
107 | rspec (3.4.0)
108 | rspec-core (~> 3.4.0)
109 | rspec-expectations (~> 3.4.0)
110 | rspec-mocks (~> 3.4.0)
111 | rspec-core (3.4.1)
112 | rspec-support (~> 3.4.0)
113 | rspec-expectations (3.4.0)
114 | diff-lcs (>= 1.2.0, < 2.0)
115 | rspec-support (~> 3.4.0)
116 | rspec-mocks (3.4.0)
117 | diff-lcs (>= 1.2.0, < 2.0)
118 | rspec-support (~> 3.4.0)
119 | rspec-rails (3.4.0)
120 | actionpack (>= 3.0, < 4.3)
121 | activesupport (>= 3.0, < 4.3)
122 | railties (>= 3.0, < 4.3)
123 | rspec-core (~> 3.4.0)
124 | rspec-expectations (~> 3.4.0)
125 | rspec-mocks (~> 3.4.0)
126 | rspec-support (~> 3.4.0)
127 | rspec-support (3.4.1)
128 | sass (3.4.20)
129 | sass-rails (5.0.4)
130 | railties (>= 4.0.0, < 5.0)
131 | sass (~> 3.1)
132 | sprockets (>= 2.8, < 4.0)
133 | sprockets-rails (>= 2.0, < 4.0)
134 | tilt (>= 1.1, < 3)
135 | sdoc (0.4.1)
136 | json (~> 1.7, >= 1.7.7)
137 | rdoc (~> 4.0)
138 | spring (1.6.1)
139 | sprockets (3.5.2)
140 | concurrent-ruby (~> 1.0)
141 | rack (> 1, < 3)
142 | sprockets-rails (3.0.0)
143 | actionpack (>= 4.0)
144 | activesupport (>= 4.0)
145 | sprockets (>= 3.0.0)
146 | sqlite3 (1.3.11)
147 | thor (0.19.1)
148 | thread_safe (0.3.5)
149 | tilt (2.0.1)
150 | turbolinks (2.5.3)
151 | coffee-rails
152 | tzinfo (1.2.2)
153 | thread_safe (~> 0.1)
154 | uglifier (2.7.2)
155 | execjs (>= 0.3.0)
156 | json (>= 1.8.0)
157 | web-console (2.2.1)
158 | activemodel (>= 4.0)
159 | binding_of_caller (>= 0.7.2)
160 | railties (>= 4.0)
161 | sprockets-rails (>= 2.0, < 4.0)
162 |
163 | PLATFORMS
164 | ruby
165 |
166 | DEPENDENCIES
167 | byebug
168 | coffee-rails (~> 4.1.0)
169 | jbuilder (~> 2.0)
170 | jquery-rails
171 | rails (= 4.2.5)
172 | rspec
173 | rspec-rails (~> 3.0)
174 | sass-rails (~> 5.0)
175 | sdoc (~> 0.4.0)
176 | spring
177 | sqlite3
178 | turbolinks
179 | uglifier (>= 1.3.0)
180 | web-console (~> 2.0)
181 |
182 | BUNDLED WITH
183 | 1.11.2
184 |
--------------------------------------------------------------------------------
/spec/dummy/README.rdoc:
--------------------------------------------------------------------------------
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 | rake doc:app.
29 |
--------------------------------------------------------------------------------
/spec/dummy/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require File.expand_path('../config/application', __FILE__)
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/app/assets/images/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
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 .
17 |
--------------------------------------------------------------------------------
/spec/dummy/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
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 | */
16 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | # Prevent CSRF attacks by raising an exception.
3 | # For APIs, you may want to use :null_session instead.
4 | protect_from_forgery with: :exception
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/controllers/dummy_api_controller.rb:
--------------------------------------------------------------------------------
1 | class DummyApiController < ApplicationController
2 | def index
3 | render json: {
4 | users: [user: { name: 'dummy user' }]
5 | }
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/spec/dummy/app/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/app/mailers/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/app/models/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/app/models/concerns/.keep
--------------------------------------------------------------------------------
/spec/dummy/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Dummy
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 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/spec/dummy/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../../config/application', __FILE__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/spec/dummy/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/spec/dummy/bin/setup:
--------------------------------------------------------------------------------
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
30 |
--------------------------------------------------------------------------------
/spec/dummy/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11 | Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12 | gem 'spring', match[1]
13 | require 'spring/binstub'
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/spec/dummy/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require "rails"
4 | # Pick the frameworks you want:
5 | require "active_model/railtie"
6 | require "active_job/railtie"
7 | require "active_record/railtie"
8 | require "action_controller/railtie"
9 | require "action_mailer/railtie"
10 | require "action_view/railtie"
11 | require "sprockets/railtie"
12 | # require "rails/test_unit/railtie"
13 |
14 | # Require the gems listed in Gemfile, including any gems
15 | # you've limited to :test, :development, or :production.
16 | Bundler.require(*Rails.groups)
17 |
18 | module Dummy
19 | class Application < Rails::Application
20 | # Settings in config/environments/* take precedence over those specified here.
21 | # Application configuration should go into files in config/initializers
22 | # -- all .rb files in that directory are automatically loaded.
23 |
24 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26 | # config.time_zone = 'Central Time (US & Canada)'
27 |
28 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30 | # config.i18n.default_locale = :de
31 |
32 | # Do not swallow errors in after_commit/after_rollback callbacks.
33 | config.active_record.raise_in_transactional_callbacks = true
34 |
35 | config.autoload_paths += %W(#{config.root}/lib/automock)
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/spec/dummy/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | #
7 | default: &default
8 | adapter: sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | development:
13 | <<: *default
14 | database: db/development.sqlite3
15 |
16 | # Warning: The database defined as "test" will be erased and
17 | # re-generated from your development database when you run "rake".
18 | # Do not set this db to the same as development or production.
19 | test:
20 | <<: *default
21 | database: db/test.sqlite3
22 |
23 | production:
24 | <<: *default
25 | database: db/production.sqlite3
26 |
--------------------------------------------------------------------------------
/spec/dummy/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations.
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true
29 |
30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31 | # yet still be able to expire them through the digest params.
32 | config.assets.digest = true
33 |
34 | # Adds additional error checking when serving assets at runtime.
35 | # Checks for improperly declared sprockets dependencies.
36 | # Raises helpful error messages.
37 | config.assets.raise_runtime_errors = true
38 |
39 | # Raises error for missing translations
40 | # config.action_view.raise_on_missing_translations = true
41 | end
42 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like
20 | # NGINX, varnish or squid.
21 | # config.action_dispatch.rack_cache = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35 | # yet still be able to expire them through the digest params.
36 | config.assets.digest = true
37 |
38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39 |
40 | # Specifies the header that your server uses for sending files.
41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43 |
44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45 | # config.force_ssl = true
46 |
47 | # Use the lowest log level to ensure availability of diagnostic information
48 | # when problems arise.
49 | config.log_level = :debug
50 |
51 | # Prepend all log lines with the following tags.
52 | # config.log_tags = [ :subdomain, :uuid ]
53 |
54 | # Use a different logger for distributed setups.
55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61 | # config.action_controller.asset_host = 'http://assets.example.com'
62 |
63 | # Ignore bad email addresses and do not raise email delivery errors.
64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65 | # config.action_mailer.raise_delivery_errors = false
66 |
67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68 | # the I18n.default_locale when a translation cannot be found).
69 | config.i18n.fallbacks = true
70 |
71 | # Send deprecation notices to registered listeners.
72 | config.active_support.deprecation = :notify
73 |
74 | # Use default logging formatter so that PID and timestamp are not suppressed.
75 | config.log_formatter = ::Logger::Formatter.new
76 |
77 | # Do not dump schema after migrations.
78 | config.active_record.dump_schema_after_migration = false
79 | end
80 |
--------------------------------------------------------------------------------
/spec/dummy/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure static file server for tests with Cache-Control for performance.
16 | config.serve_static_files = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Randomize the order test cases are executed.
35 | config.active_support.test_order = :random
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_dummy_session'
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/spec/dummy/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/spec/dummy/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | get path: '/api/v1/users', controller: :dummy_api, action: 'index'
3 | end
4 |
--------------------------------------------------------------------------------
/spec/dummy/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 436e9bc2ae22c32a36e319e98d673bc66e04808ec89ceb75f81fe68f41e3a3b5a6186f2535d355cdff0adba3ced8d170e36d793eeb09dff910ea00191a704323
15 |
16 | test:
17 | secret_key_base: bcc15e798ce664b7450fa6dfbe0676b707799c364b0596cca33e2b0d16b6a4a46627af270767928bcde1ba5681629e99f30afa4e86be1c111f8fec29f24e86c5
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/spec/dummy/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
--------------------------------------------------------------------------------
/spec/dummy/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/lib/assets/.keep
--------------------------------------------------------------------------------
/spec/dummy/lib/automock:
--------------------------------------------------------------------------------
1 | ./../../../lib
--------------------------------------------------------------------------------
/spec/dummy/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/lib/tasks/.keep
--------------------------------------------------------------------------------
/spec/dummy/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/log/.keep
--------------------------------------------------------------------------------
/spec/dummy/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/spec/dummy/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/spec/dummy/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/spec/dummy/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/public/favicon.ico
--------------------------------------------------------------------------------
/spec/dummy/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/spec/dummy/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | ENV['RAILS_ENV'] ||= 'test'
2 | require File.expand_path('../../config/environment', __FILE__)
3 | require 'automock'
4 | abort("The Rails environment is running in production mode!") if Rails.env.production?
5 | require 'rspec/rails'
6 |
--------------------------------------------------------------------------------
/spec/dummy/spec/requests/dummy_api.rb:
--------------------------------------------------------------------------------
1 | require_relative '../rails_helper'
2 |
3 | RSpec.describe 'users', type: :request do
4 | describe 'GET /api/v1/users' do
5 | context 'This is test API', automock: true do
6 | before do
7 | get '/api/v1/users'
8 | end
9 | it 'receives 200 and users json' do
10 | expect(response.status).to eq 200
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/dummy/vendor/assets/javascripts/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/vendor/assets/javascripts/.keep
--------------------------------------------------------------------------------
/spec/dummy/vendor/assets/stylesheets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joe-re/automock/a8f395627e587ae152ae0e0e12b3b36d756e2651/spec/dummy/vendor/assets/stylesheets/.keep
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2 | require 'automock'
3 |
4 | RSpec.configure do |config|
5 | config.before(:all) do
6 | system('bundle exec rake update_mockdata_fixtures')
7 | end
8 | end
9 |
--------------------------------------------------------------------------------