queue_classic_matchers 0.0.4 → 1.0.2

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
- SHA1:
3
- metadata.gz: 155467017e30b8ae1bd1de89d3981c54eaaa032b
4
- data.tar.gz: f96cf7da66fab15bb8d098d35ee45ae60bb433f3
2
+ SHA256:
3
+ metadata.gz: b516868daa0cdaed7d9e70d26ee846710ab6bc973b32ae8e40e50ed3d5cd52d9
4
+ data.tar.gz: 66dbccc932e04352021618a36c74998864d4f0373fa520ad20cb1a919a26073b
5
5
  SHA512:
6
- metadata.gz: e393ca593be99a3751a73a9ad6a1d747a9116866aa8ea27b65f917925e399094afbd161b27413e5720676a3315acfa1980a552ea0eba4ffdff3a682cd68ee8c1
7
- data.tar.gz: 1042181e589d458b843faee8bc2cf3c26cce5b94bde6c4ecfe81399994f857ebdfe955110f326555b366b6f8f49e9f86a3992958599c4b6c7385f420acd0c880
6
+ metadata.gz: bdd4edeff0ecbad53710f2a62566a1e385d8d3c8e7703690ddd07cc41cc4a3453d364c1b0055032145d6266cc2de78f11125dffa04a1188ac13128b52eb7100e
7
+ data.tar.gz: fe695d5d3f026649eb22bb2bea5a6b1df10fce46bb0099a6945c2e1b4acea0f4858f29a1368c9c92adc5014e2a10d90d9824b51bf36b03e6d0f812539ea7ee35
@@ -0,0 +1,48 @@
1
+ version: 2
2
+
3
+ jobs:
4
+ test:
5
+ docker:
6
+ - image: circleci/ruby:2.5.3-node
7
+ - image: circleci/postgres:9.6.6-alpine
8
+ steps:
9
+ - checkout
10
+ - run:
11
+ name: run tests
12
+ command: |
13
+ bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
14
+ bundle exec rspec
15
+
16
+ push_to_rubygems:
17
+ docker:
18
+ - image: circleci/ruby:2.5.3
19
+ steps:
20
+ - checkout
21
+ - run:
22
+ name: Create .gem/credentials file
23
+ command: |
24
+ mkdir ~/.gem
25
+ echo "---
26
+ :rubygems_api_key: $RUBYGEMS_API_KEY
27
+ " > ~/.gem/credentials
28
+ chmod 600 ~/.gem/credentials
29
+ - run:
30
+ name: Release to rubygems
31
+ command: |
32
+ gem build queue_classic_matchers
33
+ gem push queue_classic_matchers-*.gem
34
+
35
+ workflows:
36
+ version: 2
37
+ gem_release:
38
+ jobs:
39
+ - test
40
+
41
+ - push_to_rubygems:
42
+ filters:
43
+ branches:
44
+ ignore:
45
+ - /.*/
46
+ tags:
47
+ only:
48
+ - /^v.*/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in queue_classic_matchers.gemspec
4
4
  gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'queue_classic_plus'
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Test helpers and RSpec matchers to [QueueClassicPlus](https://github.com/rainforestapp/queue_classic_plus).
4
4
 
5
+ ## Compatibility
6
+
7
+ This version of the matchers are compatible with queue_classic 3.1+ which includes built-in scheduling. See other branches for other compatible versions.
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
@@ -26,6 +30,8 @@ TODO: Write usage instructions here
26
30
  expect(MyQueueClassicPlusJob).to have_queued(*my_args)
27
31
  ```
28
32
 
33
+ Other matchers are `have_queue_size_of`, `change_queue_size_of` and `have_scheduled`.
34
+
29
35
 
30
36
  ### Test Helper
31
37
 
@@ -43,3 +49,9 @@ run_queue q_name, [MyQueueClassicPlusJob]
43
49
  3. Commit your changes (`git commit -am 'Add some feature'`)
44
50
  4. Push to the branch (`git push origin my-new-feature`)
45
51
  5. Create a new Pull Request
52
+
53
+ ## Releasing
54
+
55
+ 1. Open a PR and get it merged to master, making sure you've updated VERSION in `lib/queue_classic_matchers/version.rb`
56
+ 2. `git checkout master; git pull`
57
+ 3. `rake release:source_control_push`
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
@@ -1,3 +1,3 @@
1
1
  module QueueClassicMatchers
2
- VERSION = "0.0.4"
2
+ VERSION = '1.0.2'
3
3
  end
@@ -1,21 +1,21 @@
1
1
  require 'rspec/matchers'
2
- require "queue_classic_matchers/version"
3
- require "queue_classic_matchers/test_worker"
4
- require "queue_classic_matchers/test_helper"
2
+ require 'rspec/core'
3
+ require 'queue_classic_matchers/version'
4
+ require 'queue_classic_matchers/test_worker'
5
+ require 'queue_classic_matchers/test_helper'
5
6
 
6
7
  module QueueClassicMatchers
7
8
  # Your code goes here...
8
9
  module QueueClassicMatchers::QueueClassicRspec
9
- def self.find_by_args(queue_name, method, args, table = "queue_classic_jobs")
10
- q = "SELECT * FROM #{table} WHERE q_name = $1 AND method = $2 AND args::text = $3"
10
+ def self.find_by_args(queue_name, method, args)
11
+ q = 'SELECT * FROM queue_classic_jobs WHERE q_name = $1 AND method = $2 AND args::text = $3'
11
12
  result = QC.default_conn_adapter.execute q, queue_name, method, JSON.dump(args)
12
13
  result = [result] unless Array === result
13
14
  result.compact
14
15
  end
15
16
 
16
17
  def self.reset!
17
- QC.default_conn_adapter.execute "DELETE FROM queue_classic_jobs"
18
- QC.default_conn_adapter.execute "DELETE FROM queue_classic_later_jobs"
18
+ QC.default_conn_adapter.execute 'DELETE FROM queue_classic_jobs'
19
19
  end
20
20
  end
21
21
 
@@ -24,14 +24,14 @@ module QueueClassicMatchers
24
24
  module Job
25
25
  def self.included(receiver)
26
26
  receiver.class_eval do
27
- shared_examples_for "a queueable class" do
27
+ shared_examples_for 'a queueable class' do
28
28
  subject { described_class }
29
29
  its(:queue) { should be_a(::QC::Queue) }
30
30
  it { should respond_to(:do) }
31
31
  it { should respond_to(:perform) }
32
32
 
33
- it "should be a valid queue name" do
34
- subject.queue.name.should be_present
33
+ it 'should be a valid queue name' do
34
+ expect(subject.queue.name).to be_present
35
35
  end
36
36
  end
37
37
  end
@@ -64,7 +64,7 @@ RSpec::Matchers.define :have_queued do |*expected|
64
64
  end
65
65
 
66
66
  description do
67
- "should enqueue in queue classic"
67
+ 'should enqueue in queue classic'
68
68
  end
69
69
  end
70
70
 
@@ -114,14 +114,13 @@ RSpec::Matchers.define :change_queue_size_of do |expected|
114
114
  end
115
115
 
116
116
  description do
117
- "should change the queue size"
117
+ 'should change the queue size'
118
118
  end
119
119
  end
120
120
 
121
121
 
122
122
  RSpec::Matchers.define :have_scheduled do |*expected_args|
123
123
  chain :at do |timestamp|
124
- @interval = nil
125
124
  @time = timestamp
126
125
  @time_info = "at #{@time}"
127
126
  end
@@ -129,13 +128,11 @@ RSpec::Matchers.define :have_scheduled do |*expected_args|
129
128
  match do |actual|
130
129
  method = "#{actual.to_s}._perform"
131
130
  queue_name = actual.queue.name
132
- results = QueueClassicMatchers::QueueClassicRspec.find_by_args(queue_name,
133
- method,
134
- expected_args,
135
- "queue_classic_later_jobs")
131
+ results = QueueClassicMatchers::QueueClassicRspec.find_by_args(queue_name, method, expected_args)
132
+
136
133
  results.any? do |entry|
137
134
  time_matches = if @time
138
- Time.parse(entry['not_before']).to_i == @time.to_i
135
+ (Time.parse(entry['scheduled_at']).to_i - @time.to_i).abs <= 2
139
136
  else
140
137
  true
141
138
  end
@@ -151,6 +148,6 @@ RSpec::Matchers.define :have_scheduled do |*expected_args|
151
148
  end
152
149
 
153
150
  description do
154
- "have scheduled arguments"
151
+ 'have scheduled arguments'
155
152
  end
156
153
  end
@@ -4,20 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'queue_classic_matchers/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "queue_classic_matchers"
7
+ spec.name = 'queue_classic_matchers'
8
8
  spec.version = QueueClassicMatchers::VERSION
9
- spec.authors = ["Simon Mathieu"]
10
- spec.email = ["simon.math@gmail.com"]
9
+ spec.authors = ['Simon Mathieu', 'Jean-Philippe Boily', 'Emanuel Evans', 'Jonathan Barber']
11
10
  spec.summary = %q{RSpec Matchers and helpers for QueueClassicPlus}
12
- spec.description = %q{RSpec Matchers and helpers for QueueClassicPlus}
13
- spec.homepage = ""
14
- spec.license = "MIT"
11
+ spec.homepage = 'https://github.com/rainforestapp/queue_classic_matchers'
12
+ spec.license = 'MIT'
15
13
 
16
14
  spec.files = `git ls-files -z`.split("\x0")
17
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
17
+ spec.require_paths = ['lib']
20
18
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
19
+ spec.add_dependency 'queue_classic', '>= 3.1.0'
20
+ spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'pg'
23
+ spec.add_development_dependency 'activerecord'
23
24
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe QueueClassicMatchers do
4
+ class TestJob < QueueClassicPlus::Base
5
+ @queue = :low
6
+ def self.perform
7
+ end
8
+ end
9
+
10
+ describe 'have_queued' do
11
+ it 'works with no arguments' do
12
+ expect(TestJob).to_not have_queued
13
+ TestJob.do
14
+ expect(TestJob).to have_queued
15
+ end
16
+
17
+ it 'works wiht argument' do
18
+ expect(TestJob).to_not have_queued(1)
19
+ TestJob.do 1
20
+ expect(TestJob).to have_queued(1)
21
+ expect(TestJob).to_not have_queued(2)
22
+ end
23
+ end
24
+
25
+ describe 'have_queue_size_of' do
26
+ it 'works' do
27
+ expect(TestJob).to have_queue_size_of(0)
28
+ expect(TestJob).to_not have_queue_size_of(1)
29
+
30
+ TestJob.do
31
+
32
+ expect(TestJob).to have_queue_size_of(1)
33
+ expect(TestJob).to_not have_queue_size_of(0)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,122 @@
1
+ require 'queue_classic_plus'
2
+ require 'queue_classic_matchers'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
7
+ # this file to always be loaded, without a need to explicitly require it in any
8
+ # files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need
16
+ # it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is
57
+ # recommended. For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+
95
+ config.before(:suite) do
96
+ require 'active_record'
97
+ require 'pg'
98
+
99
+ db_url = ENV.fetch('DATABASE_URL', 'postgres://postgres:@localhost')
100
+
101
+ ActiveRecord::Base.establish_connection(db_url)
102
+ begin
103
+ ActiveRecord::Base.connection.create_database('queue_classic_matcher_test')
104
+ rescue ActiveRecord::StatementInvalid => e
105
+ raise unless e.cause.class == PG::DuplicateDatabase
106
+ end
107
+
108
+ ActiveRecord::Base.connection.execute 'drop schema public cascade; create schema public;'
109
+
110
+ QC.default_conn_adapter = QC::ConnAdapter.new(ActiveRecord::Base.connection.raw_connection)
111
+ QC::Setup.create
112
+ QueueClassicPlus.migrate
113
+ end
114
+
115
+ config.before(:each) do
116
+ tables = ActiveRecord::Base.connection.tables.select do |table|
117
+ table != 'schema_migrations'
118
+ end
119
+ ActiveRecord::Base.connection.execute("TRUNCATE #{tables.join(', ')} CASCADE") unless tables.empty?
120
+
121
+ end
122
+ end
metadata CHANGED
@@ -1,15 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queue_classic_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Mathieu
8
+ - Jean-Philippe Boily
9
+ - Emanuel Evans
10
+ - Jonathan Barber
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
14
+ date: 2019-07-16 00:00:00.000000000 Z
12
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: queue_classic
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.1.0
13
30
  - !ruby/object:Gem::Dependency
14
31
  name: bundler
15
32
  requirement: !ruby/object:Gem::Requirement
@@ -38,15 +55,43 @@ dependencies:
38
55
  - - ">="
39
56
  - !ruby/object:Gem::Version
40
57
  version: '0'
41
- description: RSpec Matchers and helpers for QueueClassicPlus
42
- email:
43
- - simon.math@gmail.com
58
+ - !ruby/object:Gem::Dependency
59
+ name: pg
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: activerecord
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ description:
87
+ email:
44
88
  executables: []
45
89
  extensions: []
46
90
  extra_rdoc_files: []
47
91
  files:
92
+ - ".circleci/config.yml"
48
93
  - ".gitignore"
49
- - ".rvmrc"
94
+ - ".rspec"
50
95
  - Gemfile
51
96
  - LICENSE.txt
52
97
  - README.md
@@ -56,7 +101,9 @@ files:
56
101
  - lib/queue_classic_matchers/test_worker.rb
57
102
  - lib/queue_classic_matchers/version.rb
58
103
  - queue_classic_matchers.gemspec
59
- homepage: ''
104
+ - spec/queue_classic_matchers_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/rainforestapp/queue_classic_matchers
60
107
  licenses:
61
108
  - MIT
62
109
  metadata: {}
@@ -75,9 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
122
  - !ruby/object:Gem::Version
76
123
  version: '0'
77
124
  requirements: []
78
- rubyforge_project:
79
- rubygems_version: 2.2.2
125
+ rubygems_version: 3.0.3
80
126
  signing_key:
81
127
  specification_version: 4
82
128
  summary: RSpec Matchers and helpers for QueueClassicPlus
83
- test_files: []
129
+ test_files:
130
+ - spec/queue_classic_matchers_spec.rb
131
+ - spec/spec_helper.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 2.1.2@queue_classic_matchers --create