use_case 0.13.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +11 -1
- data/Rakefile +10 -0
- data/lib/use_case/version.rb +1 -1
- data/lib/use_case.rb +2 -10
- data/test/sample_use_case.rb +1 -1
- data/test/test_helper.rb +5 -0
- data/test/use_case_test.rb +5 -6
- metadata +4 -3
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ GIT
|
|
12
12
|
PATH
|
13
13
|
remote: .
|
14
14
|
specs:
|
15
|
-
use_case (0.
|
15
|
+
use_case (1.0.0)
|
16
16
|
|
17
17
|
GEM
|
18
18
|
remote: http://rubygems.org/
|
@@ -30,6 +30,8 @@ GEM
|
|
30
30
|
ice_nine (~> 0.7.0)
|
31
31
|
backports (3.1.1)
|
32
32
|
builder (3.0.4)
|
33
|
+
ci_reporter (1.9.0)
|
34
|
+
builder (>= 2.1.2)
|
33
35
|
coercible (0.2.0)
|
34
36
|
backports (~> 3.0, >= 3.1.0)
|
35
37
|
descendants_tracker (~> 0.0.1)
|
@@ -39,13 +41,21 @@ GEM
|
|
39
41
|
minitest (4.7.0)
|
40
42
|
multi_json (1.6.1)
|
41
43
|
rake (10.0.3)
|
44
|
+
rcov (1.0.0)
|
45
|
+
simplecov (0.7.1)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
simplecov-html (~> 0.7.1)
|
48
|
+
simplecov-html (0.7.1)
|
42
49
|
|
43
50
|
PLATFORMS
|
44
51
|
ruby
|
45
52
|
|
46
53
|
DEPENDENCIES
|
47
54
|
activemodel
|
55
|
+
ci_reporter
|
48
56
|
minitest (~> 4)
|
49
57
|
rake
|
58
|
+
rcov
|
59
|
+
simplecov
|
50
60
|
use_case!
|
51
61
|
virtus!
|
data/Rakefile
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
require "rake/testtask"
|
2
|
+
require "ci/reporter/rake/minitest"
|
2
3
|
|
3
4
|
Rake::TestTask.new(:test) do |test|
|
4
5
|
test.libs << "test"
|
5
6
|
test.pattern = "test/**/*_test.rb"
|
6
7
|
end
|
7
8
|
|
9
|
+
if RUBY_VERSION < "1.9"
|
10
|
+
require "rcov/rcovtask"
|
11
|
+
Rcov::RcovTask.new do |t|
|
12
|
+
t.libs << "test"
|
13
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
14
|
+
t.rcov_opts += %w{--exclude gems}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
task :default => :test
|
data/lib/use_case/version.rb
CHANGED
data/lib/use_case.rb
CHANGED
@@ -57,11 +57,7 @@ module UseCase
|
|
57
57
|
private
|
58
58
|
def execute_steps(steps, params)
|
59
59
|
result = steps.inject(params) do |input, step|
|
60
|
-
|
61
|
-
input = prepare_input(input, step)
|
62
|
-
rescue Exception => err
|
63
|
-
return PreConditionFailed.new(err)
|
64
|
-
end
|
60
|
+
input = prepare_input(input, step)
|
65
61
|
|
66
62
|
if outcome = validate_params(input, step[:validators])
|
67
63
|
return outcome
|
@@ -79,11 +75,7 @@ module UseCase
|
|
79
75
|
|
80
76
|
def verify_pre_conditions(input)
|
81
77
|
pre_conditions.each do |pc|
|
82
|
-
|
83
|
-
return PreConditionFailed.new(pc) if !pc.satisfied?(input)
|
84
|
-
rescue Exception => err
|
85
|
-
return PreConditionFailed.new(err)
|
86
|
-
end
|
78
|
+
return PreConditionFailed.new(pc) if !pc.satisfied?(input)
|
87
79
|
end
|
88
80
|
nil
|
89
81
|
end
|
data/test/sample_use_case.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/use_case_test.rb
CHANGED
@@ -51,10 +51,9 @@ describe UseCase do
|
|
51
51
|
|
52
52
|
it "fails with error if pre-condition raises" do
|
53
53
|
def @logged_in_user.id; raise "Oops!"; end
|
54
|
-
outcome = CreateRepository.new(@logged_in_user).execute({})
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
assert_raises RuntimeError do
|
56
|
+
CreateRepository.new(@logged_in_user).execute({})
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
@@ -109,9 +108,9 @@ describe UseCase do
|
|
109
108
|
end
|
110
109
|
|
111
110
|
it "treats builder error as failed pre-condition" do
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
assert_raises RuntimeError do
|
112
|
+
CreateRepositoryWithExplodingBuilder.new(@logged_in_user).execute({ :name => "Dude" })
|
113
|
+
end
|
115
114
|
end
|
116
115
|
|
117
116
|
it "chains two commands" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: use_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -49,6 +49,7 @@ executables: []
|
|
49
49
|
extensions: []
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
|
+
- .gitignore
|
52
53
|
- Gemfile
|
53
54
|
- Gemfile.lock
|
54
55
|
- LICENSE
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
88
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
89
|
+
rubygems_version: 1.8.25
|
89
90
|
signing_key:
|
90
91
|
specification_version: 3
|
91
92
|
summary: ''
|