use_cases 0.2.8 → 0.3.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
  SHA256:
3
- metadata.gz: e5012e555486c72a9bf671da5685c72f5db95a2566e9aa20420d69feb1cbe4ec
4
- data.tar.gz: d37c121f8cfce5116bcbe6d2fbab815a821f077f697e9331d42bacc385aad3aa
3
+ metadata.gz: 9e37115bbba6763134166d41497c5b1bd75725618cfa81a0cca04dccdeda1590
4
+ data.tar.gz: bc732410906c5e053d75bf982561a34c663faafed062f5f6ccac006f4f1f3cee
5
5
  SHA512:
6
- metadata.gz: 0cc7e4b0c5b862443e9e6043448224f9fd1a3b999e4b59a748ad6cd1cf7fdb372bf2b8d8536ac4ca53fd20807fe064a3977af3ff39469974c9a52340d1994530
7
- data.tar.gz: c396adf4f58e01d46fef45d67d2ae56ad91db1bef26656cf6a4084d718b03d827817bd676de57d09f784553a87655a66c60d6fe75483f6863b11117756d5040b
6
+ metadata.gz: f7a9ff7502bf8b6db76f10a56d68a4d43055ecd54a106c50a37abde3543ba832611deb3561f03dd4a0a65e07642144b51620beede3701cb2f437634f39aab100
7
+ data.tar.gz: a170718b5d281df6f761b4c297d6cbb5ecfa0dbf5deb34ac01254dfd21a125898de4cf9935b05d49b73a2699c2007b52fcac1caa2e6c160d66e580307deec83a
data/.gitignore CHANGED
@@ -9,5 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
- .byebug_history
13
- *.gem
12
+ .byebug_history
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- use_cases (0.2.7)
4
+ use_cases (0.2.5)
5
5
  activesupport
6
6
  dry-events
7
7
  dry-matcher
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "byebug"
4
+
3
5
  module UseCases
4
6
  module Notifications
5
7
  def self.included(base)
@@ -2,30 +2,46 @@
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
8
  expect(test_subject.failure.first).to eq expected_code
9
9
  end
10
+
11
+ failure_message do |test_subject|
12
+ "the use case was expected to fail with code #{expected_code} but it returned #{test_subject.failure.first}"
13
+ end
10
14
  end
11
15
 
12
- RSpec::Matchers.define(:fail_with_payload) do |expected_result|
16
+ RSpec::Matchers.define(:be_failure_with_payload) do |expected_result|
13
17
  match do |test_subject|
14
18
  expect(test_subject.failure?).to be true
15
19
  expect(test_subject.failure.last).to eq expected_result
16
20
  end
21
+
22
+ failure_message do |test_subject|
23
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.last.inspect}"
24
+ end
17
25
  end
18
26
 
19
- RSpec::Matchers.define(:fail_with) do |*expected_failure|
27
+ RSpec::Matchers.define(:be_failure_with) do |*expected_failure|
20
28
  match do |test_subject|
21
29
  expect(test_subject.failure?).to be true
22
30
  expect(test_subject.failure).to eq expected_failure
23
31
  end
32
+
33
+ failure_message do |test_subject|
34
+ "the use case was expected to fail with #{expected_result.inspect} but it returned #{test_subject.failure.inspect}"
35
+ end
24
36
  end
25
37
 
26
- RSpec::Matchers.define(:succeed_with) do |expected_result|
38
+ RSpec::Matchers.define(:be_successful_with) do |expected_result|
27
39
  match do |test_subject|
28
40
  expect(test_subject.success?).to be true
29
41
  expect(test_subject.success).to eq expected_result
30
42
  end
43
+
44
+ failure_message do |test_subject|
45
+ "the use case was expected to succeed with #{expected_result.inspect} but it returned #{test_subject.success.inspect}"
46
+ end
31
47
  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.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ring Twice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport