spec/command_line_spec.rb in shutter-0.1.0 vs spec/command_line_spec.rb in shutter-0.2.0
- old
+ new
@@ -1,12 +1,19 @@
require File.dirname(__FILE__) + '/spec_helper'
describe "Shutter::CommandLine" do
before(:each) do
+ FileUtils.mkdir("./tmp")
+ Shutter::Files.create("./tmp")
@cmd = Shutter::CommandLine.new("./tmp")
end
+ after(:each) do
+ FileUtils.rm Dir.glob('./tmp/*')
+ FileUtils.rmdir("./tmp")
+ end
+
it "should not raise exception when firewall is called" do
expect { @cmd.firewall }.to_not raise_error
end
it "should set default value of persist to false" do
@@ -34,10 +41,17 @@
@cmd.execute(["--restore", "--persist"],true)
@cmd.command.should == :restore
@cmd.persist.should == true
end
+ it "should set the command to :check" do
+ @cmd.execute(["--check"],true)
+ @cmd.command.should == :check
+ @cmd.execute(["-c"],true)
+ @cmd.command.should == :check
+ end
+
it "should set the command to :init" do
@cmd.execute(["--init"],true)
@cmd.command.should == :init
end
@@ -50,33 +64,33 @@
@cmd.execute(["--upgrade"],true)
@cmd.command.should == :upgrade
end
it "should set the config path and persist" do
- Shutter::OS.stubs(:version).returns("Unknown")
- @cmd.execute(["--dir", "/tmp", "--restore", "--persist"],true)
+ @cmd.os.stubs(:version).returns("Unknown")
+ @cmd.execute(["--dir", "./tmp", "--restore", "--persist"],true)
@cmd.command.should == :restore
@cmd.persist.should == true
@cmd.persist_file.should == "/tmp/iptables.rules"
- @cmd.config_path.should == "/tmp"
- @cmd.execute(["-d", "/tmp", "--restore", "--persist"],true)
+ @cmd.config_path.should == "./tmp"
+ @cmd.execute(["-d", "./tmp", "--restore", "--persist"],true)
@cmd.command.should == :restore
@cmd.persist.should == true
@cmd.persist_file.should == "/tmp/iptables.rules"
- @cmd.config_path.should == "/tmp"
+ @cmd.config_path.should == "./tmp"
end
it "should set the config path and persist with file" do
- Shutter::OS.stubs(:version).returns("Unknown")
- @cmd.execute(["--dir", "/tmp", "--restore", "--persist", "/tmp/persistance.file"],true)
+ @cmd.os.stubs(:version).returns("Unknown")
+ @cmd.execute(["--dir", "./tmp", "--restore", "--persist", "./tmp/persistance.file"],true)
@cmd.command.should == :restore
@cmd.persist.should == true
- @cmd.persist_file.should == "/tmp/persistance.file"
- @cmd.config_path.should == "/tmp"
- @cmd.execute(["-d", "/tmp", "--restore", "--persist", "/tmp/persistance.file"],true)
+ @cmd.persist_file.should == "./tmp/persistance.file"
+ @cmd.config_path.should == "./tmp"
+ @cmd.execute(["-d", "./tmp", "--restore", "--persist", "./tmp/persistance.file"],true)
@cmd.command.should == :restore
@cmd.persist.should == true
- @cmd.persist_file.should == "/tmp/persistance.file"
- @cmd.config_path.should == "/tmp"
+ @cmd.persist_file.should == "./tmp/persistance.file"
+ @cmd.config_path.should == "./tmp"
end
end
\ No newline at end of file