diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/spec/simulator.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/spec/simulator.rb b/tests/spec/simulator.rb new file mode 100644 index 0000000..7919647 --- /dev/null +++ b/tests/spec/simulator.rb @@ -0,0 +1,39 @@ +require 'aruba/rspec' + +IFILE_PATH = 'installfile' + +def run_simulate(extra = '') + run_command 'hscript-simulate ' + IFILE_PATH + extra +end + +def use_fixture(fixture) + copy '%/' + fixture, IFILE_PATH +end + +RSpec.describe 'HorizonScript Simulator', :type => :aruba do + context "argument passing" do + it "requires an installfile to be specified" do + run_command 'hscript-simulate' + expect(last_command_started).to have_output(/usage/) + end + it "doesn't output ANSI colours when redirected" do + run_command 'hscript-simulate foo 2>/dev/null' + expect(last_command_started).to_not have_output(/\033/) + end + it "outputs the hashbang when redirected" do + run_command 'hscript-simulate foo' + expect(last_command_started.stdout).to start_with("#!/bin/sh") + end + end + context "simulating 'mount' flags" do + it "mounts directories in tree order" do + use_fixture '0057-many-mounts.installfile' + run_simulate + expect(last_command_started.stdout).to include(" +mount /dev/sda1 /target/ +mount /dev/gwyn/home /target/home +mount /dev/sda2 /target/usr +mount /dev/gwyn/source /target/usr/src") + end + end +end |