rake_tasks 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/rake_tasks.rb CHANGED
@@ -33,17 +33,21 @@ require 'rake/testtask'
33
33
  require 'rdoc/task'
34
34
  require 'rake/clean'
35
35
  require 'tempfile'
36
+ require 'fileutils'
36
37
 
37
38
  gem_name = File.basename(__FILE__, '.rb')
38
39
 
39
- require_relative File.join(gem_name, 'doc')
40
- require_relative File.join(gem_name, 'rdoc')
41
- require_relative File.join(gem_name, 'gem')
42
- require_relative File.join(gem_name, 'test')
40
+ # Require lib files.
41
+ Dir[File.join(File.dirname(__FILE__), gem_name, 'lib', '*.rb')].each do |lib|
42
+ require lib
43
+ end
43
44
 
44
- # Include any ruby files in the tasks folder.
45
- task_files = Dir[File.join(Dir.getwd, 'tasks', '*.rb')]
45
+ # Require tasks.
46
+ Dir[File.join(File.dirname(__FILE__), gem_name, '*.rb')].each do |task|
47
+ require task
48
+ end
46
49
 
47
- task_files.each do |rake_file|
50
+ # Include any ruby files in the tasks folder.
51
+ Dir[File.join(Dir.getwd, 'tasks', '*.rb')].each do |rake_file|
48
52
  require rake_file
49
53
  end
File without changes
File without changes
File without changes
data/rake_tasks.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rake_tasks'
3
- s.version = '1.1.0'
3
+ s.version = '2.0.0'
4
4
 
5
5
  s.summary = 'Basic rake tasks. You know you want some.'
6
6
  s.description =%Q{
@@ -25,5 +25,7 @@ mmmm yummy
25
25
  s.add_dependency 'rdoc', '~> 3.9.4'
26
26
  s.add_dependency 'rake', '~> 0.9.2'
27
27
 
28
+ s.add_development_dependency 'mocha', '~> 0.10.0'
29
+
28
30
  s.has_rdoc = true
29
31
  end
@@ -0,0 +1,79 @@
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ require_relative File.join('../require.rb'.split('/'))
32
+
33
+ class DocIntegrationTest < Test::Unit::TestCase
34
+ def setup
35
+ @class = RakeTasks::Doc
36
+ @gem = RakeTasks::Gem
37
+ @gem_spec = @gem.gem_spec
38
+ @title = @gem.gem_title
39
+ @obj = @class.new
40
+ end
41
+
42
+ def test_readme_basic_contents
43
+ [
44
+ @title,
45
+ 'Getting Started',
46
+ 'Usage',
47
+ 'Additional Notes',
48
+ 'Additional Documentation',
49
+ "gem install #{@gem_spec.name}",
50
+ "gem '#{@gem_spec.name}', '~> #{@gem_spec.version}'",
51
+ "require '#{@gem_spec.name}'",
52
+ "rake rdoc:app",
53
+ "the {#{@gem_spec.license} license}" +
54
+ "[link:../../license/#{@gem_spec.license.downcase}].\n\n" +
55
+ "link:../../license/#{@gem_spec.license.downcase}.png",
56
+ ].each do |text|
57
+ assert_contains readme, text
58
+ end
59
+ end
60
+
61
+ def test_actual_readme_contents
62
+ contents = File.open('README', 'r')
63
+ assert_contains contents.read,
64
+ "gem '#{@gem_spec.name}', '~> #{@gem_spec.version}'"
65
+ end
66
+
67
+ ############################################################################
68
+ private
69
+ ############################################################################
70
+
71
+ def assert_contains(text, snippet)
72
+ assert text.include?(snippet),
73
+ "The specified text does not contain '#{snippet}'."
74
+ end
75
+
76
+ def readme
77
+ @readme ||= @obj.readme_contents
78
+ end
79
+ end
@@ -0,0 +1,74 @@
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ require_relative File.join('../require.rb'.split('/'))
32
+
33
+ class GemIntegrationTest < Test::Unit::TestCase
34
+ def setup
35
+ @class = RakeTasks::Gem
36
+ @version = @class.gem_spec.version
37
+ end
38
+
39
+ def teardown
40
+ if @version != @class.gem_spec.version
41
+ @class.version! @version.to_s
42
+ end
43
+ end
44
+
45
+ def test_gem_title
46
+ assert_equal 'RakeTasks', @class.gem_title
47
+ end
48
+
49
+ def test_load_gem_spec
50
+ assert_kind_of Gem::Specification, @class.gem_spec
51
+ end
52
+
53
+ def test_gem_spec_file
54
+ assert_equal File.basename(Dir.getwd) + '.gemspec', @class.gem_spec_file
55
+ end
56
+
57
+ def test_gem_file_exists
58
+ assert @class.gem_file?, "#{@class.gem_spec_file} does not exist."
59
+ end
60
+
61
+ def test_set_version
62
+ old_spec = @class.gem_spec
63
+ @class.version! '0.0.0'
64
+ new_spec = @class.gem_spec
65
+
66
+ assert_not_equal old_spec.version, new_spec.version
67
+ assert_equal '0.0.0', new_spec.version.to_s
68
+ end
69
+
70
+ def test_version
71
+ spec = @class.gem_spec
72
+ assert_equal "#{spec.name} version #{spec.version}", @class.version
73
+ end
74
+ end
@@ -0,0 +1,79 @@
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ require_relative File.join('../require'.split('/'))
32
+
33
+ class TestsIntegrationTest < Test::Unit::TestCase
34
+ def setup
35
+ @class = RakeTasks::Tests
36
+ @file_path = 'test'
37
+ end
38
+
39
+ def test_tests_exist
40
+ assert_equal true, @class.exist?
41
+ end
42
+
43
+ def test_types
44
+ types = @class.types
45
+
46
+ assert_equal 2, types.count
47
+
48
+ ['integration', 'unit'].each do |type|
49
+ assert types.include?(type), "Test types do not include #{type} tests."
50
+ end
51
+ end
52
+
53
+ def test_file_list
54
+ file = File.join(@file_path, 'integration', File.basename(__FILE__))
55
+
56
+ assert @class.file_list.include?(file),
57
+ "#{file} is not in the list of test files:\n" +
58
+ @class.file_list.join("\n")
59
+
60
+ check_file_list :unit
61
+ check_file_list :integration
62
+ end
63
+
64
+ ############################################################################
65
+ private
66
+ ############################################################################
67
+
68
+ def check_file_list(group)
69
+ files = Dir[File.join(@file_path, group.to_s, '*.rb')]
70
+
71
+ assert_equal files.count, @class.file_list(group).count
72
+
73
+ files.each do |file|
74
+ assert @class.file_list(group).include?(file),
75
+ "#{file} is not in the list of test files:\n" +
76
+ @class.file_list(group).join("\n")
77
+ end
78
+ end
79
+ end
data/test/require.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'test/unit'
2
+
3
+ Bundler.require :test
4
+
5
+ require_relative File.join('../lib/rake_tasks'.split('/'))
@@ -0,0 +1,145 @@
1
+ #--
2
+ ################################################################################
3
+ # Copyright (C) 2011 Travis Herrick #
4
+ ################################################################################
5
+ # #
6
+ # \v^V,^!v\^/ #
7
+ # ~% %~ #
8
+ # { _ _ } #
9
+ # ( * - ) #
10
+ # | / | #
11
+ # \ _, / #
12
+ # \__.__/ #
13
+ # #
14
+ ################################################################################
15
+ # This program is free software: you can redistribute it #
16
+ # and/or modify it under the terms of the GNU Lesser General Public License #
17
+ # as published by the Free Software Foundation, #
18
+ # either version 3 of the License, or (at your option) any later version. #
19
+ ################################################################################
20
+ # This program is distributed in the hope that it will be useful, #
21
+ # but WITHOUT ANY WARRANTY; #
22
+ # without even the implied warranty of MERCHANTABILITY #
23
+ # or FITNESS FOR A PARTICULAR PURPOSE. #
24
+ # See the GNU Lesser General Public License for more details. #
25
+ # #
26
+ # You should have received a copy of the GNU Lesser General Public License #
27
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
28
+ ################################################################################
29
+ #++
30
+
31
+ require_relative File.join('../require'.split('/'))
32
+
33
+ class DocUnitTest < Test::Unit::TestCase
34
+ def setup
35
+ @class = RakeTasks::Doc
36
+ @gem = RakeTasks::Gem
37
+ @spec_class = Gem::Specification
38
+ stubs :gem_spec
39
+ stubs :file?
40
+ @spec = @gem.gem_spec
41
+ @obj = @class.new(@gem)
42
+ @readme = nil
43
+ end
44
+
45
+ def test_readme_basic_contents
46
+ expectations :file_list
47
+ [
48
+ spec[:title],
49
+ 'Getting Started',
50
+ 'Usage',
51
+ 'Additional Notes',
52
+ 'Additional Documentation',
53
+ "gem install #{spec[:name]}",
54
+ "gem '#{spec[:name]}', '~> #{spec[:version]}'",
55
+ "require '#{spec[:name]}'",
56
+ "rake rdoc:app",
57
+ "the {#{spec[:license]} license}[link:../../license/MiT].\n\n" +
58
+ "link:../../license/MiT.png",
59
+ ].each do |text|
60
+ assert_contains readme, text
61
+ end
62
+ end
63
+
64
+ def test_no_license_information
65
+ @spec.expects(:licenses).with.returns([]).at_least_once
66
+ assert_not_contains readme, ' license.'
67
+ end
68
+
69
+ def test_readme_license_no_files_match
70
+ Dir.expects(:[] => ['license/file3', 'license/file4'])
71
+ Dir.expects(:[] => ['license/file1.jpg', 'license/file2.png'])
72
+
73
+ assert_contains readme, "the #{spec[:license]} license."
74
+ end
75
+
76
+ def test_readme_license_with_license_but_no_images
77
+ Dir.expects(:[] => ['license/file1', 'license/MiT'])
78
+ Dir.expects(:[] => [])
79
+
80
+ assert_contains readme, "the {#{spec[:license]} license}" +
81
+ "[link:../../license/MiT]."
82
+ end
83
+
84
+ def test_readme_license_with_images_but_no_license
85
+ Dir.expects(:[] => [])
86
+ Dir.expects(:[] => ['license/file1.jpg', 'license/mIt.png'])
87
+
88
+ assert_contains readme, "the #{spec[:license]} license.\n\n" +
89
+ "link:../../license/mIt.png"
90
+ end
91
+
92
+
93
+ ############################################################################
94
+ private
95
+ ############################################################################
96
+
97
+ def expectations(key)
98
+ case key
99
+ when :file_list then
100
+ Dir.expects(:[]).returns(['license/file1', 'license/MiT'])
101
+ Dir.expects(:[]).returns(['license/file1.jpg', 'license/MiT.png'])
102
+ end
103
+ end
104
+
105
+ def stubs(item)
106
+ case item
107
+ when :file? then File.stubs(:file? => true)
108
+ when :spec
109
+ gem_spec = mock.responds_like(@spec_class.new)
110
+ gem_spec.stubs spec
111
+ return gem_spec
112
+ when :gem_spec
113
+ @gem.stubs(:gem_spec => stubs(:spec))
114
+ end
115
+ end
116
+
117
+ def assert_not_contains(text, snippet)
118
+ assert !text.include?(snippet),
119
+ "The specified text should not contain '#{snippet}'."
120
+ end
121
+
122
+ def assert_contains(text, snippet)
123
+ assert text.include?(snippet),
124
+ "The specified text does not contain '#{snippet}'."
125
+ end
126
+
127
+ def readme
128
+ @readme ||= @obj.readme_contents
129
+ end
130
+
131
+ def spec
132
+ {
133
+ :name => 'test_gem',
134
+ :title => 'TestGem',
135
+ :version => '0.0.1',
136
+ :licenses => ['MIT', 'GPL'],
137
+ :license => 'MIT',
138
+ :description =>
139
+ %Q{
140
+ A long explanation of what this thing can do.
141
+ Yeah, it's cool.
142
+ }.strip,
143
+ }
144
+ end
145
+ end