rspec-activejob 0.0.1 → 0.1.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: d8206ef4115ccb0283a36013a2b2bc43d73c3285
4
- data.tar.gz: d001cf73f04e980b58d725a593807f4b80f826aa
3
+ metadata.gz: f57742790063ccf2ed6cd10e683e20389dbac437
4
+ data.tar.gz: 231a686b90f41591f5ad437e8beaec9421ae8144
5
5
  SHA512:
6
- metadata.gz: 2aba60f994f30bdaa7099c0388674642961a98ff04da4caee1c801ce2f3846710a5be7b78e96b190ef6c4763256a69a4c96c4303c67f06b41e48e840d6e76181
7
- data.tar.gz: c65123947482b545cc68c4cadfa8844afd219631231f087f859a98f914bcbca8515f107cee91c5d0c0350b8a4c2a75fa5565090ae1d5e90a10c3990a95148175
6
+ metadata.gz: b95a86346e700b872030feb2d8046e9bfd6c33f9419709186caaee85a49807f72dc51a4e641e13e308fc740053731278b3fb4dc70f278824b44e01276137b8c6
7
+ data.tar.gz: 38fedfe32066a157dd1b8b5e77edc9221889acbadf4a81fdaf14309cb58e08bfaa5efad2ec8044afeb2f051764ba7587e2376e67dd8c47a69cea51a3b4d6ef0d
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-activejob (0.0.1)
4
+ rspec-activejob (0.1.0)
5
5
  activejob (>= 4.2)
6
+ rspec-mocks
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -1,3 +1,5 @@
1
+ require 'rspec/mocks/argument_list_matcher'
2
+
1
3
  module RSpec
2
4
  module ActiveJob
3
5
  module Matchers
@@ -15,7 +17,7 @@ module RSpec
15
17
  def with(*args)
16
18
  raise "Must specify the job class when specifying arguments" unless job_class
17
19
 
18
- @expected_args = args
20
+ @argument_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(*args)
19
21
  self
20
22
  end
21
23
 
@@ -28,7 +30,7 @@ module RSpec
28
30
  return "expected to enqueue a #{job_class}, enqueued a #{enqueued_jobs.last[:job]}"
29
31
  end
30
32
 
31
- "expected to enqueue a #{job_class} with #{expected_args}, but enqueued with " \
33
+ "expected to enqueue a #{job_class} with #{argument_list_matcher.expected_args}, but enqueued with " \
32
34
  "#{new_jobs_with_correct_class.first[:args]}"
33
35
  end
34
36
 
@@ -38,7 +40,7 @@ module RSpec
38
40
 
39
41
  private
40
42
 
41
- attr_reader :before_count, :after_count, :job_class, :expected_args
43
+ attr_reader :before_count, :after_count, :job_class, :argument_list_matcher
42
44
 
43
45
  def enqueued_something?
44
46
  new_jobs.any?
@@ -50,7 +52,7 @@ module RSpec
50
52
  end
51
53
 
52
54
  def with_correct_args?
53
- return true unless expected_args
55
+ return true unless argument_list_matcher
54
56
  new_jobs_with_correct_class_and_args.any?
55
57
  end
56
58
 
@@ -63,7 +65,7 @@ module RSpec
63
65
  end
64
66
 
65
67
  def new_jobs_with_correct_class_and_args
66
- new_jobs_with_correct_class.select { |job| job[:args] == expected_args }
68
+ new_jobs_with_correct_class.select { |job| argument_list_matcher.args_match?(*job[:args]) }
67
69
  end
68
70
 
69
71
  def enqueued_jobs
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module ActiveJob
3
- VERSION = '0.0.1'.freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = %w(lib)
20
20
 
21
21
  s.add_runtime_dependency('activejob', '>= 4.2')
22
+ s.add_runtime_dependency('rspec-mocks')
22
23
 
23
24
  s.add_development_dependency('rspec')
24
25
  s.add_development_dependency('rspec-its')
@@ -51,9 +51,11 @@ RSpec.describe RSpec::ActiveJob::Matchers::EnqueueA do
51
51
  context "with argument expectations" do
52
52
  let(:job_class) { AJob }
53
53
  let(:instance) { described_class.new(job_class).with(*arguments) }
54
- let(:arguments) { ['thing', 'other_thing'] }
54
+ let(:arguments) { [instance_of(BJob), hash_including(thing: 1)] }
55
55
 
56
- let(:proc) { -> { enqueued_jobs << { job: AJob, args: arguments } } }
56
+ let(:proc) do
57
+ -> { enqueued_jobs << { job: AJob, args: [BJob.new, { thing: 1, 'thing' => 2 }] } }
58
+ end
57
59
 
58
60
  it { is_expected.to be(true) }
59
61
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-activejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Seymour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-mocks
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +75,7 @@ executables: []
61
75
  extensions: []
62
76
  extra_rdoc_files: []
63
77
  files:
78
+ - .gitignore
64
79
  - Gemfile
65
80
  - Gemfile.lock
66
81
  - README.md