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

Version Path
automate-it-0.9.2 spec/integration/edit_manager_spec.rb
automate-it-0.9.1 spec/integration/edit_manager_spec.rb
automate-it-0.9.0 spec/integration/edit_manager_spec.rb
automateit-0.70928 spec/integration/edit_manager_spec.rb
automateit-0.70930 spec/integration/edit_manager_spec.rb
automateit-0.71003 spec/integration/edit_manager_spec.rb
automateit-0.71021 spec/integration/edit_manager_spec.rb
automateit-0.71031.1 spec/integration/edit_manager_spec.rb
automateit-0.71031.2 spec/integration/edit_manager_spec.rb
automateit-0.71030 spec/integration/edit_manager_spec.rb
automateit-0.71017 spec/integration/edit_manager_spec.rb
automateit-0.71012 spec/integration/edit_manager_spec.rb
automateit-0.71006 spec/integration/edit_manager_spec.rb
automateit-0.71103 spec/integration/edit_manager_spec.rb
automateit-0.71031 spec/integration/edit_manager_spec.rb
automateit-0.71101 spec/integration/edit_manager_spec.rb
automateit-0.71101.1 spec/integration/edit_manager_spec.rb
automateit-0.71101.2 spec/integration/edit_manager_spec.rb
automateit-0.71102 spec/integration/edit_manager_spec.rb
automateit-0.71220 spec/integration/edit_manager_spec.rb