mactag 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DslTest < ActiveSupport::TestCase
4
- setup do
5
- @builder = Mactag::Builder.new
6
- @dsl = Mactag::Dsl.new(@builder)
7
- end
8
-
9
- context 'app' do
10
- should 'be able to handle single argument' do
11
- @dsl.app('lib/**/*.rb')
12
- end
13
- end
14
-
15
- context 'plugin' do
16
- should 'be able to handle no arguments' do
17
- @dsl.plugin
18
- end
19
-
20
- should 'be able to handle single argument' do
21
- @dsl.plugin('devise')
22
- end
23
-
24
- should 'be able to handle multiple arguments' do
25
- @dsl.plugins('devise', 'rack')
26
- end
27
- end
28
-
29
- context 'gem' do
30
- should 'be able to handle no arguments' do
31
- @dsl.gem
32
- end
33
-
34
- context 'single argument' do
35
- should 'be able to handle version' do
36
- @dsl.gem('devise', :version => '1.1.1')
37
- end
38
-
39
- should 'be able to handle no version' do
40
- @dsl.gem('devise')
41
- end
42
- end
43
-
44
- should 'be able to handle multiple arguments' do
45
- @dsl.gem('devise', 'rack')
46
- end
47
- end
48
-
49
- context 'rails' do
50
- should 'be able to handle no arguments' do
51
- @dsl.rails
52
- end
53
-
54
- should 'be able to handle only' do
55
- @dsl.rails(:only => [])
56
- end
57
-
58
- should 'be able to handle except' do
59
- @dsl.rails(:except => [])
60
- end
61
-
62
- should 'be able to handle version' do
63
- @dsl.rails(:version => '3.0.0.rc')
64
- end
65
- end
66
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AppTest < ActiveSupport::TestCase
4
- context 'application tag' do
5
- setup do
6
- @tag = 'app/**/*.rb'
7
- @app = Mactag::Tag::App.new(@tag)
8
- end
9
-
10
- should 'return the same file as array' do
11
- assert_equal @tag, @app.tag
12
- end
13
- end
14
- end
@@ -1,108 +0,0 @@
1
- require 'test_helper'
2
-
3
- class GemTest < ActiveSupport::TestCase
4
- setup do
5
- Mactag::Config.stubs(:gem_home).returns('GEM_HOME')
6
- end
7
-
8
- context '#tag' do
9
- context 'for existing gem' do
10
- context 'with no specified version' do
11
- setup do
12
- Mactag::Tag::Gem.stubs(:most_recent).returns('devise-1.1.1')
13
-
14
- @gem = Mactag::Tag::Gem.new('devise')
15
- @gem.stubs(:exists?).returns(true)
16
- end
17
-
18
- should 'return correct tag' do
19
- assert_equal 'GEM_HOME/devise-1.1.1/lib/**/*.rb', @gem.tag
20
- end
21
- end
22
-
23
- context 'with specified version' do
24
- setup do
25
- @gem = Mactag::Tag::Gem.new('devise', '1.1.1')
26
- @gem.stubs(:exists?).returns(true)
27
- end
28
-
29
- should 'return correct tag' do
30
- assert_equal 'GEM_HOME/devise-1.1.1/lib/**/*.rb', @gem.tag
31
- end
32
- end
33
- end
34
-
35
- should 'return nil when gem does not exist' do
36
- @gem = Mactag::Tag::Gem.new('devise')
37
- @gem.stubs(:exists?).returns(false)
38
-
39
- assert_nil @gem.tag
40
- end
41
- end
42
-
43
- context '#most_recent' do
44
- should 'return most recent gem if more than one version of same gem exists' do
45
- Dir.stubs(:glob).returns(['vendor/plugins/devise-1.1.1', 'vendor/plugins/devise-1.1.0'])
46
-
47
- assert_equal 'devise-1.1.1', Mactag::Tag::Gem.most_recent('devise')
48
- end
49
-
50
- should 'return only gem if only one version of same gem exists' do
51
- Dir.stubs(:glob).returns(['vendor/plugins/devise-1.1.1'])
52
-
53
- assert_equal 'devise-1.1.1', Mactag::Tag::Gem.most_recent('devise')
54
- end
55
-
56
- should 'return nil if no version of gem' do
57
- Dir.stubs(:glob).returns([])
58
-
59
- assert_nil Mactag::Tag::Gem.most_recent('devise')
60
- end
61
- end
62
-
63
- context '#exists' do
64
- context 'with specified version' do
65
- setup do
66
- @gem = Mactag::Tag::Gem.new('devise', '1.1.1')
67
- end
68
-
69
- should 'return true when gem exists' do
70
- File.stubs(:directory?).returns(true)
71
-
72
- assert @gem.send(:exists?)
73
- end
74
-
75
- should 'return false when gem does not exist' do
76
- File.stubs(:directory?).returns(false)
77
-
78
- assert !@gem.send(:exists?)
79
- end
80
- end
81
-
82
- context 'with no specified version' do
83
- setup do
84
- @gem = Mactag::Tag::Gem.new('devise')
85
- end
86
-
87
- should 'return true when gem exists' do
88
- Mactag::Tag::Gem.stubs(:most_recent).returns('devise-1.1.1')
89
-
90
- assert @gem.send(:exists?)
91
- end
92
-
93
- should 'return false when gem does not exist' do
94
- Mactag::Tag::Gem.stubs(:most_recent).returns(nil)
95
-
96
- assert !@gem.send(:exists?)
97
- end
98
- end
99
- end
100
-
101
- context '#splash' do
102
- should 'return gem name, dash, version' do
103
- @gem = Mactag::Tag::Gem.new('devise', '1.1.1')
104
-
105
- assert_equal 'devise-1.1.1', @gem.send(:splash)
106
- end
107
- end
108
- end
@@ -1,57 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PluginTest < ActiveSupport::TestCase
4
- should 'have correct plugin path' do
5
- assert_equal 'vendor/plugins', Mactag::Tag::Plugin::PLUGIN_PATH
6
- end
7
-
8
- context '#tag' do
9
- setup do
10
- @plugin = Mactag::Tag::Plugin.new('devise')
11
- end
12
-
13
- should 'return correct tag when plugin exists' do
14
- @plugin.stubs(:exists?).returns(true)
15
-
16
- assert_equal 'vendor/plugins/devise/lib/**/*.rb', @plugin.tag
17
- end
18
-
19
- should 'return nil when plugin does not exist' do
20
- @plugin.stubs(:exists?).returns(false)
21
-
22
- assert_nil @plugin.tag
23
- end
24
- end
25
-
26
- context '#exists' do
27
- setup do
28
- @plugin = Mactag::Tag::Plugin.new('devise')
29
- end
30
-
31
- should 'return true when plugin exists' do
32
- File.stubs(:directory?).returns(true)
33
-
34
- assert @plugin.send(:exists?)
35
- end
36
-
37
- should 'return false when plugin does not exist' do
38
- File.stubs(:directory?).returns(false)
39
-
40
- assert !@plugin.send(:exists?)
41
- end
42
- end
43
-
44
- context '#all' do
45
- should 'return plugins when they exists' do
46
- Dir.stubs(:glob).returns(['plugin/one', 'plugin/two'])
47
-
48
- assert_same_elements Mactag::Tag::Plugin.all, ['one', 'two']
49
- end
50
-
51
- should 'return an empty array when no plugins exist' do
52
- Dir.stubs(:glob).returns([])
53
-
54
- assert_same_elements Mactag::Tag::Plugin.all, []
55
- end
56
- end
57
- end
@@ -1,105 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RailsTest < ActiveSupport::TestCase
4
- should "have correct packages" do
5
- packages = Mactag::Tag::Rails::PACKAGES
6
-
7
- [
8
- :actionmailer,
9
- :actionpack,
10
- :activemodel,
11
- :activerecord,
12
- :activeresource,
13
- :railties,
14
- :activesupport
15
- ].each do |package|
16
- assert_contains packages, package
17
- end
18
- end
19
-
20
- context '#tag' do
21
- should 'return empty array if no packages' do
22
- @rails = Mactag::Tag::Rails.new({})
23
- @rails.stubs(:packages).returns([])
24
-
25
- assert_equal [], @rails.tag
26
- end
27
-
28
- should 'return array with gem tags if packages' do
29
- @rails = Mactag::Tag::Rails.new({})
30
- @rails.stubs(:packages).returns([:activemodel, :activerecord])
31
-
32
- o = Object.new
33
- def o.tag
34
- 'tag'
35
- end
36
-
37
- Mactag::Tag::Gem.stubs(:new).returns(o)
38
-
39
- assert_equal ['tag', 'tag'], @rails.tag
40
- end
41
- end
42
-
43
- context '#packages' do
44
- should 'return all packages if no arguments' do
45
- @rails = Mactag::Tag::Rails.new({})
46
-
47
- assert_same_elements Mactag::Tag::Rails::PACKAGES, @rails.send(:packages)
48
- end
49
-
50
- should 'return some packages if only specified' do
51
- @rails = Mactag::Tag::Rails.new(:only => [:active_support, :activerecord])
52
-
53
- assert_same_elements [:activesupport, :activerecord], @rails.send(:packages)
54
- end
55
-
56
- should 'return some packages if except specified' do
57
-
58
- @rails = Mactag::Tag::Rails.new(:except => [:active_support, :activerecord])
59
-
60
- assert_same_elements Mactag::Tag::Rails::PACKAGES - [:activesupport, :activerecord], @rails.send(:packages)
61
- end
62
- end
63
-
64
- context '#packagize' do
65
- setup do
66
- @rails = Mactag::Tag::Rails.new({})
67
- end
68
-
69
- context 'single package' do
70
- setup do
71
- @packagized = @rails.send(:packagize!, 'active_record')
72
- end
73
-
74
- should 'return a packagized package' do
75
- assert_equal [:activerecord], @packagized
76
- end
77
- end
78
-
79
- context 'multiple packages' do
80
- setup do
81
- @packagized = @rails.send(:packagize!, ['_active_support_', :action_view])
82
- end
83
-
84
- should 'return packagized packages' do
85
- assert_equal [:activesupport, :actionview], @packagized
86
- end
87
- end
88
- end
89
-
90
- context '#version' do
91
- should 'pick specified version if given' do
92
- @rails = Mactag::Tag::Rails.new({ :version => '3.0.0.rc' })
93
-
94
- assert_equal '3.0.0.rc', @rails.send(:version)
95
- end
96
-
97
- should 'pick same rails version as application if not specified version' do
98
- Rails.stubs(:version).returns('3.0.0.beta3')
99
-
100
- @rails = Mactag::Tag::Rails.new({})
101
-
102
- assert_equal '3.0.0.beta3', @rails.send(:version)
103
- end
104
- end
105
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MactagTest < ActiveSupport::TestCase
4
- end