resqutils 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f57266b7682198b7c27f8268ebc9b27ef8635ed4
4
- data.tar.gz: a9d48a1bb58181da264051574ca5eeac89d6c951
3
+ metadata.gz: a80c8babeebfe016d723913e3526e2b20970d672
4
+ data.tar.gz: 19828b603b4b2f7f991e03e2be56f4a441a29fae
5
5
  SHA512:
6
- metadata.gz: 030106d9602805a8ade0f0d8993d56fbde5cdb8babc91d6eb4097a6de21ebbe25b406a62fa92c746f6f08935c14ab3f51d645595bb5d70c268d51b664ed31b62
7
- data.tar.gz: edef10efbffa408e8b57546ce739d44b503593dc1ce9a8d182148da1f7f3fd022ea3fe1582ad236e3b9a7b22a84193c0b84cd91dc3ca62950ca4237ee62cd5e3
6
+ metadata.gz: d1d995e26e2361f9d040631b922f1c495da746109a2ff9217f2dd544a7baa155281394b0729790c2b95c1cb38242a0c81ded71950ba43e61697ce5f2415203ea
7
+ data.tar.gz: ef07f5f0aa385e580f7bb6141ca61e27aaefe0aa31a466517fd9d105a10ba68cde2d898a5958a94a712f618eb3135cecffe74a16d5ef3b6d89f1829260d31ddc
data/.travis.yml CHANGED
@@ -2,3 +2,9 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.0
4
4
  - 2.2.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - ruby-head
8
+ gemfile:
9
+ - Gemfile
10
+ - gemfiles/rspec2.gemfile
@@ -0,0 +1,6 @@
1
+ # Code of Conduct
2
+
3
+ We are committed to keeping our community open and inclusive.
4
+
5
+ **Our Code of Conduct can be found here**:
6
+ http://opensource.stitchfix.com/code-of-conduct.html
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,18 @@
1
+ # Contributing
2
+ Thanks for using and improving *resqutils*! If you'd like to help out, check out [the project's issues list](https://github.com/stitchfix/resqutils/issues) for ideas on what could be improved. If there's an idea you'd like to propose, or a design change, feel free to file a new issue or send a pull request:
3
+
4
+ 1. [Fork][fork] the repo.
5
+ 1. [Create a topic branch.][branch]
6
+ 1. Write tests.
7
+ 1. Implement your feature or fix bug.
8
+ 1. Add, commit, and push your changes.
9
+ 1. [Submit a pull request.][pr]
10
+
11
+ [fork]: https://help.github.com/articles/fork-a-repo/
12
+ [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
13
+ [pr]: https://help.github.com/articles/using-pull-requests/
14
+
15
+ ## General Guidelines
16
+
17
+ * When in doubt, test it. If you can't test it, re-think what you are doing.
18
+ * Code formatting and internal application architecture should be consistent.
data/Gemfile.lock CHANGED
@@ -1,19 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- resqutils (1.1.1)
4
+ resqutils (1.2.0)
5
5
  resque
6
6
 
7
7
  GEM
8
8
  remote: https://www.rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.2.5)
11
+ fakeredis (0.5.0)
12
+ redis (~> 3.0)
11
13
  mono_logger (1.1.0)
12
- multi_json (1.11.0)
13
- rack (1.6.1)
14
+ multi_json (1.11.2)
15
+ rack (1.6.4)
14
16
  rack-protection (1.5.3)
15
17
  rack
16
- rake (10.3.2)
18
+ rake (10.4.2)
17
19
  redis (3.2.1)
18
20
  redis-namespace (1.5.2)
19
21
  redis (~> 3.0, >= 3.0.4)
@@ -23,18 +25,19 @@ GEM
23
25
  redis-namespace (~> 1.3)
24
26
  sinatra (>= 0.9.2)
25
27
  vegas (~> 0.1.2)
26
- rspec (3.1.0)
27
- rspec-core (~> 3.1.0)
28
- rspec-expectations (~> 3.1.0)
29
- rspec-mocks (~> 3.1.0)
30
- rspec-core (3.1.2)
31
- rspec-support (~> 3.1.0)
32
- rspec-expectations (3.1.0)
28
+ rspec (3.3.0)
29
+ rspec-core (~> 3.3.0)
30
+ rspec-expectations (~> 3.3.0)
31
+ rspec-mocks (~> 3.3.0)
32
+ rspec-core (3.3.2)
33
+ rspec-support (~> 3.3.0)
34
+ rspec-expectations (3.3.1)
33
35
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.1.0)
35
- rspec-mocks (3.1.0)
36
- rspec-support (~> 3.1.0)
37
- rspec-support (3.1.0)
36
+ rspec-support (~> 3.3.0)
37
+ rspec-mocks (3.3.2)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.3.0)
40
+ rspec-support (3.3.0)
38
41
  sinatra (1.4.6)
39
42
  rack (~> 1.4)
40
43
  rack-protection (~> 1.4)
@@ -47,6 +50,10 @@ PLATFORMS
47
50
  ruby
48
51
 
49
52
  DEPENDENCIES
53
+ fakeredis
50
54
  rake
51
55
  resqutils!
52
56
  rspec
57
+
58
+ BUNDLED WITH
59
+ 1.10.6
@@ -0,0 +1,7 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ group :test, :development do
4
+ gem "rspec", "~> 2"
5
+ end
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ resqutils (1.1.1)
5
+ resque
6
+
7
+ GEM
8
+ remote: https://www.rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ fakeredis (0.5.0)
12
+ redis (~> 3.0)
13
+ mono_logger (1.1.0)
14
+ multi_json (1.11.2)
15
+ rack (1.6.4)
16
+ rack-protection (1.5.3)
17
+ rack
18
+ rake (10.4.2)
19
+ redis (3.2.1)
20
+ redis-namespace (1.5.2)
21
+ redis (~> 3.0, >= 3.0.4)
22
+ resque (1.25.2)
23
+ mono_logger (~> 1.0)
24
+ multi_json (~> 1.0)
25
+ redis-namespace (~> 1.3)
26
+ sinatra (>= 0.9.2)
27
+ vegas (~> 0.1.2)
28
+ rspec (2.99.0)
29
+ rspec-core (~> 2.99.0)
30
+ rspec-expectations (~> 2.99.0)
31
+ rspec-mocks (~> 2.99.0)
32
+ rspec-core (2.99.2)
33
+ rspec-expectations (2.99.2)
34
+ diff-lcs (>= 1.1.3, < 2.0)
35
+ rspec-mocks (2.99.4)
36
+ sinatra (1.4.6)
37
+ rack (~> 1.4)
38
+ rack-protection (~> 1.4)
39
+ tilt (>= 1.3, < 3)
40
+ tilt (2.0.1)
41
+ vegas (0.1.11)
42
+ rack (>= 1.0.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ fakeredis
49
+ rake
50
+ resqutils!
51
+ rspec (~> 2)
52
+
53
+ BUNDLED WITH
54
+ 1.10.6
@@ -12,7 +12,13 @@ RSpec::Matchers.define :have_job_queued do |expected_job_hash|
12
12
  jobs_matching(queue_name,expected_job_hash).first.size == 1
13
13
  end
14
14
 
15
- failure_message_for_should do |queue_name|
15
+ failure_message_method = if defined?(failure_message)
16
+ :failure_message
17
+ else
18
+ :failure_message_for_should
19
+ end
20
+
21
+ send(failure_message_method) do |queue_name|
16
22
  matching_jobs,all_jobs = jobs_matching(queue_name,expected_job_hash)
17
23
  if matching_jobs.empty?
18
24
  "No jobs in #{queue_name} matched #{expected_job_hash.inspect} (Found these jobs: #{all_jobs.map(&:inspect).join(',')})"
@@ -21,7 +27,13 @@ RSpec::Matchers.define :have_job_queued do |expected_job_hash|
21
27
  end
22
28
  end
23
29
 
24
- failure_message_for_should_not do |queue_name|
30
+ failure_message_when_negated_method = if defined?(failure_message_when_negated)
31
+ :failure_message_when_negated
32
+ else
33
+ :failure_message_for_should_not
34
+ end
35
+
36
+ send(failure_message_when_negated_method) do |queue_name|
25
37
  "Found job #{expected_job_hash.inspect} in the queue"
26
38
  end
27
39
  end
@@ -6,8 +6,8 @@ module Resqutils
6
6
  self.new.kill_stale_workers
7
7
  end
8
8
 
9
- def initialize(stale_workers: nil)
10
- @stale_workers = stale_workers || Resqutils::StaleWorkers.new
9
+ def initialize(options={})
10
+ @stale_workers = options.fetch(:stale_workers, Resqutils::StaleWorkers.new)
11
11
  end
12
12
  def kill_stale_workers
13
13
  @stale_workers.each do |worker|
@@ -1,3 +1,3 @@
1
1
  module Resqutils
2
- VERSION='1.1.1'
2
+ VERSION='1.2.0'
3
3
  end
data/resqutils.gemspec CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "resqutils"
7
7
  s.version = Resqutils::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ['Stitch Fix Engineering']
10
- s.email = ['opensource@stitchfix.com']
9
+ s.authors = ["Stitch Fix Engineering","Dave Copeland","Simeon Willbanks"]
10
+ s.email = ["opensource@stitchfix.com","davetron5000@gmail.com","simeon@simeons.net"]
11
11
  s.license = "Apache License Version 2.0, January 2004"
12
12
  s.homepage = "https://github.com/stitchfix/resqutils"
13
13
  s.summary = "Utilities for using Resque in a Rails app"
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
- s.add_dependency("resque")
20
+ s.add_runtime_dependency("resque")
21
21
  s.add_development_dependency("rake")
22
22
  s.add_development_dependency("rspec")
23
+ s.add_development_dependency("fakeredis")
23
24
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'rspec/version'
3
+
4
+ describe "Resque RSpec custom matchers" do
5
+ include Resqutils::Spec::ResqueHelpers
6
+
7
+ context "have_job_queued" do
8
+ class BackgroundJob
9
+ @queue = :low
10
+
11
+ def self.perform
12
+ end
13
+ end
14
+
15
+ class Service
16
+ def expensive
17
+ Resque.enqueue(BackgroundJob)
18
+ end
19
+ end
20
+
21
+ before do
22
+ clear_queue(BackgroundJob)
23
+ end
24
+
25
+ it "asserts Resque job has been queued" do
26
+ Service.new.expensive
27
+
28
+ if RSpec::Version::STRING.start_with?("2")
29
+ "low".should have_job_queued(class: BackgroundJob, args: [])
30
+ else
31
+ expect("low").to have_job_queued(class: BackgroundJob, args: [])
32
+ end
33
+ end
34
+ end
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
+ require 'fakeredis'
1
2
  require 'resque'
2
3
  require 'resqutils'
4
+ require 'resqutils/spec'
3
5
 
4
6
  GEM_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..'))
5
7
  Dir["#{GEM_ROOT}/spec/support/**/*.rb"].sort.each {|f| require f}
@@ -14,8 +14,11 @@ describe Resqutils::StaleWorkers do
14
14
  ]
15
15
  }
16
16
 
17
- before do
17
+ after do
18
18
  ENV.delete("RESQUTILS_SECONDS_TO_BE_CONSIDERED_STALE")
19
+ end
20
+
21
+ before do
19
22
  allow(Resque).to receive(:workers).and_return(workers)
20
23
  end
21
24
 
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resqutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering
8
+ - Dave Copeland
9
+ - Simeon Willbanks
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2015-06-09 00:00:00.000000000 Z
13
+ date: 2015-11-19 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: resque
@@ -52,9 +54,25 @@ dependencies:
52
54
  - - ">="
53
55
  - !ruby/object:Gem::Version
54
56
  version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: fakeredis
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
55
71
  description: Utilities for using Resque in a Rails app
56
72
  email:
57
73
  - opensource@stitchfix.com
74
+ - davetron5000@gmail.com
75
+ - simeon@simeons.net
58
76
  executables: []
59
77
  extensions: []
60
78
  extra_rdoc_files: []
@@ -63,11 +81,15 @@ files:
63
81
  - ".ruby-gemset"
64
82
  - ".ruby-version"
65
83
  - ".travis.yml"
84
+ - CODE_OF_CONDUCT.md
85
+ - CONTRIBUTING.md
66
86
  - Gemfile
67
87
  - Gemfile.lock
68
88
  - LICENSE.txt
69
89
  - README.md
70
90
  - Rakefile
91
+ - gemfiles/rspec2.gemfile
92
+ - gemfiles/rspec2.gemfile.lock
71
93
  - lib/resqutils.rb
72
94
  - lib/resqutils/do_not_auto_retry.rb
73
95
  - lib/resqutils/spec.rb
@@ -79,6 +101,7 @@ files:
79
101
  - lib/resqutils/worker_killer_job.rb
80
102
  - lib/resqutils/worker_task.rb
81
103
  - resqutils.gemspec
104
+ - spec/resque_matchers_spec.rb
82
105
  - spec/spec_helper.rb
83
106
  - spec/stale_workers_killer_spec.rb
84
107
  - spec/stale_workers_spec.rb
@@ -109,6 +132,7 @@ signing_key:
109
132
  specification_version: 4
110
133
  summary: Utilities for using Resque in a Rails app
111
134
  test_files:
135
+ - spec/resque_matchers_spec.rb
112
136
  - spec/spec_helper.rb
113
137
  - spec/stale_workers_killer_spec.rb
114
138
  - spec/stale_workers_spec.rb