derail_specs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +25 -0
  4. data/.rubocop_todo.yml +47 -0
  5. data/.tool-versions +1 -0
  6. data/CHANGELOG.md +5 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +13 -0
  9. data/Gemfile.lock +122 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +85 -0
  12. data/Rakefile +12 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +8 -0
  15. data/derail_specs.gemspec +34 -0
  16. data/example/.gitignore +23 -0
  17. data/example/.ruby-version +1 -0
  18. data/example/Gemfile +15 -0
  19. data/example/Gemfile.lock +159 -0
  20. data/example/README.md +24 -0
  21. data/example/Rakefile +8 -0
  22. data/example/app/controllers/application_controller.rb +4 -0
  23. data/example/app/models/application_record.rb +5 -0
  24. data/example/app/views/layouts/application.html.erb +15 -0
  25. data/example/bin/bundle +118 -0
  26. data/example/bin/rails +6 -0
  27. data/example/bin/rake +6 -0
  28. data/example/bin/setup +35 -0
  29. data/example/config/application.rb +40 -0
  30. data/example/config/boot.rb +5 -0
  31. data/example/config/credentials.yml.enc +1 -0
  32. data/example/config/database.yml +25 -0
  33. data/example/config/environment.rb +7 -0
  34. data/example/config/environments/development.rb +62 -0
  35. data/example/config/environments/production.rb +98 -0
  36. data/example/config/environments/test.rb +51 -0
  37. data/example/config/initializers/application_controller_renderer.rb +9 -0
  38. data/example/config/initializers/backtrace_silencers.rb +10 -0
  39. data/example/config/initializers/content_security_policy.rb +29 -0
  40. data/example/config/initializers/cookies_serializer.rb +7 -0
  41. data/example/config/initializers/derail_specs.rb +3 -0
  42. data/example/config/initializers/filter_parameter_logging.rb +8 -0
  43. data/example/config/initializers/inflections.rb +17 -0
  44. data/example/config/initializers/mime_types.rb +5 -0
  45. data/example/config/initializers/permissions_policy.rb +12 -0
  46. data/example/config/initializers/wrap_parameters.rb +16 -0
  47. data/example/config/locales/en.yml +33 -0
  48. data/example/config/puma.rb +45 -0
  49. data/example/config/routes.rb +5 -0
  50. data/example/config.ru +8 -0
  51. data/example/public/404.html +67 -0
  52. data/example/public/422.html +67 -0
  53. data/example/public/500.html +66 -0
  54. data/example/public/apple-touch-icon-precomposed.png +0 -0
  55. data/example/public/apple-touch-icon.png +0 -0
  56. data/example/public/favicon.ico +0 -0
  57. data/example/public/robots.txt +1 -0
  58. data/example/tests.sh +4 -0
  59. data/lib/derail_specs/boot.rb +28 -0
  60. data/lib/derail_specs/railtie.rb +7 -0
  61. data/lib/derail_specs/server/app.rb +15 -0
  62. data/lib/derail_specs/server/checker.rb +43 -0
  63. data/lib/derail_specs/server/middleware.rb +67 -0
  64. data/lib/derail_specs/server/puma.rb +32 -0
  65. data/lib/derail_specs/server/timer.rb +20 -0
  66. data/lib/derail_specs/server.rb +117 -0
  67. data/lib/derail_specs/transaction.rb +84 -0
  68. data/lib/derail_specs/version.rb +5 -0
  69. data/lib/derail_specs.rb +24 -0
  70. data/lib/generators/derail_specs/install_generator.rb +16 -0
  71. data/lib/generators/templates/config/initializers/derail_specs.rb +5 -0
  72. data/lib/tasks/derail_specs.rake +5 -0
  73. metadata +145 -0
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/derail_specs/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "derail_specs"
7
+ spec.version = DerailSpecs::VERSION
8
+ spec.authors = ["Alex Piechowski"]
9
+ spec.email = ["alex@piechowski.io"]
10
+
11
+ spec.summary = "Rails test server for external tests."
12
+ # spec.description = ""
13
+ spec.homepage = "https://github.com/roshreview/derail_specs"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/roshreview/derail_specs"
19
+ spec.metadata["changelog_uri"] = "https://github.com/roshreview/derail_specs/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "puma", ">= 3.8.0"
33
+ spec.add_dependency "railties", ">= 5.2.0"
34
+ end
@@ -0,0 +1,23 @@
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-*
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ /tmp/*
17
+
18
+
19
+ /public/assets
20
+ .byebug_history
21
+
22
+ # Ignore master key for decrypting credentials and more.
23
+ /config/master.key
@@ -0,0 +1 @@
1
+ ruby-3.0.2
data/example/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ ruby '3.0.2'
7
+
8
+ gem 'puma', '~> 5.0'
9
+ gem 'rails', '~> 6.1.4', '>= 6.1.4.1'
10
+ gem 'sqlite3', '~> 1.4'
11
+
12
+ group :development, :test do
13
+ gem "derail_specs", path: '..'
14
+ gem 'pry-rails'
15
+ end
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ derail_specs (0.1.0)
5
+ puma (>= 3.8.0)
6
+ railties (>= 5.2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.1.4.1)
12
+ actionpack (= 6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.1.4.1)
17
+ actionpack (= 6.1.4.1)
18
+ activejob (= 6.1.4.1)
19
+ activerecord (= 6.1.4.1)
20
+ activestorage (= 6.1.4.1)
21
+ activesupport (= 6.1.4.1)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.1.4.1)
24
+ actionpack (= 6.1.4.1)
25
+ actionview (= 6.1.4.1)
26
+ activejob (= 6.1.4.1)
27
+ activesupport (= 6.1.4.1)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.1.4.1)
31
+ actionview (= 6.1.4.1)
32
+ activesupport (= 6.1.4.1)
33
+ rack (~> 2.0, >= 2.0.9)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.1.4.1)
38
+ actionpack (= 6.1.4.1)
39
+ activerecord (= 6.1.4.1)
40
+ activestorage (= 6.1.4.1)
41
+ activesupport (= 6.1.4.1)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.1.4.1)
44
+ activesupport (= 6.1.4.1)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.1.4.1)
50
+ activesupport (= 6.1.4.1)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.1.4.1)
53
+ activesupport (= 6.1.4.1)
54
+ activerecord (6.1.4.1)
55
+ activemodel (= 6.1.4.1)
56
+ activesupport (= 6.1.4.1)
57
+ activestorage (6.1.4.1)
58
+ actionpack (= 6.1.4.1)
59
+ activejob (= 6.1.4.1)
60
+ activerecord (= 6.1.4.1)
61
+ activesupport (= 6.1.4.1)
62
+ marcel (~> 1.0.0)
63
+ mini_mime (>= 1.1.0)
64
+ activesupport (6.1.4.1)
65
+ concurrent-ruby (~> 1.0, >= 1.0.2)
66
+ i18n (>= 1.6, < 2)
67
+ minitest (>= 5.1)
68
+ tzinfo (~> 2.0)
69
+ zeitwerk (~> 2.3)
70
+ builder (3.2.4)
71
+ coderay (1.1.3)
72
+ concurrent-ruby (1.1.9)
73
+ crass (1.0.6)
74
+ erubi (1.10.0)
75
+ globalid (0.5.2)
76
+ activesupport (>= 5.0)
77
+ i18n (1.8.10)
78
+ concurrent-ruby (~> 1.0)
79
+ loofah (2.12.0)
80
+ crass (~> 1.0.2)
81
+ nokogiri (>= 1.5.9)
82
+ mail (2.7.1)
83
+ mini_mime (>= 0.1.1)
84
+ marcel (1.0.1)
85
+ method_source (1.0.0)
86
+ mini_mime (1.1.1)
87
+ minitest (5.14.4)
88
+ nio4r (2.5.8)
89
+ nokogiri (1.12.4-x86_64-linux)
90
+ racc (~> 1.4)
91
+ pry (0.14.1)
92
+ coderay (~> 1.1)
93
+ method_source (~> 1.0)
94
+ pry-rails (0.3.9)
95
+ pry (>= 0.10.4)
96
+ puma (5.4.0)
97
+ nio4r (~> 2.0)
98
+ racc (1.5.2)
99
+ rack (2.2.3)
100
+ rack-test (1.1.0)
101
+ rack (>= 1.0, < 3)
102
+ rails (6.1.4.1)
103
+ actioncable (= 6.1.4.1)
104
+ actionmailbox (= 6.1.4.1)
105
+ actionmailer (= 6.1.4.1)
106
+ actionpack (= 6.1.4.1)
107
+ actiontext (= 6.1.4.1)
108
+ actionview (= 6.1.4.1)
109
+ activejob (= 6.1.4.1)
110
+ activemodel (= 6.1.4.1)
111
+ activerecord (= 6.1.4.1)
112
+ activestorage (= 6.1.4.1)
113
+ activesupport (= 6.1.4.1)
114
+ bundler (>= 1.15.0)
115
+ railties (= 6.1.4.1)
116
+ sprockets-rails (>= 2.0.0)
117
+ rails-dom-testing (2.0.3)
118
+ activesupport (>= 4.2.0)
119
+ nokogiri (>= 1.6)
120
+ rails-html-sanitizer (1.4.2)
121
+ loofah (~> 2.3)
122
+ railties (6.1.4.1)
123
+ actionpack (= 6.1.4.1)
124
+ activesupport (= 6.1.4.1)
125
+ method_source
126
+ rake (>= 0.13)
127
+ thor (~> 1.0)
128
+ rake (13.0.6)
129
+ sprockets (4.0.2)
130
+ concurrent-ruby (~> 1.0)
131
+ rack (> 1, < 3)
132
+ sprockets-rails (3.2.2)
133
+ actionpack (>= 4.0)
134
+ activesupport (>= 4.0)
135
+ sprockets (>= 3.0.0)
136
+ sqlite3 (1.4.2)
137
+ thor (1.1.0)
138
+ tzinfo (2.0.4)
139
+ concurrent-ruby (~> 1.0)
140
+ websocket-driver (0.7.5)
141
+ websocket-extensions (>= 0.1.0)
142
+ websocket-extensions (0.1.5)
143
+ zeitwerk (2.4.2)
144
+
145
+ PLATFORMS
146
+ x86_64-linux
147
+
148
+ DEPENDENCIES
149
+ derail_specs!
150
+ pry-rails
151
+ puma (~> 5.0)
152
+ rails (~> 6.1.4, >= 6.1.4.1)
153
+ sqlite3 (~> 1.4)
154
+
155
+ RUBY VERSION
156
+ ruby 3.0.2p107
157
+
158
+ BUNDLED WITH
159
+ 2.2.27
data/example/README.md ADDED
@@ -0,0 +1,24 @@
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
+ * ...
data/example/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative "config/application"
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Example</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= stylesheet_link_tag 'application', media: 'all' %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+
28
+ bundler_version = nil
29
+ update_index = nil
30
+ ARGV.each_with_index do |a, i|
31
+ bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
32
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
33
+
34
+ bundler_version = Regexp.last_match(1)
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path('../Gemfile', __dir__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+
59
+ lockfile_contents = File.read(lockfile)
60
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
61
+
62
+ Regexp.last_match(1)
63
+ end
64
+
65
+ def bundler_requirement
66
+ @bundler_requirement ||=
67
+ env_var_version || cli_arg_version ||
68
+ bundler_requirement_for(lockfile_version)
69
+ end
70
+
71
+ def bundler_requirement_for(version)
72
+ return "#{Gem::Requirement.default}.a" unless version
73
+
74
+ bundler_gem_version = Gem::Version.new(version)
75
+
76
+ requirement = bundler_gem_version.approximate_recommendation
77
+
78
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
79
+
80
+ requirement += ".a" if bundler_gem_version.prerelease?
81
+
82
+ requirement
83
+ end
84
+
85
+ def load_bundler!
86
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
87
+
88
+ activate_bundler
89
+ end
90
+
91
+ def activate_bundler
92
+ gem_error = activation_error_handling do
93
+ gem "bundler", bundler_requirement
94
+ end
95
+ return if gem_error.nil?
96
+
97
+ require_error = activation_error_handling do
98
+ require "bundler/version"
99
+ end
100
+ if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
101
+ return
102
+ end
103
+
104
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
105
+ exit 42
106
+ end
107
+
108
+ def activation_error_handling
109
+ yield
110
+ nil
111
+ rescue StandardError, LoadError => e
112
+ e
113
+ end
114
+ end
115
+
116
+ m.load_bundler!
117
+
118
+ load Gem.bin_path("bundler", "bundle") if m.invoked_as_script?
data/example/bin/rails ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative "../config/boot"
6
+ require "rails/commands"
data/example/bin/rake ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../config/boot"
5
+ require "rake"
6
+ Rake.application.run