sidekiq 6.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +71 -0
  3. data/.github/contributing.md +32 -0
  4. data/.github/issue_template.md +11 -0
  5. data/.gitignore +13 -0
  6. data/.standard.yml +20 -0
  7. data/3.0-Upgrade.md +70 -0
  8. data/4.0-Upgrade.md +53 -0
  9. data/5.0-Upgrade.md +56 -0
  10. data/6.0-Upgrade.md +72 -0
  11. data/COMM-LICENSE +97 -0
  12. data/Changes.md +1718 -0
  13. data/Ent-2.0-Upgrade.md +37 -0
  14. data/Ent-Changes.md +269 -0
  15. data/Gemfile +24 -0
  16. data/Gemfile.lock +208 -0
  17. data/LICENSE +9 -0
  18. data/Pro-2.0-Upgrade.md +138 -0
  19. data/Pro-3.0-Upgrade.md +44 -0
  20. data/Pro-4.0-Upgrade.md +35 -0
  21. data/Pro-5.0-Upgrade.md +25 -0
  22. data/Pro-Changes.md +790 -0
  23. data/README.md +94 -0
  24. data/Rakefile +10 -0
  25. data/bin/sidekiq +42 -0
  26. data/bin/sidekiqload +157 -0
  27. data/bin/sidekiqmon +8 -0
  28. data/code_of_conduct.md +50 -0
  29. data/lib/generators/sidekiq/templates/worker.rb.erb +9 -0
  30. data/lib/generators/sidekiq/templates/worker_spec.rb.erb +6 -0
  31. data/lib/generators/sidekiq/templates/worker_test.rb.erb +8 -0
  32. data/lib/generators/sidekiq/worker_generator.rb +57 -0
  33. data/lib/sidekiq.rb +262 -0
  34. data/lib/sidekiq/api.rb +960 -0
  35. data/lib/sidekiq/cli.rb +401 -0
  36. data/lib/sidekiq/client.rb +263 -0
  37. data/lib/sidekiq/delay.rb +41 -0
  38. data/lib/sidekiq/exception_handler.rb +27 -0
  39. data/lib/sidekiq/extensions/action_mailer.rb +47 -0
  40. data/lib/sidekiq/extensions/active_record.rb +43 -0
  41. data/lib/sidekiq/extensions/class_methods.rb +43 -0
  42. data/lib/sidekiq/extensions/generic_proxy.rb +31 -0
  43. data/lib/sidekiq/fetch.rb +82 -0
  44. data/lib/sidekiq/job_logger.rb +63 -0
  45. data/lib/sidekiq/job_retry.rb +262 -0
  46. data/lib/sidekiq/launcher.rb +206 -0
  47. data/lib/sidekiq/logger.rb +165 -0
  48. data/lib/sidekiq/manager.rb +135 -0
  49. data/lib/sidekiq/middleware/chain.rb +160 -0
  50. data/lib/sidekiq/middleware/i18n.rb +40 -0
  51. data/lib/sidekiq/monitor.rb +133 -0
  52. data/lib/sidekiq/paginator.rb +47 -0
  53. data/lib/sidekiq/processor.rb +280 -0
  54. data/lib/sidekiq/rails.rb +50 -0
  55. data/lib/sidekiq/redis_connection.rb +146 -0
  56. data/lib/sidekiq/scheduled.rb +173 -0
  57. data/lib/sidekiq/sd_notify.rb +149 -0
  58. data/lib/sidekiq/systemd.rb +24 -0
  59. data/lib/sidekiq/testing.rb +344 -0
  60. data/lib/sidekiq/testing/inline.rb +30 -0
  61. data/lib/sidekiq/util.rb +67 -0
  62. data/lib/sidekiq/version.rb +5 -0
  63. data/lib/sidekiq/web.rb +213 -0
  64. data/lib/sidekiq/web/action.rb +93 -0
  65. data/lib/sidekiq/web/application.rb +357 -0
  66. data/lib/sidekiq/web/csrf_protection.rb +153 -0
  67. data/lib/sidekiq/web/helpers.rb +333 -0
  68. data/lib/sidekiq/web/router.rb +101 -0
  69. data/lib/sidekiq/worker.rb +244 -0
  70. data/sidekiq.gemspec +20 -0
  71. data/web/assets/images/favicon.ico +0 -0
  72. data/web/assets/images/logo.png +0 -0
  73. data/web/assets/images/status.png +0 -0
  74. data/web/assets/javascripts/application.js +95 -0
  75. data/web/assets/javascripts/dashboard.js +296 -0
  76. data/web/assets/stylesheets/application-dark.css +133 -0
  77. data/web/assets/stylesheets/application-rtl.css +246 -0
  78. data/web/assets/stylesheets/application.css +1158 -0
  79. data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
  80. data/web/assets/stylesheets/bootstrap.css +5 -0
  81. data/web/locales/ar.yml +81 -0
  82. data/web/locales/cs.yml +78 -0
  83. data/web/locales/da.yml +68 -0
  84. data/web/locales/de.yml +81 -0
  85. data/web/locales/el.yml +68 -0
  86. data/web/locales/en.yml +83 -0
  87. data/web/locales/es.yml +70 -0
  88. data/web/locales/fa.yml +80 -0
  89. data/web/locales/fr.yml +78 -0
  90. data/web/locales/he.yml +79 -0
  91. data/web/locales/hi.yml +75 -0
  92. data/web/locales/it.yml +69 -0
  93. data/web/locales/ja.yml +83 -0
  94. data/web/locales/ko.yml +68 -0
  95. data/web/locales/lt.yml +83 -0
  96. data/web/locales/nb.yml +77 -0
  97. data/web/locales/nl.yml +68 -0
  98. data/web/locales/pl.yml +59 -0
  99. data/web/locales/pt-br.yml +68 -0
  100. data/web/locales/pt.yml +67 -0
  101. data/web/locales/ru.yml +78 -0
  102. data/web/locales/sv.yml +68 -0
  103. data/web/locales/ta.yml +75 -0
  104. data/web/locales/uk.yml +76 -0
  105. data/web/locales/ur.yml +80 -0
  106. data/web/locales/vi.yml +83 -0
  107. data/web/locales/zh-cn.yml +68 -0
  108. data/web/locales/zh-tw.yml +68 -0
  109. data/web/views/_footer.erb +20 -0
  110. data/web/views/_job_info.erb +89 -0
  111. data/web/views/_nav.erb +52 -0
  112. data/web/views/_paging.erb +23 -0
  113. data/web/views/_poll_link.erb +7 -0
  114. data/web/views/_status.erb +4 -0
  115. data/web/views/_summary.erb +40 -0
  116. data/web/views/busy.erb +101 -0
  117. data/web/views/dashboard.erb +75 -0
  118. data/web/views/dead.erb +34 -0
  119. data/web/views/layout.erb +41 -0
  120. data/web/views/morgue.erb +78 -0
  121. data/web/views/queue.erb +55 -0
  122. data/web/views/queues.erb +38 -0
  123. data/web/views/retries.erb +83 -0
  124. data/web/views/retry.erb +34 -0
  125. data/web/views/scheduled.erb +57 -0
  126. data/web/views/scheduled_job_info.erb +8 -0
  127. metadata +212 -0
@@ -0,0 +1,94 @@
1
+ Sidekiq
2
+ ==============
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
5
+ [![Codecov](https://codecov.io/gh/mperham/sidekiq/branch/master/graph/badge.svg)](https://codecov.io/gh/mperham/sidekiq)
6
+ [![Build Status](https://circleci.com/gh/mperham/sidekiq/tree/master.svg?style=svg)](https://circleci.com/gh/mperham/sidekiq/tree/master)
7
+
8
+ Simple, efficient background processing for Ruby.
9
+
10
+ Sidekiq uses threads to handle many jobs at the same time in the
11
+ same process. It does not require Rails but will integrate tightly with
12
+ Rails to make background processing dead simple.
13
+
14
+ Performance
15
+ ---------------
16
+
17
+ Version | Latency | Garbage created for 10k jobs | Time to process 100k jobs | Throughput | Ruby
18
+ -----------------|------|---------|---------|------------------------|-----
19
+ Sidekiq 6.0.2 | 3 ms | 156 MB | 14.0 sec| **7100 jobs/sec** | MRI 2.6.3
20
+ Sidekiq 6.0.0 | 3 ms | 156 MB | 19 sec | 5200 jobs/sec | MRI 2.6.3
21
+ Sidekiq 4.0.0 | 10 ms | 151 MB | 22 sec | 4500 jobs/sec |
22
+ Sidekiq 3.5.1 | 22 ms | 1257 MB | 125 sec | 800 jobs/sec |
23
+ Resque 1.25.2 | - | - | 420 sec | 240 jobs/sec |
24
+ DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec |
25
+
26
+ This benchmark can be found in `bin/sidekiqload` and assumes a Redis network latency of 1ms.
27
+
28
+ Requirements
29
+ -----------------
30
+
31
+ - Redis: 4.0+
32
+ - Ruby: MRI 2.5+ or JRuby 9.2+.
33
+
34
+ Sidekiq 6.0 supports Rails 5.0+ but does not require it.
35
+
36
+
37
+ Installation
38
+ -----------------
39
+
40
+ gem install sidekiq
41
+
42
+
43
+ Getting Started
44
+ -----------------
45
+
46
+ See the [Getting Started wiki page](https://github.com/mperham/sidekiq/wiki/Getting-Started) and follow the simple setup process.
47
+ You can watch [this Youtube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
48
+ Sidekiq and see its features in action. Here's the Web UI:
49
+
50
+ ![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
51
+
52
+
53
+ Want to Upgrade?
54
+ -------------------
55
+
56
+ I also sell Sidekiq Pro and Sidekiq Enterprise, extensions to Sidekiq which provide more
57
+ features, a commercial-friendly license and allow you to support high
58
+ quality open source development all at the same time. Please see the
59
+ [Sidekiq](https://sidekiq.org/) homepage for more detail.
60
+
61
+ Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
62
+ features and changes to Sidekiq and its bigger siblings.
63
+
64
+
65
+ Problems?
66
+ -----------------
67
+
68
+ **Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public.
69
+
70
+ If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages.
71
+ Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
72
+
73
+ Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at https://sidekiq.org; email support@contribsys.com for help.
74
+
75
+ Useful resources:
76
+
77
+ * Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
78
+ * Occasional announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
79
+ * The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
80
+
81
+ Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
82
+ See the [Sidekiq support page](https://sidekiq.org/support.html) for details.
83
+
84
+
85
+ License
86
+ -----------------
87
+
88
+ Please see [LICENSE](https://github.com/mperham/sidekiq/blob/master/LICENSE) for licensing details.
89
+
90
+
91
+ Author
92
+ -----------------
93
+
94
+ Mike Perham, [@getajobmike](https://twitter.com/getajobmike) / [@sidekiq](https://twitter.com/sidekiq), [https://www.mikeperham.com](https://www.mikeperham.com) / [https://www.contribsys.com](https://www.contribsys.com)
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "standard/rake"
4
+
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.warning = true
7
+ test.pattern = "test/**/test_*.rb"
8
+ end
9
+
10
+ task default: [:standard, :test]
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Quiet some warnings we see when running in warning mode:
4
+ # RUBYOPT=-w bundle exec sidekiq
5
+ $TESTING = false
6
+
7
+ require_relative '../lib/sidekiq/cli'
8
+
9
+ def integrate_with_systemd
10
+ return unless ENV["NOTIFY_SOCKET"]
11
+
12
+ Sidekiq.configure_server do |config|
13
+ Sidekiq.logger.info "Enabling systemd notification integration"
14
+ require "sidekiq/sd_notify"
15
+ config.on(:startup) do
16
+ Sidekiq::SdNotify.ready
17
+ end
18
+ config.on(:shutdown) do
19
+ Sidekiq::SdNotify.stopping
20
+ end
21
+ Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
22
+ end
23
+ end
24
+
25
+ begin
26
+ cli = Sidekiq::CLI.instance
27
+ cli.parse
28
+
29
+ integrate_with_systemd
30
+
31
+ cli.run
32
+ rescue => e
33
+ raise e if $DEBUG
34
+ if Sidekiq.error_handlers.length == 0
35
+ STDERR.puts e.message
36
+ STDERR.puts e.backtrace.join("\n")
37
+ else
38
+ cli.handle_exception e
39
+ end
40
+
41
+ exit 1
42
+ end
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Quiet some warnings we see when running in warning mode:
4
+ # RUBYOPT=-w bundle exec sidekiq
5
+ $TESTING = false
6
+
7
+ #require 'ruby-prof'
8
+ require 'bundler/setup'
9
+ Bundler.require(:default, :load_test)
10
+
11
+ require_relative '../lib/sidekiq/cli'
12
+ require_relative '../lib/sidekiq/launcher'
13
+
14
+ include Sidekiq::Util
15
+
16
+ Sidekiq.configure_server do |config|
17
+ config.options[:concurrency] = 10
18
+ config.redis = { db: 13, port: 6380, driver: :hiredis }
19
+ config.options[:queues] << 'default'
20
+ config.logger.level = Logger::ERROR
21
+ config.average_scheduled_poll_interval = 2
22
+ config.reliable! if defined?(Sidekiq::Pro)
23
+ end
24
+
25
+ class LoadWorker
26
+ include Sidekiq::Worker
27
+ sidekiq_options retry: 1
28
+ sidekiq_retry_in do |x|
29
+ 1
30
+ end
31
+
32
+ def perform(idx, ts=nil)
33
+ puts(Time.now.to_f - ts) if ts != nil
34
+ #raise idx.to_s if idx % 100 == 1
35
+ end
36
+ end
37
+
38
+ # brew tap shopify/shopify
39
+ # brew install toxiproxy
40
+ # gem install toxiproxy
41
+ # run `toxiproxy-server` in a separate terminal window.
42
+ require 'toxiproxy'
43
+ # simulate a non-localhost network for realer-world conditions.
44
+ # adding 1ms of network latency has an ENORMOUS impact on benchmarks
45
+ Toxiproxy.populate([{
46
+ "name": "redis",
47
+ "listen": "127.0.0.1:6380",
48
+ "upstream": "127.0.0.1:6379"
49
+ }])
50
+
51
+ self_read, self_write = IO.pipe
52
+ %w(INT TERM TSTP TTIN).each do |sig|
53
+ begin
54
+ trap sig do
55
+ self_write.puts(sig)
56
+ end
57
+ rescue ArgumentError
58
+ puts "Signal #{sig} not supported"
59
+ end
60
+ end
61
+
62
+ Sidekiq.redis {|c| c.flushdb}
63
+ def handle_signal(launcher, sig)
64
+ Sidekiq.logger.debug "Got #{sig} signal"
65
+ case sig
66
+ when 'INT'
67
+ # Handle Ctrl-C in JRuby like MRI
68
+ # http://jira.codehaus.org/browse/JRUBY-4637
69
+ raise Interrupt
70
+ when 'TERM'
71
+ # Heroku sends TERM and then waits 30 seconds for process to exit.
72
+ raise Interrupt
73
+ when 'TSTP'
74
+ Sidekiq.logger.info "Received TSTP, no longer accepting new work"
75
+ launcher.quiet
76
+ when 'TTIN'
77
+ Thread.list.each do |thread|
78
+ Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread['label']}"
79
+ if thread.backtrace
80
+ Sidekiq.logger.warn thread.backtrace.join("\n")
81
+ else
82
+ Sidekiq.logger.warn "<no backtrace available>"
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ def Process.rss
89
+ `ps -o rss= -p #{Process.pid}`.chomp.to_i
90
+ end
91
+
92
+ iter = 10
93
+ count = 10_000
94
+
95
+ iter.times do
96
+ arr = Array.new(count) do
97
+ []
98
+ end
99
+ count.times do |idx|
100
+ arr[idx][0] = idx
101
+ end
102
+ Sidekiq::Client.push_bulk('class' => LoadWorker, 'args' => arr)
103
+ end
104
+ Sidekiq.logger.error "Created #{count*iter} jobs"
105
+
106
+ start = Time.now
107
+
108
+ Monitoring = Thread.new do
109
+ watchdog("monitor thread") do
110
+ while true
111
+ sleep 0.2
112
+ qsize = Sidekiq.redis do |conn|
113
+ conn.llen "queue:default"
114
+ end
115
+ total = qsize
116
+ #Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
117
+ if total == 0
118
+ Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
119
+ Sidekiq.logger.error("Now here's the latency for three jobs")
120
+
121
+ LoadWorker.perform_async(1, Time.now.to_f)
122
+ LoadWorker.perform_async(2, Time.now.to_f)
123
+ LoadWorker.perform_async(3, Time.now.to_f)
124
+
125
+ sleep 0.2
126
+ exit(0)
127
+ end
128
+ end
129
+ end
130
+ end
131
+
132
+ begin
133
+ #RubyProf::exclude_threads = [ Monitoring ]
134
+ #RubyProf.start
135
+ fire_event(:startup)
136
+ Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
137
+ Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
138
+ launcher = Sidekiq::Launcher.new(Sidekiq.options)
139
+ launcher.run
140
+
141
+ while readable_io = IO.select([self_read])
142
+ signal = readable_io.first[0].gets.strip
143
+ handle_signal(launcher, signal)
144
+ end
145
+ end
146
+ rescue SystemExit => e
147
+ #Sidekiq.logger.error("Profiling...")
148
+ #result = RubyProf.stop
149
+ #printer = RubyProf::GraphHtmlPrinter.new(result)
150
+ #printer.print(File.new("output.html", "w"), :min_percent => 1)
151
+ # normal
152
+ rescue => e
153
+ raise e if $DEBUG
154
+ STDERR.puts e.message
155
+ STDERR.puts e.backtrace.join("\n")
156
+ exit 1
157
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sidekiq/monitor'
4
+
5
+ section = "all"
6
+ section = ARGV[0] if ARGV.size == 1
7
+
8
+ Sidekiq::Monitor::Status.new.display(section)
@@ -0,0 +1,50 @@
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 the project maintainer at mperham AT 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
+
45
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
46
+ version 1.3.0, available at
47
+ [http://contributor-covenant.org/version/1/3/0/][version]
48
+
49
+ [homepage]: http://contributor-covenant.org
50
+ [version]: http://contributor-covenant.org/version/1/3/0/
@@ -0,0 +1,9 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Worker
3
+ include Sidekiq::Worker
4
+
5
+ def perform(*args)
6
+ # Do something
7
+ end
8
+ end
9
+ <% end -%>
@@ -0,0 +1,6 @@
1
+ require 'rails_helper'
2
+ <% module_namespacing do -%>
3
+ RSpec.describe <%= class_name %>Worker, type: :worker do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+ <% end -%>
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+ <% module_namespacing do -%>
3
+ class <%= class_name %>WorkerTest < Minitest::Test
4
+ def test_example
5
+ skip "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
8
+ <% end -%>
@@ -0,0 +1,57 @@
1
+ require "rails/generators/named_base"
2
+
3
+ module Sidekiq
4
+ module Generators # :nodoc:
5
+ class WorkerGenerator < ::Rails::Generators::NamedBase # :nodoc:
6
+ desc "This generator creates a Sidekiq Worker in app/workers and a corresponding test"
7
+
8
+ check_class_collision suffix: "Worker"
9
+
10
+ def self.default_generator_root
11
+ File.dirname(__FILE__)
12
+ end
13
+
14
+ def create_worker_file
15
+ template "worker.rb.erb", File.join("app/workers", class_path, "#{file_name}_worker.rb")
16
+ end
17
+
18
+ def create_test_file
19
+ return unless test_framework
20
+
21
+ if test_framework == :rspec
22
+ create_worker_spec
23
+ else
24
+ create_worker_test
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def create_worker_spec
31
+ template_file = File.join(
32
+ "spec/workers",
33
+ class_path,
34
+ "#{file_name}_worker_spec.rb"
35
+ )
36
+ template "worker_spec.rb.erb", template_file
37
+ end
38
+
39
+ def create_worker_test
40
+ template_file = File.join(
41
+ "test/workers",
42
+ class_path,
43
+ "#{file_name}_worker_test.rb"
44
+ )
45
+ template "worker_test.rb.erb", template_file
46
+ end
47
+
48
+ def file_name
49
+ @_file_name ||= super.sub(/_?worker\z/i, "")
50
+ end
51
+
52
+ def test_framework
53
+ ::Rails.application.config.generators.options[:rails][:test_framework]
54
+ end
55
+ end
56
+ end
57
+ end