ducktrap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.circle.yml +6 -0
  3. data/.gitignore +5 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +16 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.devtools +59 -0
  8. data/Guardfile +18 -0
  9. data/LICENSE +20 -0
  10. data/README.md +47 -0
  11. data/Rakefile +2 -0
  12. data/TODO +4 -0
  13. data/config/devtools.yml +2 -0
  14. data/config/flay.yml +3 -0
  15. data/config/flog.yml +2 -0
  16. data/config/heckle.yml +3 -0
  17. data/config/mutant.yml +2 -0
  18. data/config/reek.yml +98 -0
  19. data/config/yardstick.yml +2 -0
  20. data/ducktrap.gemspec +23 -0
  21. data/lib/ducktrap.rb +73 -0
  22. data/lib/ducktrap/builder.rb +36 -0
  23. data/lib/ducktrap/error.rb +48 -0
  24. data/lib/ducktrap/evaluator.rb +127 -0
  25. data/lib/ducktrap/evaluator/invalid.rb +30 -0
  26. data/lib/ducktrap/evaluator/static.rb +25 -0
  27. data/lib/ducktrap/formatter.rb +138 -0
  28. data/lib/ducktrap/mapper.rb +59 -0
  29. data/lib/ducktrap/nary.rb +148 -0
  30. data/lib/ducktrap/node.rb +94 -0
  31. data/lib/ducktrap/node/anima.rb +40 -0
  32. data/lib/ducktrap/node/anima/dump.rb +39 -0
  33. data/lib/ducktrap/node/anima/load.rb +39 -0
  34. data/lib/ducktrap/node/block.rb +44 -0
  35. data/lib/ducktrap/node/coercion.rb +7 -0
  36. data/lib/ducktrap/node/custom.rb +121 -0
  37. data/lib/ducktrap/node/disjunction.rb +8 -0
  38. data/lib/ducktrap/node/forward.rb +55 -0
  39. data/lib/ducktrap/node/guard_nil.rb +42 -0
  40. data/lib/ducktrap/node/hash.rb +7 -0
  41. data/lib/ducktrap/node/hash/transform.rb +53 -0
  42. data/lib/ducktrap/node/invalid.rb +29 -0
  43. data/lib/ducktrap/node/inverse.rb +46 -0
  44. data/lib/ducktrap/node/key.rb +61 -0
  45. data/lib/ducktrap/node/key/add.rb +42 -0
  46. data/lib/ducktrap/node/key/delete.rb +44 -0
  47. data/lib/ducktrap/node/key/dump.rb +38 -0
  48. data/lib/ducktrap/node/key/fetch.rb +49 -0
  49. data/lib/ducktrap/node/map.rb +42 -0
  50. data/lib/ducktrap/node/noop.rb +30 -0
  51. data/lib/ducktrap/node/primitive.rb +61 -0
  52. data/lib/ducktrap/node/static.rb +33 -0
  53. data/lib/ducktrap/nullary.rb +41 -0
  54. data/lib/ducktrap/pretty_dump.rb +31 -0
  55. data/lib/ducktrap/registry.rb +60 -0
  56. data/lib/ducktrap/singleton.rb +55 -0
  57. data/lib/ducktrap/unary.rb +153 -0
  58. data/spec/rcov.opts +7 -0
  59. data/spec/shared/inverse_behavior.rb +7 -0
  60. data/spec/spec_helper.rb +20 -0
  61. data/spec/support/ice_nine_config.rb +8 -0
  62. data/spec/support/let_mock_helper.rb +13 -0
  63. data/spec/unit/ducktrap/builder/class_methods/new_spec.rb +41 -0
  64. data/spec/unit/ducktrap/builder/new_spec.rb +41 -0
  65. data/spec/unit/ducktrap/class_methods/build_spec.rb +11 -0
  66. data/spec/unit/ducktrap/error/exception/pretty_inspect_spec.rb +22 -0
  67. data/spec/unit/ducktrap/error/pretty_inspect_spec.rb +19 -0
  68. data/spec/unit/ducktrap/evaluator/assert_successful_spec.rb +38 -0
  69. data/spec/unit/ducktrap/evaluator/invalid/output_spec.rb +14 -0
  70. data/spec/unit/ducktrap/evaluator/noop/output_spec.rb +14 -0
  71. data/spec/unit/ducktrap/evaluator/output_spec.rb +52 -0
  72. data/spec/unit/ducktrap/evaluator/pretty_inspect_spec.rb +63 -0
  73. data/spec/unit/ducktrap/evaluator/successful_predicate_spec.rb +36 -0
  74. data/spec/unit/ducktrap/failed_transformation_error/message_spec.rb +10 -0
  75. data/spec/unit/ducktrap/formatter/attribute_spec.rb +24 -0
  76. data/spec/unit/ducktrap/formatter/body_spec.rb +19 -0
  77. data/spec/unit/ducktrap/formatter/class_methods/new_spec.rb +14 -0
  78. data/spec/unit/ducktrap/formatter/initialize_spec.rb +14 -0
  79. data/spec/unit/ducktrap/formatter/name_spec.rb +25 -0
  80. data/spec/unit/ducktrap/formatter/nest_spec.rb +48 -0
  81. data/spec/unit/ducktrap/formatter/puts_spec.rb +36 -0
  82. data/spec/unit/ducktrap/mapper/builder/dumper_spec.rb +20 -0
  83. data/spec/unit/ducktrap/mapper/builder/loader_spec.rb +20 -0
  84. data/spec/unit/ducktrap/mapper/builder/object_spec.rb +90 -0
  85. data/spec/unit/ducktrap/mapper/class_methods/build_spec.rb +20 -0
  86. data/spec/unit/ducktrap/nary/builder/add_spec.rb +16 -0
  87. data/spec/unit/ducktrap/nary/builder/method_missing_spec.rb +44 -0
  88. data/spec/unit/ducktrap/nary/builder/output_spec.rb +16 -0
  89. data/spec/unit/ducktrap/nary/class_methods/build_spec.rb +22 -0
  90. data/spec/unit/ducktrap/nary/class_methods/included_spec.rb +13 -0
  91. data/spec/unit/ducktrap/nary/evaluator/output_spec.rb +79 -0
  92. data/spec/unit/ducktrap/nary/instance_methods/inverse_spec.rb +24 -0
  93. data/spec/unit/ducktrap/nary/instance_methods/pretty_inspect_spec.rb +31 -0
  94. data/spec/unit/ducktrap/node/anima/dump/evaluator/output_spec.rb +18 -0
  95. data/spec/unit/ducktrap/node/anima/dump/inverse_spec.rb +10 -0
  96. data/spec/unit/ducktrap/node/anima/dump/pretty_inspect_spec.rb +15 -0
  97. data/spec/unit/ducktrap/node/anima/evaluator/output_spec.rb +18 -0
  98. data/spec/unit/ducktrap/node/anima/load/evaluator/output_spec.rb +35 -0
  99. data/spec/unit/ducktrap/node/anima/load/inverse_spec.rb +10 -0
  100. data/spec/unit/ducktrap/node/anima/load/pretty_inspect_spec.rb +15 -0
  101. data/spec/unit/ducktrap/node/anima/pretty_inspect_spec.rb +15 -0
  102. data/spec/unit/ducktrap/node/block/evaluator/output_spec.rb +79 -0
  103. data/spec/unit/ducktrap/node/block/inverse_spec.rb +24 -0
  104. data/spec/unit/ducktrap/node/call_spec.rb +21 -0
  105. data/spec/unit/ducktrap/node/class_methods/build_spec.rb +11 -0
  106. data/spec/unit/ducktrap/node/class_methods/register_spec.rb +16 -0
  107. data/spec/unit/ducktrap/node/custom/builder/forward_spec.rb +54 -0
  108. data/spec/unit/ducktrap/node/custom/builder/inverse_spec.rb +54 -0
  109. data/spec/unit/ducktrap/node/custom/builder/object_spec.rb +54 -0
  110. data/spec/unit/ducktrap/node/custom/call_spec.rb +21 -0
  111. data/spec/unit/ducktrap/node/custom/class_methods/build_spec.rb +20 -0
  112. data/spec/unit/ducktrap/node/custom/inverse_spec.rb +12 -0
  113. data/spec/unit/ducktrap/node/custom/pretty_inspect_spec.rb +15 -0
  114. data/spec/unit/ducktrap/node/forward/evaluator/output_spec.rb +13 -0
  115. data/spec/unit/ducktrap/node/forward/inverse_spec.rb +14 -0
  116. data/spec/unit/ducktrap/node/forward/pretty_inspect_spec.rb +19 -0
  117. data/spec/unit/ducktrap/node/guard_nil/call_spec.rb +21 -0
  118. data/spec/unit/ducktrap/node/guard_nil/evaluator/output_spec.rb +27 -0
  119. data/spec/unit/ducktrap/node/guard_nil/inverse_spec.rb +12 -0
  120. data/spec/unit/ducktrap/node/hash/transform/evaluator/output_spec.rb +51 -0
  121. data/spec/unit/ducktrap/node/hash/transform/inverse_spec.rb +27 -0
  122. data/spec/unit/ducktrap/node/invalid/call_spec.rb +13 -0
  123. data/spec/unit/ducktrap/node/invalid/inverse_spec.rb +11 -0
  124. data/spec/unit/ducktrap/node/inverse/call_spec.rb +11 -0
  125. data/spec/unit/ducktrap/node/inverse/inverse_spec.rb +14 -0
  126. data/spec/unit/ducktrap/node/inverse/pretty_inspect_spec.rb +19 -0
  127. data/spec/unit/ducktrap/node/key/add/call_spec.rb +15 -0
  128. data/spec/unit/ducktrap/node/key/add/evaluator/call_spec.rb +15 -0
  129. data/spec/unit/ducktrap/node/key/add/inverse_spec.rb +14 -0
  130. data/spec/unit/ducktrap/node/key/delete/call_spec.rb +13 -0
  131. data/spec/unit/ducktrap/node/key/delete/evaluator/call_spec.rb +13 -0
  132. data/spec/unit/ducktrap/node/key/delete/inverse_spec.rb +13 -0
  133. data/spec/unit/ducktrap/node/key/dump/evaluator/output_spec.rb +37 -0
  134. data/spec/unit/ducktrap/node/key/dump/inverse_spec.rb +14 -0
  135. data/spec/unit/ducktrap/node/key/evaluator/key_spec.rb +26 -0
  136. data/spec/unit/ducktrap/node/key/fetch/evaluator/output_spec.rb +48 -0
  137. data/spec/unit/ducktrap/node/key/fetch/inverse_spec.rb +14 -0
  138. data/spec/unit/ducktrap/node/key/pretty_inspect_spec.rb +20 -0
  139. data/spec/unit/ducktrap/node/map/evaluator/output_spec.rb +22 -0
  140. data/spec/unit/ducktrap/node/map/inverse_spec.rb +15 -0
  141. data/spec/unit/ducktrap/node/noop/call_spec.rb +11 -0
  142. data/spec/unit/ducktrap/node/noop/inverse_spec.rb +9 -0
  143. data/spec/unit/ducktrap/node/pretty_inspect_spec.rb +17 -0
  144. data/spec/unit/ducktrap/node/primitive/call_spec.rb +19 -0
  145. data/spec/unit/ducktrap/node/primitive/inverse_spec.rb +13 -0
  146. data/spec/unit/ducktrap/node/primitive/pretty_inspect_spec.rb +15 -0
  147. data/spec/unit/ducktrap/node/run_spec.rb +46 -0
  148. data/spec/unit/ducktrap/node/static/call_spec.rb +13 -0
  149. data/spec/unit/ducktrap/node/static/inverse_spec.rb +14 -0
  150. data/spec/unit/ducktrap/nullary/class_methods/build_spec.rb +37 -0
  151. data/spec/unit/ducktrap/nullary/class_methods/included_spec.rb +7 -0
  152. data/spec/unit/ducktrap/pretty_dump/pretty_dump_spec.rb +47 -0
  153. data/spec/unit/ducktrap/pretty_dump/pretty_inspect_spec.rb +22 -0
  154. data/spec/unit/ducktrap/registry/lookup_spec.rb +27 -0
  155. data/spec/unit/ducktrap/registry/register_spec.rb +21 -0
  156. data/spec/unit/ducktrap/singleton/class_methods/included_spec.rb +13 -0
  157. data/spec/unit/ducktrap/singleton/class_methods/instance_spec.rb +19 -0
  158. data/spec/unit/ducktrap/singleton/instance_methods/inspect_spec.rb +19 -0
  159. data/spec/unit/ducktrap/singleton/instance_methods/pretty_inspect_spec.rb +17 -0
  160. data/spec/unit/ducktrap/unary/class_methods/build_spec.rb +18 -0
  161. data/spec/unit/ducktrap/unary/class_methods/included_spec.rb +14 -0
  162. data/spec/unit/ducktrap/unary/evaluator/output2_spec.rb +48 -0
  163. data/spec/unit/ducktrap/unary/evaluator/output_spec.rb +37 -0
  164. data/spec/unit/ducktrap/unary/instance_methods/pretty_inspect_spec.rb +15 -0
  165. metadata +399 -0
@@ -0,0 +1,7 @@
1
+ --exclude-only "spec/,^/"
2
+ --sort coverage
3
+ --callsites
4
+ --xrefs
5
+ --profile
6
+ --text-summary
7
+ --failure-threshold 100
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ shared_examples_for 'an #inverse method' do
4
+ it 'should round trip' do
5
+ object.inverse.inverse.should eql(object)
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'ducktrap'
2
+ require 'devtools'
3
+ Devtools.init_spec_helper
4
+
5
+ module StripHelper
6
+ def strip(string)
7
+ lines = string.lines
8
+ line = lines.first
9
+ match = /\A[ ]*/.match(line)
10
+ length = match[0].length
11
+ source = lines.map do |line|
12
+ line[(length..-1)]
13
+ end.join
14
+ end
15
+ end
16
+
17
+ RSpec.configure do |config|
18
+ config.extend(LetMockHelper)
19
+ config.include(StripHelper)
20
+ end
@@ -0,0 +1,8 @@
1
+ require 'ice_nine'
2
+
3
+ module IceNine
4
+ class Freezer
5
+ class RSpec < NoFreeze
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module LetMockHelper
2
+ def let_mock(name,&block)
3
+ let(name) do
4
+ stubs =
5
+ if block
6
+ instance_exec(mock,&block)
7
+ else
8
+ {}
9
+ end
10
+ mock(name.to_s.capitalize,stubs)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Builder, '.new' do
4
+ let(:object) { class_under_test }
5
+
6
+ let(:class_under_test) do
7
+ Class.new(described_class)
8
+ end
9
+
10
+ let(:klass) { mock('Class') }
11
+
12
+ subject { object.new(klass, &block) }
13
+
14
+ context 'when called with block argument' do
15
+ let(:yields) { [] }
16
+ let(:block) { proc { |argument| yields << argument } }
17
+
18
+ it { should eql(class_under_test.new(klass)) }
19
+
20
+ it 'should yield builder' do
21
+ subject
22
+ yields.should eql([subject])
23
+ end
24
+
25
+ its(:klass) { should be(klass) }
26
+ end
27
+
28
+ context 'when called with block argument' do
29
+ let(:selfs) { [] }
30
+ let(:block) { selfs = self.selfs; proc { selfs << self } }
31
+
32
+ it { should eql(class_under_test.new(klass)) }
33
+
34
+ it 'should execute block within builder' do
35
+ subject
36
+ selfs.should eql([subject])
37
+ end
38
+
39
+ its(:klass) { should be(klass) }
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Builder, '.new' do
4
+ let(:object) { class_under_test }
5
+
6
+ let(:class_under_test) do
7
+ Class.new(described_class)
8
+ end
9
+
10
+ let(:klass) { mock('Class') }
11
+
12
+ subject { object.new(klass, &block) }
13
+
14
+ context 'when called with block argument' do
15
+ let(:yields) { [] }
16
+ let(:block) { proc { |argument| yields << argument } }
17
+
18
+ it { should eql(class_under_test.new(klass)) }
19
+
20
+ it 'should yield builder' do
21
+ subject
22
+ yields.should eql([subject])
23
+ end
24
+
25
+ its(:klass) { should be(klass) }
26
+ end
27
+
28
+ context 'when called with block argument' do
29
+ let(:selfs) { [] }
30
+ let(:block) { selfs = self.selfs; proc { selfs << self } }
31
+
32
+ it { should eql(class_under_test.new(klass)) }
33
+
34
+ it 'should execute block within builder' do
35
+ subject
36
+ selfs.should eql([subject])
37
+ end
38
+
39
+ its(:klass) { should be(klass) }
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap, '.build' do
4
+ let(:object) { described_class }
5
+
6
+ subject { object.build(&block) }
7
+
8
+ let(:block) { proc { noop } }
9
+
10
+ it { should eql(Ducktrap::Node::Block.new([Ducktrap::Node::Noop.instance])) }
11
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Error::Exception, '#pretty_inspect' do
4
+ let(:object) { described_class.new(context, input, exception) }
5
+
6
+ let(:context) { Ducktrap::Node::Noop.instance }
7
+ let(:input) { :input }
8
+ let(:exception) { RuntimeError.new('foo-message') }
9
+
10
+ subject { object.pretty_inspect }
11
+
12
+ it 'should return inspected error' do
13
+ should eql(strip(<<-STR))
14
+ Ducktrap::Error::Exception
15
+ input: :input
16
+ exception: RuntimeError
17
+ exception_message: "foo-message"
18
+ context:
19
+ Ducktrap::Node::Noop
20
+ STR
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Error, '#pretty_inspect' do
4
+ let(:object) { described_class.new(context, input) }
5
+
6
+ let(:context) { Ducktrap::Node::Noop.instance }
7
+ let(:input) { :input }
8
+
9
+ subject { object.pretty_inspect }
10
+
11
+ it 'should return inspected error' do
12
+ should eql(strip(<<-STR))
13
+ Ducktrap::Error
14
+ input: :input
15
+ context:
16
+ Ducktrap::Node::Noop
17
+ STR
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator, '#assert_successful' do
4
+ let(:object) { class_under_test.new(context, input) }
5
+
6
+ let(:context) { Ducktrap::Node::Noop.instance }
7
+ let(:input) { mock('Input') }
8
+
9
+ subject { object.assert_successful }
10
+
11
+ context 'when process is not successful' do
12
+
13
+ let(:class_under_test) do
14
+ Class.new(described_class) do
15
+ def process
16
+ error
17
+ end
18
+ end
19
+ end
20
+
21
+ it 'should raise error' do
22
+ expect { subject }.to raise_error(Ducktrap::FailedTransformationError)
23
+ end
24
+ end
25
+
26
+ context 'when process is successful' do
27
+
28
+ let(:class_under_test) do
29
+ Class.new(described_class) do
30
+ def process
31
+ :result
32
+ end
33
+ end
34
+ end
35
+
36
+ it { should be(object) }
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator::Invalid, '#output' do
4
+ let(:object) { described_class.new(context, input) }
5
+
6
+ let(:context) { mock('Context') }
7
+ let(:input) { mock('Input') }
8
+
9
+ subject { object.output }
10
+
11
+ it { should eql(Ducktrap::Error.new(context, input)) }
12
+
13
+ it_should_behave_like 'an idempotent method'
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator::Noop, '#output' do
4
+ let(:object) { described_class.new(context, input) }
5
+
6
+ subject { object.output }
7
+
8
+ let(:context) { mock('Context') }
9
+ let(:input) { mock('Input') }
10
+
11
+ it { should be(input) }
12
+
13
+ it_should_behave_like 'an idempotent method'
14
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator, '#output' do
4
+ let(:object) { class_under_test.new(context, input) }
5
+
6
+ subject { object.output }
7
+
8
+ let(:context) { mock('Context') }
9
+ let(:input) { mock('Input') }
10
+
11
+ context 'when using nested error' do
12
+
13
+ let(:inner) { mock('Inner') }
14
+
15
+ let(:class_under_test) do
16
+ inner = self.inner
17
+ Class.new(described_class) do
18
+ define_method :process do
19
+ nested_error(inner)
20
+ end
21
+ end
22
+ end
23
+
24
+ let(:exception) do
25
+ RuntimeError.new('some-message')
26
+ end
27
+
28
+ it { should eql(Ducktrap::Error.new(inner, input)) }
29
+
30
+ it_should_behave_like 'an idempotent method'
31
+ end
32
+
33
+ context 'when using exception macro' do
34
+
35
+ let(:class_under_test) do
36
+ exception = self.exception
37
+ Class.new(described_class) do
38
+ define_method :process do
39
+ exception(exception)
40
+ end
41
+ end
42
+ end
43
+
44
+ let(:exception) do
45
+ RuntimeError.new('some-message')
46
+ end
47
+
48
+ it { should eql(Ducktrap::Error::Exception.new(context, input, exception)) }
49
+
50
+ it_should_behave_like 'an idempotent method'
51
+ end
52
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator, '#pretty_inspect' do
4
+ let(:object) { class_under_test.new(context, input) }
5
+ let(:context) { Ducktrap::Node::Noop.instance }
6
+ let(:input) { :input }
7
+
8
+ subject { object.pretty_inspect }
9
+
10
+ context 'successful' do
11
+
12
+ let(:class_under_test) do
13
+ Class.new(described_class) do
14
+ def process
15
+ :output
16
+ end
17
+
18
+ def self.name
19
+ 'TestEvaluator'
20
+ end
21
+ end
22
+ end
23
+
24
+ it 'should return inspected error' do
25
+ should eql(strip(<<-STR))
26
+ TestEvaluator
27
+ input: :input
28
+ output: :output
29
+ context:
30
+ Ducktrap::Node::Noop
31
+ STR
32
+ end
33
+ end
34
+
35
+ context 'error' do
36
+
37
+ let(:class_under_test) do
38
+ Class.new(described_class) do
39
+ def process
40
+ error
41
+ end
42
+
43
+ def self.name
44
+ 'TestEvaluator'
45
+ end
46
+ end
47
+ end
48
+
49
+ it 'should return inspected error' do
50
+ should eql(strip(<<-STR))
51
+ TestEvaluator
52
+ input: :input
53
+ error:
54
+ Ducktrap::Error
55
+ input: :input
56
+ context:
57
+ Ducktrap::Node::Noop
58
+ context:
59
+ Ducktrap::Node::Noop
60
+ STR
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Evaluator, '#successful?' do
4
+ let(:object) { class_under_test.new(context, input) }
5
+
6
+ let(:context) { mock('Context') }
7
+ let(:input) { mock('Input') }
8
+
9
+ subject { object.successful? }
10
+
11
+ context 'when process is not successful' do
12
+
13
+ let(:class_under_test) do
14
+ Class.new(described_class) do
15
+ def process
16
+ error
17
+ end
18
+ end
19
+ end
20
+
21
+ it { should be(false) }
22
+ end
23
+
24
+ context 'when process is successful' do
25
+
26
+ let(:class_under_test) do
27
+ Class.new(described_class) do
28
+ def process
29
+ :result
30
+ end
31
+ end
32
+ end
33
+
34
+ it { should be(true) }
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::FailedTransformationError, '#message' do
4
+ subject { object.message }
5
+
6
+ let(:evaluator) { mock('Evaluator', :pretty_inspect => 'blah') }
7
+ let(:object) { described_class.new(evaluator) }
8
+
9
+ it { should eql('blah') }
10
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ducktrap::Formatter, '#attribute' do
4
+ subject { object.attribute(label, value) }
5
+
6
+ let(:object) { described_class.new(io) }
7
+ let(:io) { StringIO.new }
8
+
9
+ def output
10
+ io.rewind
11
+ io.read
12
+ end
13
+
14
+ before { subject }
15
+
16
+ let(:label) { 'label' }
17
+ let(:value) { 'value' }
18
+
19
+ it 'should print indented labeled value' do
20
+ output.should eql(%Q( label: "value"\n))
21
+ end
22
+
23
+ it_should_behave_like 'a command method'
24
+ end