spec/integration/test_command.rb in viiite-0.1.0 vs spec/integration/test_command.rb in viiite-0.2.0
- old
+ new
@@ -1,33 +1,29 @@
require 'spec_helper'
-describe "viiite command / " do
+describe "viiite commands" do
Dir[File.expand_path('../**/*.cmd', __FILE__)].each do |input|
- cmd = File.readlines(input).first
- specify{ cmd.should =~ /^viiite / }
-
- describe "#{File.basename(input)}: #{cmd}" do
- let(:argv) { Quickl.parse_commandline_args(cmd)[1..-1] }
- let(:stdout) { File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stdout") }
- let(:stderr) { File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stderr") }
- let(:stdout_expected) { File.exists?(stdout) ? File.read(stdout) : "" }
- let(:stderr_expected) { File.exists?(stderr) ? File.read(stderr) : "" }
+ cmd = File.read(input).chomp
- before{ redirect_io }
- after { restore_io }
-
- specify{
+ specify "#{File.basename(input)}: #{cmd}" do
+ argv = Quickl.parse_commandline_args(cmd)[1..-1]
+ stdout = File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stdout")
+ stderr = File.join(File.dirname(input), "#{File.basename(input, ".cmd")}.stderr")
+ stdout_expected = File.exists?(stdout) ? File.read(stdout) : ""
+ stderr_expected = File.exists?(stderr) ? File.read(stderr) : ""
+
+ cmd.should match /^viiite /
+ cache = File.join(fixtures_folder, "saved")
+ out, err = capture_io do
begin
- if i = argv.index("raw_data")
- argv[i] = File.expand_path('../raw_data.rash', __FILE__)
- end
- Viiite::Command.run(argv)
+ Viiite::Command.run(["--suite=#{fixtures_folder}/bdb", "--cache=#{cache}"] + argv)
rescue SystemExit
- $stdout << "SystemExit" << "\n"
+ puts "SystemExit"
end
- $stdout.string.should(eq(stdout_expected)) unless RUBY_VERSION < "1.9"
- $stderr.string.should(eq(stderr_expected)) unless RUBY_VERSION < "1.9"
- }
+ end
+
+ out.should eq stdout_expected unless RUBY_VERSION < "1.9"
+ err.should eq stderr_expected unless RUBY_VERSION < "1.9"
end
end
-
+
end