spec/applix_spec.rb in applix-0.4.10 vs spec/applix_spec.rb in applix-0.4.11
- old
+ new
@@ -2,33 +2,33 @@
describe Applix do
context 'main' do
it 'catches unknown task errors' do
- expect { Applix.main(%w(no-such-task)) {} }.
- should_not raise_error /no-such-task/
+ expect { Applix.main(%w(no-such-task)) {} }.not_to raise_error
end
context 'with captured I/O streams' do
it 'prints a minimal (better than nothing?) usage line on errors' do
output = capture(:stdout) { Applix.main(%w(no-such-task)) {} }
output.should =~ /usage: /
end
it 'suppresses the callstack on errors' do
output = capture(:stdout) { Applix.main(%w(no-such-task)) {} }
- output.should_not =~ /no such task:/
+ output.should =~ / ## no such task:/
+ output.should_not =~ / !! no such task:/
end
it 'shows callstack on --debug option' do
output = capture(:stdout) { Applix.main(%w(--debug no-such-task)) {} }
output.should =~ / !! no such task:/
end
it 'dumps a stacktrace on main with a !' do
expect { Applix.main!(%w(no-such-task)) {} }.
- should raise_error /no such task:/
+ to raise_error /no such task:/
end
end
end
describe 'cluster' do
@@ -192,10 +192,22 @@
end
end
end
end
+ it 'loops over args with argsloop app option to any' do
+ # stubbed app simulates consuming the args while looping over app calls
+ app = double(:app)
+ app.should_receive(:a).with(%w(1 b 2 3 c 4 5 6), {}).and_return(%w(b 2 3))
+ app.should_receive(:b).with(%w(2 3), {}).and_return(%w(c 4 5 6))
+ app.should_receive(:c).with(%w(4 5 6), {}).and_return([])
+ Applix.main(%w(a 1 b 2 3 c 4 5 6)) do
+ handle(:not_called) { raise "can't possible happen" }
+ any(argsloop: app)
+ end
+ end
+
it 'should call actions by first argument names' do
argv = ['func']
Applix.main(argv) do
handle(:func) { :func_return }
end.should == :func_return
@@ -219,10 +231,10 @@
Applix.main(argv) do
handle(:func) { |*_, options| options }
end.should include(:a => true, :bar => true)
end
- it 'parses dashes in string options' do
+ pending 'parses dashes in string options' do
end
it "should parse the old unit test..." do
# see applix_hash_spec.rb