Sha256: 2e25291887d36d96cc3cc8cd25983efda6e8eab4b3b98e8a5e7e326bf84eddd9
Contents?: true
Size: 1.46 KB
Versions: 30
Compression:
Stored size: 1.46 KB
Contents
require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb") describe "AutomateIt::EditManager for files" do before :all do @a = AutomateIt.new(:verbosity => Logger::WARN) end it "should make a backup if editing a file" do @a.mktempdircd do target = "myfile" @a.render(:text => "Whatever", :to => target) entries = Dir.entries(".").select{|t| t =~ /^#{target}/} entries.size.should == 1 @a.edit(:file => target) do append "Hello" end.should be_true entries = Dir.entries(".").select{|t| t =~ /^#{target}/} entries.size.should == 2 File.size(entries[0]).should_not == File.size(entries[1]) end end it "should not make a backup if not editing a file" do @a.mktempdircd do target = "myfile" @a.render(:text => "Whatever", :to => target) entries = Dir.entries(".").select{|t| t =~ /^#{target}/} entries.size.should == 1 @a.edit(:file => target) do end.should be_false entries = Dir.entries(".").select{|t| t =~ /^#{target}/} entries.size.should == 1 end end it "should not make a backup for a newly created file" do @a.mktempdircd do target = "myfile" @a.edit(:file => target, :create => true) do append "Hello" end.should be_true entries = Dir.entries(".").select{|t| t =~ /^#{target}/} entries.size.should == 1 end end end
Version data entries
30 entries across 30 versions & 2 rubygems