spec/invoker/power/setup/osx_setup_spec.rb in invoker-1.4.1 vs spec/invoker/power/setup/osx_setup_spec.rb in invoker-1.5.1
- old
+ new
@@ -1,11 +1,16 @@
require "spec_helper"
-describe Invoker::Power::OsxSetup do
- describe "When no setup exists" do
+describe Invoker::Power::OsxSetup, fakefs: true do
+ before do
+ FileUtils.mkdir_p(inv_conf_dir)
+ FileUtils.mkdir_p(Invoker::Power::OsxSetup::RESOLVER_DIR)
+ end
+
+ describe "when no setup exists" do
it "should create a config file with port etc" do
- setup = Invoker::Power::OsxSetup.new
+ setup = Invoker::Power::OsxSetup.new('dev')
setup.expects(:install_resolver).returns(true)
setup.expects(:drop_to_normal_user).returns(true)
setup.expects(:install_firewall).once
setup.setup_invoker
@@ -21,20 +26,20 @@
it "should throw error about existing file" do
File.open(Invoker::Power::Config.config_file, "w") {|fl|
fl.write("foo test")
}
Invoker::Power::Setup.any_instance.expects(:setup_invoker).never
- Invoker::Power::Setup.install()
+ Invoker::Power::Setup.install('dev')
end
end
describe "when pow like setup exists" do
before {
- File.open(Invoker::Power::OsxSetup::RESOLVER_FILE, "w") {|fl|
+ File.open(File.join(Invoker::Power::OsxSetup::RESOLVER_DIR, "dev"), "w") { |fl|
fl.write("hello")
}
- @setup = Invoker::Power::OsxSetup.new
+ @setup = Invoker::Power::OsxSetup.new('dev')
}
describe "when user selects to overwrite it" do
it "should run setup normally" do
@setup.expects(:setup_resolver_file).returns(true)
@@ -58,11 +63,11 @@
end
end
describe "uninstalling firewall rules" do
it "should uninstall firewall rules and remove all files created by setup" do
- setup = Invoker::Power::OsxSetup.new
+ setup = Invoker::Power::OsxSetup.new('dev')
Invoker::CLI::Question.expects(:agree).returns(true)
setup.expects(:remove_resolver_file).once
setup.expects(:unload_firewall_rule).with(true).once
Invoker::Power::Config.expects(:delete).once
@@ -72,20 +77,29 @@
end
describe "setup on fresh osx install" do
context "when resolver directory does not exist" do
before do
- @setup = Invoker::Power::OsxSetup.new
+ @setup = Invoker::Power::OsxSetup.new('dev')
FileUtils.rm_rf(Invoker::Power::OsxSetup::RESOLVER_DIR)
end
it "should create the directory and install" do
@setup.expects(:setup_resolver_file).returns(true)
@setup.expects(:drop_to_normal_user).returns(true)
@setup.expects(:install_firewall).once()
@setup.setup_invoker
expect(Dir.exist?(Invoker::Power::OsxSetup::RESOLVER_DIR)).to be_truthy
+ end
+ end
+ end
+
+ describe '.resolver_file' do
+ context 'user sets up a custom top level domain' do
+ it 'should create the correct resolver file' do
+ setup = Invoker::Power::OsxSetup.new('local')
+ expect(setup.resolver_file).to eq('/etc/resolver/local')
end
end
end
end