spec/rflow/configuration/ruby_dsl_spec.rb in rflow-1.0.1 vs spec/rflow/configuration/ruby_dsl_spec.rb in rflow-1.1.0
- old
+ new
@@ -3,24 +3,24 @@
class RFlow
class Configuration
describe RubyDSL do
before(:each) do
- ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
Configuration.migrate_database
end
- it "should correctly process an empty DSL" do
+ it 'should correctly process an empty DSL' do
described_class.configure {}
expect(Shard).to have(0).shards
expect(Component).to have(0).components
expect(Port).to have(0).ports
expect(Connection).to have(0).connections
end
- it "should correctly process a component declaration" do
+ it 'should correctly process a component declaration' do
described_class.configure do |c|
c.component 'boom', 'town', 'opt1' => 'OPT1', 'opt2' => 'OPT2'
end
expect(Shard).to have(1).shard
@@ -33,11 +33,11 @@
expect(c.specification).to eq('town')
expect(c.options).to eq('opt1' => 'OPT1', 'opt2' => 'OPT2')
end
end
- it "should correctly process a connect declaration" do
+ it 'should correctly process a connect declaration' do
described_class.configure do |c|
c.component 'first', 'First'
c.component 'second', 'Second'
c.component 'third', 'Third'
c.connect 'first#out' => 'second#in'
@@ -107,36 +107,36 @@
expect(in_port).to have(1).connections
expect(in_port.connections).to eq(second_component.output_ports.first.connections)
end
end
- it "should correctly process shard declarations" do
+ it 'should correctly process shard declarations' do
described_class.configure do |c|
c.component 'first', 'First', :opt1 => 'opt1'
- c.shard "s1", :process => 2 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's1', :process => 2 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
- c.shard "s2", :type => :process, :count => 10 do |s|
+ c.shard 's2', :type => :process, :count => 10 do |s|
s.component 'third', 'Third'
s.component 'fourth', 'Fourth'
end
- c.process "s3", :count => 10 do |s|
+ c.process 's3', :count => 10 do |s|
s.component 'fifth', 'Fifth'
end
- c.shard "s-ignored", :type => :process, :count => 10 do
+ c.shard 's-ignored', :type => :process, :count => 10 do
# ignored because there are no components
end
- c.thread "s4", :count => 10 do |s|
+ c.thread 's4', :count => 10 do |s|
s.component 'sixth', 'Sixth'
end
- c.shard "s5", :type => :thread, :count => 10 do |s|
+ c.shard 's5', :type => :thread, :count => 10 do |s|
s.component 'seventh', 'Seventh'
end
c.component 'eighth', 'Eighth'
@@ -171,16 +171,16 @@
'third#out=>fourth#in',
'third#out=>fifth#in',
'third#out=>sixth#in'])
end
- it "should generate PUSH-PULL inproc ZeroMQ connections for in-shard connections" do
+ it 'should generate PUSH-PULL inproc ZeroMQ connections for in-shard connections' do
described_class.configure do |c|
- c.shard "s1", :process => 2 do |s|
+ c.shard 's1', :process => 2 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in'
end
@@ -203,19 +203,19 @@
expect(opts['input_responsibility']).to eq('bind')
end
end
end
- it "should generate PUSH-PULL ipc ZeroMQ connections for one-to-one inter-shard connections" do
+ it 'should generate PUSH-PULL ipc ZeroMQ connections for one-to-one inter-shard connections' do
described_class.configure do |c|
- c.shard "s1", :process => 1 do |s|
+ c.shard 's1', :process => 1 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 1 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 1 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in'
end
@@ -238,19 +238,19 @@
expect(opts['input_responsibility']).to eq('bind')
end
end
end
- it "should generate PUSH-PULL ipc ZeroMQ connections for one-to-many inter-shard connections" do
+ it 'should generate PUSH-PULL ipc ZeroMQ connections for one-to-many inter-shard connections' do
described_class.configure do |c|
- c.shard "s1", :process => 1 do |s|
+ c.shard 's1', :process => 1 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 3 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 3 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in'
end
@@ -273,19 +273,19 @@
expect(opts['input_responsibility']).to eq('connect')
end
end
end
- it "should generate PUSH-PULL ipc ZeroMQ connections for many-to-one inter-shard connections" do
+ it 'should generate PUSH-PULL ipc ZeroMQ connections for many-to-one inter-shard connections' do
described_class.configure do |c|
- c.shard "s1", :process => 3 do |s|
+ c.shard 's1', :process => 3 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 1 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 1 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in'
end
@@ -308,19 +308,19 @@
expect(opts['input_responsibility']).to eq('bind')
end
end
end
- it "should generate PUSH-PULL brokered ZeroMQ connections for many-to-many inter-shard connections" do
+ it 'should generate PUSH-PULL brokered ZeroMQ connections for many-to-many inter-shard connections' do
described_class.configure do |c|
- c.shard "s1", :process => 3 do |s|
+ c.shard 's1', :process => 3 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 3 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 3 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in'
end
@@ -343,19 +343,19 @@
expect(opts['input_responsibility']).to eq('connect')
end
end
end
- it "should generate PUB-SUB ipc ZeroMQ connections for one-to-many broadcast connections" do
+ it 'should generate PUB-SUB ipc ZeroMQ connections for one-to-many broadcast connections' do
described_class.configure do |c|
- c.shard "s1", :process => 1 do |s|
+ c.shard 's1', :process => 1 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 3 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 3 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in', :delivery => 'broadcast'
end
@@ -378,19 +378,19 @@
expect(opts['input_responsibility']).to eq('connect')
end
end
end
- it "should generate PUB-SUB brokered ZeroMQ connections for many-to-many broadcast connections" do
+ it 'should generate PUB-SUB brokered ZeroMQ connections for many-to-many broadcast connections' do
described_class.configure do |c|
- c.shard "s1", :process => 3 do |s|
+ c.shard 's1', :process => 3 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
end
- c.shard "s2", :process => 3 do |s|
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ c.shard 's2', :process => 3 do |s|
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in', :delivery => 'broadcast'
end
@@ -413,16 +413,16 @@
expect(opts['input_responsibility']).to eq('connect')
end
end
end
- it "should generate PUB-SUB brokered ZeroMQ connections for many-to-many in-shard broadcast connections" do
+ it 'should generate PUB-SUB brokered ZeroMQ connections for many-to-many in-shard broadcast connections' do
described_class.configure do |c|
- c.shard "s1", :process => 3 do |s|
+ c.shard 's1', :process => 3 do |s|
s.component 'first', 'First', :opt1 => 'opt1'
- s.component 'second', 'Second', :opt1 => 'opt1', "opt2" => "opt2"
+ s.component 'second', 'Second', :opt1 => 'opt1', 'opt2' => 'opt2'
end
c.connect 'first#out' => 'second#in', :delivery => 'broadcast'
end
@@ -445,25 +445,25 @@
expect(opts['input_responsibility']).to eq('connect')
end
end
end
- it "should not allow two components with the same name" do
+ it 'should not allow two components with the same name' do
expect {
described_class.configure do |c|
c.component 'first', 'First'
c.component 'first', 'First'
end
}.to raise_error(ActiveRecord::RecordInvalid)
end
- it "should not allow two shards with the same name" do
+ it 'should not allow two shards with the same name' do
expect {
described_class.configure do |c|
- c.shard("s1", :process => 2) {|c| c.component 'x', 'y' }
- c.shard("s1", :process => 2) {|c| c.component 'z', 'q' }
+ c.shard('s1', :process => 2) {|c| c.component 'x', 'y' }
+ c.shard('s1', :process => 2) {|c| c.component 'z', 'q' }
end
- }.to raise_error
+ }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
end