tzu 0.0.2.0 → 0.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +395 -0
- data/lib/tzu.rb +12 -51
- data/lib/tzu/core_extensions/string.rb +17 -0
- data/lib/tzu/hooks.rb +21 -4
- data/lib/tzu/invalid.rb +0 -2
- data/lib/tzu/outcome.rb +0 -1
- data/lib/tzu/run_methods.rb +32 -0
- data/lib/tzu/sequence.rb +68 -0
- data/lib/tzu/step.rb +34 -0
- data/lib/tzu/validation.rb +5 -14
- data/spec/sequence_spec.rb +206 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/step_spec.rb +24 -0
- data/spec/tzu_spec.rb +195 -20
- data/spec/validation_spec.rb +21 -37
- metadata +24 -5
- data/lib/tzu/organizer.rb +0 -35
- data/spec/organizer_spec.rb +0 -48
data/spec/organizer_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Tzu::Organizer do
|
4
|
-
let(:params) { [1, 2, 3] }
|
5
|
-
let(:commands) { [spy(run!: :step1, command_name: :step1), spy(run!: :step2, command_name: :step2)] }
|
6
|
-
|
7
|
-
let(:organized) do
|
8
|
-
organized = Class.new do
|
9
|
-
include Tzu::Organizer
|
10
|
-
|
11
|
-
def initialize(commands)
|
12
|
-
commands.each { |s| add_step(s) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
organized
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when organizer is called' do
|
20
|
-
|
21
|
-
it 'calls each step' do
|
22
|
-
organized.run(params, commands)
|
23
|
-
commands.each { |s| expect(s).to have_received(:run!).with(params) }
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'collates result of steps' do
|
27
|
-
result = organized.run(params, commands)
|
28
|
-
expect(result.result.step1).to eq(:step1)
|
29
|
-
expect(result.result.step2).to eq(:step2)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when organizer defines parse' do
|
34
|
-
before do
|
35
|
-
organized.class_eval do
|
36
|
-
def parse(result)
|
37
|
-
12345
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'it parses results from commands' do
|
43
|
-
result = organized.run(params, commands)
|
44
|
-
expect(result).to have_attributes(success: true, result: 12345)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|