typed_operation 0.4.0 → 0.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1be5d239791c002be2003d22a4d1a3bad636d10f5b3b923810627e5427f6d1
|
4
|
+
data.tar.gz: e539e29bb32268211d6831866ee5b455f11b96b1949b0ec788a8cd0ae90cb094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a0cccfd3499f7cd87e73ed646163f8617125e3c07dc9259972bdbc83d50634b32b129675e9d8bcf85aaef816b61f933d096aa2c6867bcde79c88b45d43cd491
|
7
|
+
data.tar.gz: 6cf1a3f0d2d7a70e57d361cdff698ddbb29505bf8177b54db9bfba83b54f64cf23983f984d990b75d2278ffbfca0c2548d2b57d8736d1acb6ac3410f58e136c6
|
@@ -4,8 +4,8 @@
|
|
4
4
|
module <%= namespace_name %>
|
5
5
|
class <%= name %> < ::ApplicationOperation
|
6
6
|
# Replace with implementation...
|
7
|
-
param :
|
8
|
-
param :an_optional_param, Integer, allow_nil: true
|
7
|
+
param :required_param, String
|
8
|
+
param :an_optional_param, Integer, convert: true, allow_nil: true
|
9
9
|
|
10
10
|
def prepare
|
11
11
|
# Prepare...
|
@@ -20,8 +20,8 @@ end
|
|
20
20
|
<% else %>
|
21
21
|
class <%= name %> < ::ApplicationOperation
|
22
22
|
# Replace with implementation...
|
23
|
-
param :
|
24
|
-
param :an_optional_param, Integer, allow_nil: true
|
23
|
+
param :required_param, String
|
24
|
+
param :an_optional_param, Integer, convert: true, allow_nil: true
|
25
25
|
|
26
26
|
def prepare
|
27
27
|
# Prepare...
|
@@ -1,45 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_helper"
|
4
|
+
|
3
5
|
<% if namespace_name.present? %>
|
4
6
|
module <%= namespace_name %>
|
5
7
|
class <%= name %>Test < ActiveSupport::TestCase
|
6
8
|
def setup
|
7
|
-
@operation = <%= name %>.new(
|
9
|
+
@operation = <%= name %>.new(required_param: "test")
|
8
10
|
end
|
9
11
|
|
10
|
-
test
|
12
|
+
test "should raise ParameterError if required param is nil" do
|
11
13
|
assert_raises(ParameterError) do
|
12
|
-
<%= name %>.new(
|
14
|
+
<%= name %>.new(required_param: nil)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
test
|
17
|
-
assert_equal <%= name %>.new(
|
18
|
+
test "should convert optional_param if it is not a string" do
|
19
|
+
assert_equal <%= name %>.new(required_param: "foo", optional_param: 123).converts_param, "123"
|
18
20
|
end
|
19
21
|
|
20
|
-
test
|
22
|
+
test "call returns after operation" do
|
21
23
|
result = @operation.call
|
22
24
|
assert_equal result, "Hello World!"
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
<% else %>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
class <%= name %>Test < ActiveSupport::TestCase
|
30
|
+
def setup
|
31
|
+
@operation = <%= name %>.new(required_param: "test")
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
34
|
+
test "should raise ParameterError if required param is nil" do
|
35
|
+
assert_raises(ParameterError) do
|
36
|
+
<%= name %>.new(required_param: nil)
|
36
37
|
end
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
test "should convert optional_param if it is not a string" do
|
41
|
+
assert_equal <%= name %>.new(required_param: "foo", optional_param: 123).converts_param, "123"
|
40
42
|
end
|
41
43
|
|
42
|
-
test
|
44
|
+
test "call returns after operation" do
|
43
45
|
result = @operation.call
|
44
46
|
assert_equal result, "Hello World!"
|
45
47
|
end
|