Sha256: 80e652ef15f40e34b117d7f68bdf7fdd5aa776b96faa3136833dae0c54d4a054

Contents?: true

Size: 1.53 KB

Versions: 19

Compression:

Stored size: 1.53 KB

Contents

require "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

19 entries across 19 versions & 2 rubygems

Version Path
redcar-0.13 plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.5dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.4dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.3dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.2dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.1dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.12.1 plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.13.0dev plugins/declarations/spec/declarations/file_spec.rb
redcar-0.12 plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.27dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.26dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.25dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.24dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.23dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.22dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.21dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.20dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.19dev plugins/declarations/spec/declarations/file_spec.rb
redcar-dev-0.12.18dev plugins/declarations/spec/declarations/file_spec.rb