spec/unit/robots_spec.rb in robot-controller-2.0.1 vs spec/unit/robots_spec.rb in robot-controller-2.0.2
- old
+ new
@@ -59,57 +59,46 @@
end.to raise_error(RuntimeError)
end
end
context 'instances_valid?' do
- subject do
- RobotController::Parser
- end
it 'valid inputs' do
- expect(subject.instances_valid?(0)).to eq 1
- expect(subject.instances_valid?(1)).to eq 1
- expect(subject.instances_valid?(8)).to eq 8
- expect(subject.instances_valid?(16)).to eq 16
+ expect(described_class.instances_valid?(0)).to eq 1
+ expect(described_class.instances_valid?(1)).to eq 1
+ expect(described_class.instances_valid?(8)).to eq 8
+ expect(described_class.instances_valid?(16)).to eq 16
end
it 'invalid inputs' do
expect do
- subject.instances_valid?(17)
+ described_class.instances_valid?(17)
end.to raise_error RuntimeError
end
end
context 'parse_lanes' do
- subject do
- RobotController::Parser
+ it 'handles valid inputs' do
+ expect(described_class.parse_lanes('*')).to eq ['*']
+ expect(described_class.parse_lanes('')).to eq ['default']
+ expect(described_class.parse_lanes('default')).to eq ['default']
+ expect(described_class.parse_lanes('A')).to eq ['A']
+ expect(described_class.parse_lanes('A,B')).to eq %w(A B)
end
- it 'valid inputs' do
- expect(subject.parse_lanes('*')).to eq ['*']
- expect(subject.parse_lanes('')).to eq ['default']
- expect(subject.parse_lanes('default')).to eq ['default']
- expect(subject.parse_lanes('A')).to eq ['A']
- expect(subject.parse_lanes('A,B')).to eq %w(A B)
+ it 'handles tricky inputs' do
+ expect(described_class.parse_lanes(' ')).to eq ['default']
+ expect(described_class.parse_lanes(' , ')).to eq ['default']
+ expect(described_class.parse_lanes(' ,,')).to eq ['default']
+ expect(described_class.parse_lanes('A , B')).to eq %w(A B)
+ expect(described_class.parse_lanes('A-B')).to eq ['A-B']
+ expect(described_class.parse_lanes('A,B,A')).to eq %w(A B)
end
-
- it 'tricky inputs' do
- expect(subject.parse_lanes(' ')).to eq ['default']
- expect(subject.parse_lanes(' , ')).to eq ['default']
- expect(subject.parse_lanes(' ,,')).to eq ['default']
- expect(subject.parse_lanes('A , B')).to eq %w(A B)
- expect(subject.parse_lanes('A-B')).to eq ['A-B']
- expect(subject.parse_lanes('A,B,A')).to eq %w(A B)
- end
end
context 'queue_names' do
- subject do
- RobotController::Parser
- end
-
- it 'valid inputs' do
- expect(subject.queue_names('z', '*')).to eq ['z_*']
- expect(subject.queue_names('z', 'default')).to eq ['z_default']
- expect(subject.queue_names('z', 'A,B,C')).to eq %w(z_A z_B z_C)
+ it 'handles valid inputs' do
+ expect(described_class.queue_names('z', '*')).to eq ['z_*']
+ expect(described_class.queue_names('z', 'default')).to eq ['z_default']
+ expect(described_class.queue_names('z', 'A,B,C')).to eq %w(z_A z_B z_C)
end
end
end