summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2014-03-17 09:32:39 -0700
committerBryan McLellan <btm@getchef.com>2014-03-19 14:39:25 -0700
commit6bd0fd7f8a97e2637149a7a98b22fcd49c5ee804 (patch)
treec9f8f7855af299176e8f062c25748cb81f904d24
parentc1e47c10abf83e61e02e782dc7f92f8ba812f3eb (diff)
downloadchef-6bd0fd7f8a97e2637149a7a98b22fcd49c5ee804.tar.gz
CHEF-3714: Update tests for changes from CHEF-5018
Signed-off-by: Bryan McLellan <btm@opscode.com>
-rw-r--r--spec/unit/provider/ifconfig/debian_spec.rb32
-rw-r--r--spec/unit/util/file_edit_spec.rb26
2 files changed, 18 insertions, 40 deletions
diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb
index a8c2f6ce02..c6a37fdd5b 100644
--- a/spec/unit/provider/ifconfig/debian_spec.rb
+++ b/spec/unit/provider/ifconfig/debian_spec.rb
@@ -37,7 +37,6 @@ describe Chef::Provider::Ifconfig::Debian do
new_resource
end
-<<<<<<< HEAD
let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) }
let(:provider) do
@@ -313,37 +312,6 @@ source #{tempdir_path}/*
end
end
end
-=======
- describe "generate_config for action_add" do
- before do
- @config_file_ifaces = StringIO.new
- @config_file_ifcfg = StringIO.new
- FileUtils.should_receive(:cp)
- File.should_receive(:open).with(@config_filename_ifaces).and_yield(@config_file_ifaces)
- File.should_receive(:open).with(@config_filename_ifaces, "w").and_yield(@config_file_ifaces)
- File.should_receive(:new).with(@config_filename_ifcfg, "w").and_return(@config_file_ifcfg)
- end
-
- it "should create network-scripts directory" do
- File.should_receive(:directory?).with(File.dirname(@config_filename_ifcfg)).and_return(false)
- Dir.should_receive(:mkdir).with(File.dirname(@config_filename_ifcfg))
- @provider.run_action(:add)
- end
-
- it "should write configure network-scripts directory" do
- File.should_receive(:directory?).with(File.dirname(@config_filename_ifcfg)).and_return(true)
- @provider.run_action(:add)
- @config_file_ifaces.string.should match(/^\s*source\s+\/etc\/network\/interfaces[.]d\/[*]\s*$/)
- end
-
- it "should write a network-script" do
- File.should_receive(:directory?).with(File.dirname(@config_filename_ifcfg)).and_return(true)
- @provider.run_action(:add)
- @config_file_ifcfg.string.should match(/^iface eth0 inet static\s*$/)
- @config_file_ifcfg.string.should match(/^\s+address 10\.0\.0\.1\s*$/)
- @config_file_ifcfg.string.should match(/^\s+netmask 255\.255\.254\.0\s*$/)
- end
->>>>>>> CHEF-3714: Use Editor to manipulate text
end
describe "delete_config for action_delete" do
diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb
index e1b8e26e69..9acfb1baea 100644
--- a/spec/unit/util/file_edit_spec.rb
+++ b/spec/unit/util/file_edit_spec.rb
@@ -81,6 +81,17 @@ new line inserted
EOF
end
+ let(:append_twice) do
+ <<-EOF
+127.0.0.1 localhost
+255.255.255.255 broadcasthost
+::1 localhost
+fe80::1%lo0 localhost
+once
+twice
+ EOF
+ end
+
let(:target_file) do
f = Tempfile.open('file_edit_spec')
f.write(starting_content)
@@ -105,7 +116,7 @@ new line inserted
# CHEF-5018: people have monkey patched this and it has accidentally been broken
it "should read the contents into memory as an array" do
- expect(fedit.send(:contents)).to be_instance_of(Array)
+ expect(fedit.send(:editor).lines).to be_instance_of(Array)
end
end
@@ -138,7 +149,7 @@ new line inserted
it "should do nothing if there isn't a match" do
fedit.search_file_replace(/pattern/, "replacement")
- fedit.unwritten_changes?.should be_true
+ fedit.unwritten_changes?.should be_false
fedit.write_file
expect(edited_file_contents).to eq(starting_content)
end
@@ -190,17 +201,16 @@ new line inserted
it "should do nothing if there is a match" do
fedit.insert_line_if_no_match(/localhost/, "replacement")
- fedit.unwritten_changes?.should be_true
+ fedit.unwritten_changes?.should be_false
fedit.write_file
expect(edited_file_contents).to eq(starting_content)
end
it "should work more than once" do
- @fedit.insert_line_if_no_match(/missing/, "added")
- @fedit.insert_line_if_no_match(/missing/, "twice")
- @fedit.write_file
- newfile = File.new(@tempfile.path).readlines
- newfile.last.should match(/twice/)
+ fedit.insert_line_if_no_match(/missing/, "once")
+ fedit.insert_line_if_no_match(/missing/, "twice")
+ fedit.write_file
+ expect(edited_file_contents).to eq(append_twice)
end
end
end