Sha256: cbcabce8909f166d4d5fa24686b88fc6da7a6a933a8325fb36c8599af18aea2b

Contents?: true

Size: 1.57 KB

Versions: 51

Compression:

Stored size: 1.57 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper")

module Redcar
  describe Declarations::File do
    before do
      @tags_file = File.join(File.dirname(__FILE__), "..", "tags")
    end
    
    after do
      FileUtils.rm_f(@tags_file)
    end
    
    describe "dump and load from file" do
      describe "with no existing tags file" do
        before do
          @file = Declarations::File.new(@tags_file)
        end
        
        it "should have no tags" do
          @file.tags.should be_empty
        end
        
        it "should add new tags" do
          @file.add_tags([%w"Abc /foo class:Abc"])
          @file.tags.length.should == 1
        end
        
        describe "with tags added" do
          before do
            @file.add_tags([%w"Abc /foo class:Abc"])
          end
          
          it "should dump a tags file" do
            @file.dump
            File.exist?(@tags_file).should be_true
          end
        end
      end
      
      describe "with existing tags file" do
        before do
          file = Declarations::File.new(@tags_file)
          file.add_tags([%w"Abc /foo class:Abc"])
          file.last_updated = Time.now
          @last_updated = Time.now
          file.dump
          @file = Declarations::File.new(@tags_file)
        end
        
        it "should load up the tags" do
          @file.tags.should == [%w"Abc /foo class:Abc"]
        end
        
        it "should know the timestamp of when it was last updated" do
          @file.last_updated.to_s.should == @last_updated.to_s
        end
      end
    end
    
  end
end

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
redcar-0.9.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.9.0 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.8.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.8 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.7 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.6.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.6 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.6.1dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.6dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.5dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.4dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.3dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.2dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.5.1dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.4.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.4 plugins/declarations/spec/declarations/file_spec.rb
redcar-0.3.10.1dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.3.10.0dev plugins/declarations/spec/declarations/file_spec.rb