rachinations 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +6 -0
- data/.travis.yml +8 -0
- data/.yardopts +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +93 -0
- data/LICENSE.txt +21 -0
- data/README.md +18 -0
- data/Rakefile +16 -0
- data/lib/rachinations.rb +49 -0
- data/lib/rachinations/domain/diagrams/diagram.rb +167 -0
- data/lib/rachinations/domain/diagrams/non_deterministic_diagram.rb +16 -0
- data/lib/rachinations/domain/diagrams/verbose_diagram.rb +9 -0
- data/lib/rachinations/domain/edge_collection.rb +12 -0
- data/lib/rachinations/domain/edges/edge.rb +159 -0
- data/lib/rachinations/domain/edges/random_edge.rb +4 -0
- data/lib/rachinations/domain/exceptions/bad_options.rb +3 -0
- data/lib/rachinations/domain/exceptions/no_elements_found.rb +2 -0
- data/lib/rachinations/domain/exceptions/no_elements_matching_condition_error.rb +2 -0
- data/lib/rachinations/domain/exceptions/no_elements_of_given_type.rb +3 -0
- data/lib/rachinations/domain/exceptions/unsupported_type_error.rb +2 -0
- data/lib/rachinations/domain/modules/common/hash_init.rb +88 -0
- data/lib/rachinations/domain/modules/common/invariant.rb +17 -0
- data/lib/rachinations/domain/modules/diagrams/verbose.rb +30 -0
- data/lib/rachinations/domain/node_collection.rb +30 -0
- data/lib/rachinations/domain/nodes/converter.rb +276 -0
- data/lib/rachinations/domain/nodes/gate.rb +6 -0
- data/lib/rachinations/domain/nodes/node.rb +166 -0
- data/lib/rachinations/domain/nodes/pool.rb +267 -0
- data/lib/rachinations/domain/nodes/resourceful_node.rb +96 -0
- data/lib/rachinations/domain/nodes/resourceless_node.rb +11 -0
- data/lib/rachinations/domain/nodes/sink.rb +17 -0
- data/lib/rachinations/domain/nodes/source.rb +161 -0
- data/lib/rachinations/domain/nodes/trader.rb +6 -0
- data/lib/rachinations/domain/resource_bag.rb +131 -0
- data/lib/rachinations/domain/resources/token.rb +51 -0
- data/lib/rachinations/domain/strategies/strategy.rb +5 -0
- data/lib/rachinations/domain/strategies/valid_types.rb +69 -0
- data/lib/rachinations/dsl/dsl.rb +63 -0
- data/lib/rachinations/extras/fifo.rb +27 -0
- data/lib/rachinations/version.rb +3 -0
- data/machinations_diagrams/apenas_bonito.xml +22 -0
- data/machinations_diagrams/behavior_converter.xml +53 -0
- data/machinations_diagrams/behavior_converter_fim.xml +10 -0
- data/machinations_diagrams/canon/README.md +8 -0
- data/machinations_diagrams/canon/converters_differences.xml +27 -0
- data/machinations_diagrams/canon/converters_differences2.xml +34 -0
- data/machinations_diagrams/canon/converters_similarities.xml +63 -0
- data/machinations_diagrams/canon/converters_similarities2.xml +21 -0
- data/machinations_diagrams/canon/nodes_and_edges_differences.xml +15 -0
- data/machinations_diagrams/canon/nodes_and_edges_similarities.xml +20 -0
- data/machinations_diagrams/deterministic_example.xml +46 -0
- data/machinations_diagrams/economies_of_scale.xml +32 -0
- data/machinations_diagrams/feature_ou_bug.xml +5 -0
- data/machinations_diagrams/loop_in_trigger.xml +21 -0
- data/machinations_diagrams/naficadevendo.xml +12 -0
- data/machinations_diagrams/noreporting_equivalent.xml +22 -0
- data/machinations_diagrams/pull_all_example.xml +7 -0
- data/machinations_diagrams/sketch_of_memory.xml +41 -0
- data/machinations_diagrams/software_engineering_process 2.xml +130 -0
- data/machinations_diagrams/software_engineering_process v3.xml +168 -0
- data/machinations_diagrams/software_engineering_process v4.xml +192 -0
- data/machinations_diagrams/software_engineering_process.xml +65 -0
- data/machinations_diagrams/software_engineering_process_with_rework_after_test.xml +195 -0
- data/machinations_diagrams/startup_marketing.xml +35 -0
- data/machinations_diagrams/triggers_allow_multiple_stages_at_same_round.xml +19 -0
- data/machinations_diagrams/um_de_cada_vez_vs_todos_de_uma_vez.xml +20 -0
- data/rachinations.gemspec +35 -0
- data/testing/features/step_definitions/step_definitions.rb +11 -0
- data/testing/simulations/modelo1.rb +20 -0
- data/testing/simulations/modelo2.rb +49 -0
- data/testing/simulations/noreporting.rb +51 -0
- data/testing/simulations/sequencial.rb +19 -0
- data/testing/simulations/sobonito.rb +28 -0
- data/testing/simulations/sobonitowhile.rb +28 -0
- data/testing/simulations/whatIwish1.rb +20 -0
- data/testing/spec/canon/converter_spec.rb +33 -0
- data/testing/spec/canon/pool_spec.rb +68 -0
- data/testing/spec/conditions_spec.rb +10 -0
- data/testing/spec/converter_spec.rb +223 -0
- data/testing/spec/diagram_spec.rb +671 -0
- data/testing/spec/edge_spec.rb +256 -0
- data/testing/spec/hash_init_spec.rb +59 -0
- data/testing/spec/node_spec.rb +31 -0
- data/testing/spec/non_deterministic_diagram_spec.rb +112 -0
- data/testing/spec/pool_spec.rb +233 -0
- data/testing/spec/source_spec.rb +132 -0
- data/testing/spec/spec_helper.rb +34 -0
- data/testing/spec/xexeo_spec.rb +193 -0
- metadata +283 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '../../domain/diagrams/diagram'
|
2
|
+
require_relative '../../domain/nodes/pool'
|
3
|
+
require_relative '../../domain/edges/edge'
|
4
|
+
|
5
|
+
generator = Diagram.new('1to2')
|
6
|
+
|
7
|
+
generator.add_node! Pool, {
|
8
|
+
name: 'g1',
|
9
|
+
activation: :automatic,
|
10
|
+
initial_value: 5,
|
11
|
+
mode: :push
|
12
|
+
}
|
13
|
+
|
14
|
+
generator.add_node! Pool, {
|
15
|
+
name: 'g2',
|
16
|
+
activation: :automatic,
|
17
|
+
mode: :push
|
18
|
+
}
|
19
|
+
|
20
|
+
generator.add_node! Pool, {
|
21
|
+
name: 'g3'
|
22
|
+
}
|
23
|
+
|
24
|
+
generator.add_edge! Edge, {
|
25
|
+
name: 'c1',
|
26
|
+
from: 'g1',
|
27
|
+
to: 'g2'
|
28
|
+
}
|
29
|
+
|
30
|
+
generator.add_edge! Edge, {
|
31
|
+
name: 'c2',
|
32
|
+
from: 'g1',
|
33
|
+
to: 'g3',
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
generator.add_edge! Edge, {
|
38
|
+
name: 'c3',
|
39
|
+
from: 'g2',
|
40
|
+
to: 'g1',
|
41
|
+
}
|
42
|
+
|
43
|
+
# I want to check the initial state
|
44
|
+
puts "#### Estado inicial ####"
|
45
|
+
puts generator
|
46
|
+
|
47
|
+
# run and get the end
|
48
|
+
generator.run!(10)
|
49
|
+
|
50
|
+
puts "#### Estado final ####"
|
51
|
+
puts generator
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../../domain/diagrams/diagram'
|
2
|
+
require_relative '../../dsl/dsl'
|
3
|
+
require_relative '../../domain/nodes/pool'
|
4
|
+
require_relative '../../domain/edges/edge'
|
5
|
+
include DSL
|
6
|
+
|
7
|
+
n=diagram 'test_diagram', :verbose do
|
8
|
+
node 'p1', Pool, mode: :push, activation: :automatic, initial_value: 8
|
9
|
+
node 'p2', Pool, mode: :push, activation: :automatic
|
10
|
+
node 'p3', Pool, mode: :push, activation: :automatic
|
11
|
+
node 'p4', Pool, mode: :push, activation: :automatic
|
12
|
+
edge 'e1', Edge, 'p1', 'p2'
|
13
|
+
edge 'e2', Edge, 'p2', 'p3'
|
14
|
+
edge 'e3', Edge, 'p3', 'p4'
|
15
|
+
end
|
16
|
+
|
17
|
+
n.run!(5)
|
18
|
+
|
19
|
+
puts n
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../domain/diagrams/diagram'
|
2
|
+
require_relative '../../dsl/dsl'
|
3
|
+
require_relative '../../domain/nodes/pool'
|
4
|
+
require_relative '../../domain/edges/edge'
|
5
|
+
|
6
|
+
include DSL
|
7
|
+
|
8
|
+
n=diagram 'test_diagram',:verbose do
|
9
|
+
node 'p1', Pool, mode: :push, activation: :automatic, initial_value: 8
|
10
|
+
node 'p2', Pool, mode: :push, activation: :automatic
|
11
|
+
node 'p3', Pool, mode: :push, activation: :automatic
|
12
|
+
node 'p4', Pool, mode: :push, activation: :automatic
|
13
|
+
edge 'e1', Edge, 'p1', 'p2'
|
14
|
+
edge 'e2', Edge, 'p2', 'p1'
|
15
|
+
edge 'e3', Edge, 'p1', 'p3'
|
16
|
+
edge 'e4', Edge, 'p3', 'p1'
|
17
|
+
edge 'e5', Edge, 'p4', 'p2'
|
18
|
+
edge 'e6', Edge, 'p2', 'p4'
|
19
|
+
edge 'e7', Edge, 'p4', 'p3'
|
20
|
+
edge 'e8', Edge, 'p3', 'p4'
|
21
|
+
end
|
22
|
+
|
23
|
+
d = Diagram.new('bonitinho')
|
24
|
+
|
25
|
+
n.run!(20)
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../../domain/diagrams/diagram'
|
2
|
+
require_relative '../../dsl/dsl'
|
3
|
+
require_relative '../../domain/nodes/pool'
|
4
|
+
require_relative '../../domain/edges/edge'
|
5
|
+
include DSL
|
6
|
+
|
7
|
+
n=diagram 'test_diagram', :verbose do
|
8
|
+
node 'p1', Pool, mode: :push, activation: :automatic, initial_value: 8
|
9
|
+
node 'p2', Pool, mode: :push, activation: :automatic
|
10
|
+
node 'p3', Pool, mode: :push, activation: :automatic
|
11
|
+
node 'p4', Pool, mode: :push, activation: :automatic
|
12
|
+
edge 'e1', Edge, 'p1', 'p2'
|
13
|
+
edge 'e2', Edge, 'p2', 'p1'
|
14
|
+
edge 'e3', Edge, 'p1', 'p3'
|
15
|
+
edge 'e4', Edge, 'p3', 'p1'
|
16
|
+
edge 'e5', Edge, 'p4', 'p2'
|
17
|
+
edge 'e6', Edge, 'p2', 'p4'
|
18
|
+
edge 'e7', Edge, 'p4', 'p3'
|
19
|
+
edge 'e8', Edge, 'p3', 'p4'
|
20
|
+
end
|
21
|
+
|
22
|
+
d = Diagram.new('bonitinho')
|
23
|
+
|
24
|
+
n.run_while! do
|
25
|
+
not (n.get_node("p1").resource_count == 2 and n.get_node("p4").resource_count == 2)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../domain/diagram'
|
2
|
+
require_relative '../dsl/dsl.rb'
|
3
|
+
include DSL
|
4
|
+
|
5
|
+
n=diagram 'test_diagram' do
|
6
|
+
node 'source', Source
|
7
|
+
node 'pool1', Pool
|
8
|
+
edge 'edge1', Edge, 'source', 'pool1'
|
9
|
+
node 'pool2', Pool,
|
10
|
+
converter 'c1' , Converter
|
11
|
+
node 'e3' , Edge , 'pool2' , 'c1'
|
12
|
+
trigger 't1' , Trigger , 'pool1' , 'pool2' , { |ExtendedNode p| p.resouces>0 }
|
13
|
+
end
|
14
|
+
|
15
|
+
n.run!(5,report=true)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'Converter canonical behavior' do
|
4
|
+
|
5
|
+
context "there's just one pool on each side" do
|
6
|
+
|
7
|
+
before(:each) {
|
8
|
+
@d = Diagram.new 'foo'
|
9
|
+
@d.add_node! Pool, name: 'p9', initial_value: 9
|
10
|
+
@d.add_node! Pool, name: 'p0'
|
11
|
+
@d.add_node! Converter, name: 'c', mode: :pull_any
|
12
|
+
@d.add_edge! Edge, name:'e1', from: 'p9', to: 'c'
|
13
|
+
@d.add_edge! Edge, name:'e2',from: 'c', to: 'p0'
|
14
|
+
}
|
15
|
+
it 'is triggered by itself' do
|
16
|
+
c = @d.get_node 'c'
|
17
|
+
p0 = @d.get_node('p0')
|
18
|
+
p9 = @d.get_node('p9')
|
19
|
+
|
20
|
+
5.times{ c.trigger! }
|
21
|
+
|
22
|
+
# to unlock the resources
|
23
|
+
@d.get_node('p0').commit!
|
24
|
+
@d.get_node('p9').commit!
|
25
|
+
|
26
|
+
expect(@d.get_node('p0').resource_count).to eq 5
|
27
|
+
expect(@d.get_node('p9').resource_count).to eq 4
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'Pool canonical behaviour' do
|
4
|
+
|
5
|
+
context 'untyped pools' do
|
6
|
+
|
7
|
+
context 'push_any' do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
|
11
|
+
@p1 = Pool.new name: 'p1', initial_value: 2, mode: :push_any
|
12
|
+
@p2 = Pool.new name: 'p2'
|
13
|
+
|
14
|
+
@e = Edge.new name: 'e', from: @p1, to: @p2
|
15
|
+
@p1.attach_edge!(@e)
|
16
|
+
@p2.attach_edge!(@e)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'pushes one' do
|
21
|
+
|
22
|
+
@p1.trigger!
|
23
|
+
|
24
|
+
expect(@p1.resource_count).to eq 1
|
25
|
+
|
26
|
+
# because it's just received the resource, it'll be blocked
|
27
|
+
expect(@p2.instant_resource_count).to eq 1
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'pull_any' do
|
34
|
+
|
35
|
+
before(:each) do
|
36
|
+
@p1 = Pool.new name: 'p1', mode: :pull_any
|
37
|
+
@p2 = Pool.new name: 'p2', initial_value: 2
|
38
|
+
|
39
|
+
@e = Edge.new name: 'e', from: @p2, to: @p1
|
40
|
+
@p1.attach_edge!(@e)
|
41
|
+
@p2.attach_edge!(@e)
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'pulls one' do
|
47
|
+
@p1.trigger!
|
48
|
+
|
49
|
+
expect(@p2.resource_count).to eq 1
|
50
|
+
|
51
|
+
# # because it's just received the resource, it'll be blocked
|
52
|
+
expect(@p1.instant_resource_count).to eq 1
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'push_all' do
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'pull_all' do
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Converter do
|
4
|
+
|
5
|
+
|
6
|
+
it 'is created with name as single argument' do
|
7
|
+
|
8
|
+
expect { Converter.new name: 'foo' }.not_to raise_error
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is added into a diagram' do
|
13
|
+
|
14
|
+
d = Diagram.new 'd'
|
15
|
+
|
16
|
+
d.add_node! Converter, name: 'conv'
|
17
|
+
|
18
|
+
expect(d.get_node('conv')).to be_a Converter
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'is connected to one edge in and one edge out' do
|
23
|
+
|
24
|
+
c = Converter.new name: 'c'
|
25
|
+
|
26
|
+
c.attach_edge(double(:from => c, :to => double()))
|
27
|
+
|
28
|
+
c.attach_edge(double(:from => double(), :to => c))
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe '#trigger!' do
|
34
|
+
|
35
|
+
context 'simple' do
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
|
39
|
+
@c = Converter.new name: 'c'
|
40
|
+
@edge_in = instance_double(Edge, from: double(), to: @c, label: 1, pull_expression: proc{true==true})
|
41
|
+
@edge_out = instance_double(Edge, from: @c, to: double(), label: 1,push_expression: proc{true==true})
|
42
|
+
@c.attach_edge!(@edge_in).attach_edge!(@edge_out)
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'asks incoming edges for their pull_expressions' do
|
47
|
+
|
48
|
+
expect(@edge_in).to receive(:pull_expression)
|
49
|
+
expect(@edge_in).to receive(:pull!)
|
50
|
+
@edge_out.as_null_object
|
51
|
+
@c.trigger!
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
it "doesn't ping outgoing edges if incoming edge cannot pull" do
|
56
|
+
|
57
|
+
expect(@edge_in).to receive(:pull_expression).and_raise(RuntimeError)
|
58
|
+
expect(@edge_out).not_to receive(:push!)
|
59
|
+
|
60
|
+
@c.trigger!
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when pull_any' do
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
|
70
|
+
@c = Converter.new name: 'c', mode: :pull_any
|
71
|
+
@edge_in = instance_double(Edge, from: double(), to: @c,label:1)
|
72
|
+
@edge_out = instance_double(Edge, from: @c, to: double(),label:1)
|
73
|
+
@c.attach_edge!(@edge_in).attach_edge!(@edge_out)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'does not push when resource contributions are not met' do
|
78
|
+
|
79
|
+
expect(@edge_in).to receive(:pull_expression).and_return(proc{true})
|
80
|
+
|
81
|
+
expect(@edge_in).to receive(:pull!)
|
82
|
+
|
83
|
+
expect(@edge_out).not_to receive(:push_expression)
|
84
|
+
|
85
|
+
expect(@c).to receive(:in_conditions_met?).and_return(false)
|
86
|
+
|
87
|
+
@c.trigger!
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'does cause a push when resource contribution is met, even if across turns' do
|
93
|
+
expect(@edge_in).to receive(:pull_expression).and_raise(RuntimeError)
|
94
|
+
|
95
|
+
expect(@edge_in).not_to receive(:pull!)
|
96
|
+
|
97
|
+
expect(@c).to receive(:in_conditions_met?).and_return(true)
|
98
|
+
|
99
|
+
|
100
|
+
expect(@edge_out).to receive(:test_push?).and_return(true)
|
101
|
+
expect(@edge_out).to receive(:push_expression).and_return(proc{true})
|
102
|
+
expect(@edge_out).to receive(:push!)
|
103
|
+
|
104
|
+
@c.trigger!
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when pull_all' do
|
110
|
+
|
111
|
+
before(:each) do
|
112
|
+
@c = Converter.new name: 'c', mode: :pull_all
|
113
|
+
@edge_in = instance_double(Edge, from: double(), to: @c, label:1,pull_expression: proc{true})
|
114
|
+
@edge_in2 = instance_double(Edge, from: double(), to: @c, label: 1,pull_expression: proc{true})
|
115
|
+
@edge_out = instance_double(Edge, from: @c, to: double(), label: 1,push_expression: proc{true})
|
116
|
+
@c.attach_edge!(@edge_in).attach_edge!(@edge_in2).attach_edge!(@edge_out)
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
it 'pushes and pulls if all edges (incoming and outgoing) can push and pull, respectively' do
|
121
|
+
|
122
|
+
expect(@edge_in).to receive(:test_pull?).with(true).and_return(true)
|
123
|
+
expect(@edge_in).to receive(:pull!)
|
124
|
+
|
125
|
+
expect(@edge_in2).to receive(:test_pull?).with(true).and_return(true)
|
126
|
+
expect(@edge_in2).to receive(:pull!)
|
127
|
+
|
128
|
+
expect(@edge_out).to receive(:test_push?).with(true).and_return(true)
|
129
|
+
expect(@edge_out).to receive(:push!)
|
130
|
+
|
131
|
+
|
132
|
+
@c.trigger!
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
it 'does not pull or push if at least one incoming edge cannot pull ' do
|
138
|
+
|
139
|
+
# they are shuffled and we stop sending test_ping? to edges
|
140
|
+
# once one has returned false. Therefore we do not know which
|
141
|
+
# edges will receive the message so we have to allow all to.
|
142
|
+
|
143
|
+
allow(@edge_in).to receive_messages(:test_pull? => false)
|
144
|
+
allow(@edge_in2).to receive_messages(:test_pull? => false)
|
145
|
+
allow(@edge_out).to receive_messages(:test_push? => false)
|
146
|
+
|
147
|
+
# but none outgoing will get pinged
|
148
|
+
expect(@edge_in).not_to receive(:pull!)
|
149
|
+
expect(@edge_in2).not_to receive(:pull!)
|
150
|
+
expect(@edge_out).not_to receive(:push!)
|
151
|
+
|
152
|
+
|
153
|
+
@c.trigger!
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'also does not pull or push if at least one outgoing edge cannot push' do
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '#put_resource!' do
|
166
|
+
|
167
|
+
before(:each) do
|
168
|
+
@c = Converter.new name: 'c'
|
169
|
+
@edge_in = instance_double(Edge, from: double(), to: @c, label: 1)
|
170
|
+
@edge_out = instance_double(Edge, from: @c, to: double(), label: 1)
|
171
|
+
@c.attach_edge!(@edge_out)
|
172
|
+
@c.attach_edge!(@edge_in)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'does not ping incoming edges' do
|
176
|
+
|
177
|
+
expect(@edge_in).not_to receive(:test_pull?)
|
178
|
+
expect(@edge_out).to receive(:push_expression).and_return(proc{true})
|
179
|
+
@edge_out.as_null_object
|
180
|
+
@c.put_resource!(double(), @edge_in)
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#take_resource!' do
|
187
|
+
|
188
|
+
before(:each) do
|
189
|
+
|
190
|
+
# TODO
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'something' do
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
describe '#attach_edge' do
|
201
|
+
|
202
|
+
before(:each) do
|
203
|
+
@c = Converter.new name: 'c'
|
204
|
+
@e = Edge.new name: 'e', from: double(), to: @c
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'adds attached edge to resources_contributed hash' do
|
209
|
+
|
210
|
+
hsh = Hash.new
|
211
|
+
|
212
|
+
expect(@c).to receive(:resources_contributed).and_return(hsh)
|
213
|
+
|
214
|
+
expect(hsh).to receive(:store)
|
215
|
+
|
216
|
+
@c.attach_edge!(@e)
|
217
|
+
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|