Sha256: 0c786f356a6f461fce1e934a28a1face73d3c9b6acd951e908c19de946c251f2

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

require 'version_info/test_file'

describe "VersionInfo" do
  before :each do
    module TestFile
      include VersionInfo # force new VERSION data
    end
  end

  it "is initalized" do
    TestFile::VERSION.marshal_dump.should == {:major => 0, :minor => 0, :patch => 0 }
  end

  it "has default filename" do
    TestFile::VERSION.file_name.should == 'version_info.yml'
  end

  it "can assign filename" do
    TestFile::VERSION.file_name = 'test_file.vinfo'
    TestFile::VERSION.file_name.should == 'test_file.vinfo'
  end

  it "has a minor property" do
    TestFile::VERSION.minor.should == 0
  end

  it "has a tag property" do
    TestFile::VERSION.tag.should == '0.0.0'    
  end

  it "can bump a segment" do
    TestFile::VERSION.bump(:patch)
    TestFile::VERSION.tag.should == '0.0.1'    
  end

  it "bump a segment reset sublevels " do
    TestFile::VERSION.bump(:patch)
    TestFile::VERSION.bump(:minor)
    TestFile::VERSION.tag.should == '0.1.0'   
  end

  it "can save " do
    io = StringIO.new
    File.stub!(:open).and_yield(io)
    TestFile::VERSION.bump(:minor)
    TestFile::VERSION.save
    io.string.should == "--- \nmajor: 0\nminor: 1\npatch: 0\n"
  end

  it "can save custom data " do
    io = StringIO.new
    File.stub!(:open).and_yield(io)
    TestFile::VERSION.bump(:minor)
    TestFile::VERSION.author = 'jcangas'
    TestFile::VERSION.save
    io.string.should == "--- \nmajor: 0\nminor: 1\npatch: 0\nauthor: jcangas\n"
  end

  it "can load " do
    io = StringIO.new("--- \nmajor: 1\nminor: 2\npatch: 3\n")
    File.should_receive(:read).and_return{io}
    TestFile::VERSION.load
    TestFile::VERSION.marshal_dump.should == {:major => 1, :minor => 2, :patch => 3 }  
  end

  it "can load custom data " do
    io = StringIO.new("--- \nmajor: 1\nminor: 2\npatch: 3\nauthor: jcangas\n")
    File.should_receive(:read).and_return{io}
    TestFile::VERSION.load
    TestFile::VERSION.marshal_dump.should == {:major => 1, :minor => 2, :patch => 3, :author => 'jcangas' }  
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
version_info-0.3.0 spec/version_info/version_info_spec.rb
version_info-0.2.0 spec/version_info/version_info_spec.rb