use_cases 0.2.8 → 0.3.3

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
  SHA256:
3
- metadata.gz: e5012e555486c72a9bf671da5685c72f5db95a2566e9aa20420d69feb1cbe4ec
4
- data.tar.gz: d37c121f8cfce5116bcbe6d2fbab815a821f077f697e9331d42bacc385aad3aa
3
+ metadata.gz: 77207afa5f5968912f856f321850ff0be1baca220af443e541f666a47ce73f53
4
+ data.tar.gz: e57443d5a9e82500bf3174b8fa8962b1dc0dff8e2bb761eadb15412a7ce117be
5
5
  SHA512:
6
- metadata.gz: 0cc7e4b0c5b862443e9e6043448224f9fd1a3b999e4b59a748ad6cd1cf7fdb372bf2b8d8536ac4ca53fd20807fe064a3977af3ff39469974c9a52340d1994530
7
- data.tar.gz: c396adf4f58e01d46fef45d67d2ae56ad91db1bef26656cf6a4084d718b03d827817bd676de57d09f784553a87655a66c60d6fe75483f6863b11117756d5040b
6
+ metadata.gz: 4f6e3bb967a99f4fe28e5e5d75310e31b595a6943845d225fc29e46bed0d292f1b18b2057bd0cd1e443a8af2615f78210ae3918a18dd2fd0c879510fb238711a
7
+ data.tar.gz: d6981340c2c428f900071c605d712d06528cd463ff9c5271cd11f13a231e915b3dbf8944ac3fb737d8bcbd06d2fa4df3e80cc6fcd5ce49cae3f35fb455b38a97
@@ -2,30 +2,62 @@
2
2
 
3
3
  require "rspec"
4
4
 
5
- RSpec::Matchers.define(:fail_with_code) do |expected_code|
5
+ RSpec::Matchers.define(:be_failure_with_code) do |expected_code|
6
6
  match do |test_subject|
7
7
  expect(test_subject.failure?).to be true
8
- expect(test_subject.failure.first).to eq expected_code
8
+ expect(test_subject.failure.first).to eql expected_code
9
+ end
10
+
11
+ failure_message do |test_subject|
12
+ if text_subject.failure?
13
+ "the use case was expected to fail with code #{expected_code} but it returned #{test_subject.failure.first}"
14
+ else
15
+ "the use case was expected to fail with code #{expected_code} but it did not fail"
16
+ end
9
17
  end
10
18
  end
11
19
 
12
- RSpec::Matchers.define(:fail_with_payload) do |expected_result|
20
+ RSpec::Matchers.define(:be_failure_with_payload) do |expected_result|
13
21
  match do |test_subject|
14
22
  expect(test_subject.failure?).to be true
15
- expect(test_subject.failure.last).to eq expected_result
23
+ expect(test_subject.failure.last).to eql expected_result
16
24
  end
25
+
26
+ failure_message do |test_subject|
27
+ if test_subject.failure?
28
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.last.inspect}"
29
+ else
30
+ "the use case was expected to fail but it succeeded with #{test_subject.success.inspect}"
31
+ end
32
+ end
17
33
  end
18
34
 
19
- RSpec::Matchers.define(:fail_with) do |*expected_failure|
35
+ RSpec::Matchers.define(:be_failure_with) do |*expected_failure|
20
36
  match do |test_subject|
21
37
  expect(test_subject.failure?).to be true
22
- expect(test_subject.failure).to eq expected_failure
38
+ expect(test_subject.failure).to eql expected_failure
23
39
  end
40
+
41
+ failure_message do |test_subject|
42
+ if test_subject.failure?
43
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.inspect}"
44
+ else
45
+ "the use case was expected to fail but it succeeded with #{test_subject.success.inspect}"
46
+ end
47
+ end
24
48
  end
25
49
 
26
- RSpec::Matchers.define(:succeed_with) do |expected_result|
50
+ RSpec::Matchers.define(:be_successful_with) do |expected_result|
27
51
  match do |test_subject|
28
52
  expect(test_subject.success?).to be true
29
- expect(test_subject.success).to eq expected_result
53
+ expect(test_subject.success).to eql expected_result
30
54
  end
55
+
56
+ failure_message do |test_subject|
57
+ if test_subject.success?
58
+ "the use case was expected to succeed with #{expected_result.inspect} but it returned #{test_subject.success.inspect}"
59
+ else
60
+ "the use case was expected to succeed but it failed with #{test_subject.failure.inspect}"
61
+ end
62
+ end
31
63
  end
@@ -26,14 +26,13 @@ module UseCases
26
26
  def self.serialize_step_arguments(args)
27
27
  args.select.map.with_index do |arg, index|
28
28
  ActiveJob::Arguments.send(:serialize_argument, arg)
29
- false
30
29
  rescue ActiveJob::SerializationError => _e
31
- args = arg.serialize.merge("_serialized_by_use_case" => true, "_class" => arg.class.name)
32
-
30
+ arg.serialize.merge("_serialized_by_use_case" => true, "_class" => arg.class.name)
33
31
  rescue NoMethodError => _e
34
32
  puts "[WARNING] #{arg} of class (#{arg.clas}) (index = #{index})" \
35
33
  "is not serializable and does not repond to #serialize and will be ignored."
36
- false
34
+ else
35
+ arg
37
36
  end
38
37
  end
39
38
  end
@@ -6,7 +6,7 @@ module UseCases
6
6
  def do_call(*base_args)
7
7
  args = [object.class.name, name.to_s, *base_args]
8
8
  args = ::UseCases::StepActiveJobAdapter.serialize_step_arguments(args)
9
-
9
+ byebug
10
10
  job_options = options.slice(:queue, :wait, :wait_until, :priority)
11
11
 
12
12
  ::UseCases::StepActiveJobAdapter.set(job_options).perform_later(*args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UseCases
4
- VERSION = "0.2.8"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_cases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ring Twice