Sha256: 255bd1f380b818176ac3221eaf24ac3b40fa759f2c5b9680cc631d1e3896779c
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'spec_helper' def wlang(str, binding) str.gsub(/\$\(([\S]+)\)/){ Kernel.eval($1, binding) } end def _(path, file) File.expand_path("../#{path}", file) end describe "Alf's alf command / " do Path.dir.glob('**/*.cmd').each do |input| cmd = wlang(input.readlines.first, binding) specify{ cmd.should =~ /^alf / } describe "#{input.basename}: #{cmd}" do let(:argv) { Quickl.parse_commandline_args(cmd)[1..-1] } let(:stdout) { input.sub_ext('.stdout') } let(:stderr) { input.sub_ext('.stderr') } let(:stdout_expected) { stdout.exists? ? wlang(stdout.read, binding) : "" } let(:stderr_expected) { stderr.exists? ? wlang(stderr.read, binding) : "" } before{ $oldstdout = $stdout $oldstderr = $stderr $stdout = StringIO.new $stderr = StringIO.new } after { $stdout = $oldstdout $stderr = $oldstderr $oldstdout = nil $oldstderr = nil } specify{ begin dir = Path.relative('__database__') main = Alf::Shell::Main.new main.database = Alf.connect(dir) main.run(argv, __FILE__) rescue => ex begin Alf::Shell::Main.handle_error(ex, main) rescue SystemExit $stdout << "SystemExit" << "\n" end end $stdout.string.should(eq(stdout_expected)) $stderr.string.should(eq(stderr_expected)) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alf-shell-0.13.1 | spec/integration/test_shell.rb |
alf-shell-0.13.0 | spec/integration/test_shell.rb |