rake-version 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -6
- data/LICENSE.txt +1 -1
- data/README.md +83 -9
- data/VERSION +1 -1
- data/lib/rake-version.rb +1 -4
- data/lib/rake-version/config.rb +1 -2
- data/lib/rake-version/context.rb +3 -14
- data/lib/rake-version/copier.rb +4 -18
- data/lib/rake-version/manager.rb +3 -3
- data/lib/rake-version/tasks.rb +36 -7
- data/lib/rake-version/version.rb +8 -9
- metadata +11 -39
- data/.document +0 -5
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.screenrc +0 -5
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -51
- data/Rakefile +0 -58
- data/rake-version.gemspec +0 -89
- data/spec/config_spec.rb +0 -68
- data/spec/context_spec.rb +0 -48
- data/spec/copier_spec.rb +0 -185
- data/spec/helper.rb +0 -21
- data/spec/manager_spec.rb +0 -117
- data/spec/tasks_spec.rb +0 -57
- data/spec/version_spec.rb +0 -73
data/spec/helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
require 'simplecov'
|
4
|
-
|
5
|
-
# test coverage
|
6
|
-
SimpleCov.start
|
7
|
-
|
8
|
-
begin
|
9
|
-
Bundler.setup(:default, :development)
|
10
|
-
rescue Bundler::BundlerError => e
|
11
|
-
$stderr.puts e.message
|
12
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
-
exit e.status_code
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'rspec'
|
17
|
-
|
18
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
-
require 'rake-version'
|
21
|
-
|
data/spec/manager_spec.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe RakeVersion::Manager do
|
4
|
-
MANAGER_SAMPLE_ROOT = '/tmp'
|
5
|
-
MANAGER_SAMPLE_VERSION = '1.2.3.456-beta-custom'
|
6
|
-
MANAGER_VERSION_FILE = File.join MANAGER_SAMPLE_ROOT, 'VERSION'
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@manager = RakeVersion::Manager.new
|
10
|
-
|
11
|
-
@context = double('context')
|
12
|
-
@context.stub(:root){ MANAGER_SAMPLE_ROOT }
|
13
|
-
@context.stub(:read){ MANAGER_SAMPLE_VERSION }
|
14
|
-
@context.stub(:write){}
|
15
|
-
@context.stub(:kind_of?){ |type| type == RakeVersion::Context }
|
16
|
-
|
17
|
-
@version = double('version')
|
18
|
-
@version.stub(:to_s){ MANAGER_SAMPLE_VERSION }
|
19
|
-
@version.stub(:bump){ @version }
|
20
|
-
@version.stub(:kind_of?){ |type| type == RakeVersion::Version }
|
21
|
-
|
22
|
-
@copier = double('copier', :copy => nil)
|
23
|
-
@config = double('config', :copiers => [ @copier ])
|
24
|
-
end
|
25
|
-
|
26
|
-
def with_context &block
|
27
|
-
@manager.with_context @context do |m|
|
28
|
-
yield m if block_given?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return a version object" do
|
33
|
-
with_context do |m|
|
34
|
-
m.version.tap do |v|
|
35
|
-
v.should be_a_kind_of(RakeVersion::Version)
|
36
|
-
v.major.should == 1
|
37
|
-
v.minor.should == 2
|
38
|
-
v.patch.should == 3
|
39
|
-
v.build.should == 456
|
40
|
-
v.tags.should be_a_kind_of(Array)
|
41
|
-
v.tags.length.should == 2
|
42
|
-
v.tags[0].should == 'beta'
|
43
|
-
v.tags[1].should == 'custom'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should require a context for all operations" do
|
49
|
-
lambda{ @manager.version }.should raise_error(RakeVersion::MissingContext)
|
50
|
-
lambda{ @manager.set '1.2.3' }.should raise_error(RakeVersion::MissingContext)
|
51
|
-
lambda{ @manager.bump :minor }.should raise_error(RakeVersion::MissingContext)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should return the correct version" do
|
55
|
-
with_context{ |m| m.version.to_s.should == MANAGER_SAMPLE_VERSION }
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should set the correct version" do
|
59
|
-
with_context{ |m| m.set('1.2.3').to_s.should == '1.2.3' }
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should ask for the context root" do
|
63
|
-
@context.should_receive :root
|
64
|
-
with_context{ |m| m.version }
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should ask the version to bump itself" do
|
68
|
-
@manager.stub(:version){ @version }
|
69
|
-
[ :major, :minor, :patch ].each do |type|
|
70
|
-
@version.should_receive(:bump).with(type)
|
71
|
-
with_context{ |m| m.bump type }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should ask the context to read the version file" do
|
76
|
-
@context.should_receive(:read).with(MANAGER_VERSION_FILE)
|
77
|
-
with_context{ |m| m.version }
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should ask the context to write the version file when bumping the version" do
|
81
|
-
@context.should_receive(:write).with(MANAGER_VERSION_FILE, '1.3.0.456-beta-custom')
|
82
|
-
with_context{ |m| m.bump :minor }
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should ask the context to write the version file when setting the version" do
|
86
|
-
@context.should_receive(:write).with(MANAGER_VERSION_FILE, MANAGER_SAMPLE_VERSION)
|
87
|
-
with_context{ |m| m.set MANAGER_SAMPLE_VERSION }
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should only accept the right type of context" do
|
91
|
-
[ nil, true, false, 2, 'bad', :bad, [], {}, @version ].each do |invalid|
|
92
|
-
lambda{ @manager.with_context invalid }.should raise_error(RakeVersion::BadContext)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'Copying' do
|
97
|
-
|
98
|
-
it "should ask the given config for its copiers" do
|
99
|
-
@config.should_receive :copiers
|
100
|
-
with_context{ |m| m.config = @config }
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should ask given copiers to copy the version to sources when setting the version" do
|
104
|
-
@manager.config = @config
|
105
|
-
@copier.should_receive(:copy).with(kind_of(RakeVersion::Version), @context)
|
106
|
-
with_context{ |m| m.set '1.2.3' }
|
107
|
-
end
|
108
|
-
|
109
|
-
[ :major, :minor, :patch ].each do |type|
|
110
|
-
it "should ask given copiers to copy the version to sources when bumping the #{type} version" do
|
111
|
-
@manager.config = @config
|
112
|
-
@copier.should_receive(:copy).with(kind_of(RakeVersion::Version), @context)
|
113
|
-
with_context{ |m| m.bump type }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
data/spec/tasks_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'active_support/core_ext/kernel/reporting'
|
3
|
-
|
4
|
-
describe RakeVersion::Tasks do
|
5
|
-
TASKS_SAMPLE_VERSION = '1.2.3'
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
|
9
|
-
@version = double('version')
|
10
|
-
@version.stub(:to_s){ TASKS_SAMPLE_VERSION }
|
11
|
-
|
12
|
-
@manager = double('manager')
|
13
|
-
@manager.stub(:version){ @version }
|
14
|
-
@manager.stub(:set){ @version }
|
15
|
-
@manager.stub(:bump){ @version }
|
16
|
-
@manager.stub(:with_context).and_yield(@manager)
|
17
|
-
@manager.stub(:config=)
|
18
|
-
|
19
|
-
RakeVersion::Manager.stub(:new){ @manager }
|
20
|
-
RakeVersion::Tasks.new
|
21
|
-
end
|
22
|
-
|
23
|
-
after :each do
|
24
|
-
Rake::Task.clear
|
25
|
-
end
|
26
|
-
|
27
|
-
def silence &block
|
28
|
-
silence_stream(STDOUT) do
|
29
|
-
silence_stream(STDERR) do
|
30
|
-
yield if block_given?
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should define all tasks" do
|
36
|
-
%w( version version:set version:bump:major version:bump:minor version:bump:patch ).each do |name|
|
37
|
-
Rake::Task[name].should be_a_kind_of(Rake::Task)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should ask the manager to return the current version" do
|
42
|
-
@manager.should_receive(:version)
|
43
|
-
silence{ Rake::Task['version'].execute }
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should ask the manager to set the version" do
|
47
|
-
@manager.should_receive(:set).with(kind_of(String))
|
48
|
-
silence{ Rake::Task['version:set'].invoke TASKS_SAMPLE_VERSION }
|
49
|
-
end
|
50
|
-
|
51
|
-
[ :major, :minor, :patch ].each do |type|
|
52
|
-
it "should ask the manager to bump the #{type} version" do
|
53
|
-
@manager.should_receive(:bump).with(type)
|
54
|
-
silence{ Rake::Task["version:bump:#{type}"].execute }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/spec/version_spec.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe RakeVersion::Version do
|
4
|
-
|
5
|
-
it "should build a correct version object when initialized" do
|
6
|
-
RakeVersion::Version.new.tap do |v|
|
7
|
-
v.major.should == 0
|
8
|
-
v.minor.should == 0
|
9
|
-
v.patch.should == 0
|
10
|
-
v.build.should be_nil
|
11
|
-
v.tags.should be_a_kind_of(Array)
|
12
|
-
v.tags.length.should == 0
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should build a correct version object when built from a string" do
|
17
|
-
RakeVersion::Version.new.from_s('1.2.3.456-beta-custom').tap do |v|
|
18
|
-
v.major.should == 1
|
19
|
-
v.minor.should == 2
|
20
|
-
v.patch.should == 3
|
21
|
-
v.build.should == 456
|
22
|
-
v.tags.should be_a_kind_of(Array)
|
23
|
-
v.tags.length.should == 2
|
24
|
-
v.tags[0].should == 'beta'
|
25
|
-
v.tags[1].should == 'custom'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should build the correct version string when built from a string" do
|
30
|
-
[ '1.2.3', '2.3.4.567', '3.4.5.678-beta', '5.6.7.890-beta-custom' ].each do |v|
|
31
|
-
RakeVersion::Version.new.from_s(v).to_s.should == v
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should raise an error when built from invalid version strings" do
|
36
|
-
[ '1', '2.3', '4.5.6.7.8', 'asd', nil, true, false, [], {}, '' ].each do |invalid|
|
37
|
-
lambda{ RakeVersion::Version.new.from_s invalid }.should raise_error(RakeVersion::BadVersionString)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'Bumping' do
|
42
|
-
|
43
|
-
before :each do
|
44
|
-
@version1 = RakeVersion::Version.new.from_s '1.2.3.456-beta-custom'
|
45
|
-
@version2 = RakeVersion::Version.new.from_s '2.3.4.567-alpha-customer'
|
46
|
-
@version3 = RakeVersion::Version.new.from_s '3.4.5.678-gamma-prod'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should correctly bump the major version" do
|
50
|
-
@version1.bump(:major).to_s.should == '2.0.0.456-beta-custom'
|
51
|
-
@version2.bump(:major).to_s.should == '3.0.0.567-alpha-customer'
|
52
|
-
@version3.bump(:major).to_s.should == '4.0.0.678-gamma-prod'
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should correctly bump the minor version" do
|
56
|
-
@version1.bump(:minor).to_s.should == '1.3.0.456-beta-custom'
|
57
|
-
@version2.bump(:minor).to_s.should == '2.4.0.567-alpha-customer'
|
58
|
-
@version3.bump(:minor).to_s.should == '3.5.0.678-gamma-prod'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should correctly bump the patch version" do
|
62
|
-
@version1.bump(:patch).to_s.should == '1.2.4.456-beta-custom'
|
63
|
-
@version2.bump(:patch).to_s.should == '2.3.5.567-alpha-customer'
|
64
|
-
@version3.bump(:patch).to_s.should == '3.4.6.678-gamma-prod'
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should not accept unknown bump types" do
|
68
|
-
[ nil, true, false, '', 'asd', :build, :unknown, :Major, [], {} ].each do |invalid|
|
69
|
-
lambda{ @version1.bump invalid }.should raise_error(RakeVersion::BadBumpType)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|