spec/invoker/invoker_spec.rb in invoker-1.0.4 vs spec/invoker/invoker_spec.rb in invoker-1.1.0
- old
+ new
@@ -47,7 +47,38 @@
Invoker.expects(:ruby_platform).returns("x86_64-darwin12.4.0")
Invoker::Logger.expects(:puts).never()
Invoker.can_run_balancer?(false)
end
end
+
+ describe "#setup_config_location" do
+ before do
+ Dir.stubs(:home).returns('/tmp')
+ @config_location = File.join('/tmp', '.invoker')
+ FileUtils.rm_rf(@config_location)
+ end
+
+ context "when the old config file does not exist" do
+ it "creates the new config directory" do
+ Invoker.setup_config_location
+ expect(Dir.exist?(@config_location)).to be_true
+ end
+ end
+
+ context "when the old config file exists" do
+ before do
+ File.open(@config_location, 'w') do |file|
+ file.write('invoker config')
+ end
+ end
+
+ it "moves the file to the new directory" do
+ Invoker.setup_config_location
+ expect(Dir.exist?(@config_location)).to be_true
+ new_config_file = File.join(@config_location, 'config')
+ expect(File.exist?(new_config_file)).to be_true
+ expect(File.read(new_config_file)).to match('invoker config')
+ end
+ end
+ end
end