use_case 0.13.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ coverage
2
+ test/reports
data/Gemfile CHANGED
@@ -7,3 +7,7 @@ gem "virtus", :git => "https://github.com/solnic/virtus.git"
7
7
  # Validations are optional, but required in order to test UseCase
8
8
  # itself
9
9
  gem "activemodel"
10
+
11
+ gem "ci_reporter"
12
+ gem "rcov", :platforms => :ruby_18
13
+ gem "simplecov", :platforms => :ruby_19
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- use_case (0.12.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
@@ -24,5 +24,5 @@
24
24
  #++
25
25
 
26
26
  module UseCase
27
- VERSION = "0.13.0"
27
+ VERSION = "1.0.0"
28
28
  end
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
- begin
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
- begin
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
@@ -119,7 +119,7 @@ class CreateRepositoryWithExplodingBuilder
119
119
  step(CreateRepositoryCommand.new(user), :builder => self)
120
120
  end
121
121
 
122
- def build; raise "Oops"; end
122
+ def build(params); raise "Oops"; end
123
123
  end
124
124
 
125
125
  class PimpRepositoryCommand
data/test/test_helper.rb CHANGED
@@ -22,6 +22,11 @@
22
22
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  # SOFTWARE.
24
24
  #++
25
+ if RUBY_VERSION > "1.9"
26
+ require "simplecov"
27
+ SimpleCov.start
28
+ end
29
+
25
30
  require "bundler/setup"
26
31
  require "minitest/autorun"
27
32
 
@@ -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
- outcome.pre_condition_failed do |f|
57
- assert_equal RuntimeError, f.pre_condition.class
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
- outcome = CreateRepositoryWithExplodingBuilder.new(@logged_in_user).execute({ :name => "Dude" })
113
-
114
- assert outcome.pre_condition_failed?
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.13.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-04-15 00:00:00.000000000 Z
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.24
89
+ rubygems_version: 1.8.25
89
90
  signing_key:
90
91
  specification_version: 3
91
92
  summary: ''