mactag 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag::Tag::Plugin do
4
+ it 'should have correct plugin path' do
5
+ Mactag::Tag::Plugin::PLUGIN_PATH.should == 'vendor/plugins'
6
+ end
7
+
8
+ describe '#tag' do
9
+ before do
10
+ @plugin = Mactag::Tag::Plugin.new('devise')
11
+ end
12
+
13
+ it 'should return tag when plugin exist' do
14
+ @plugin.stub!(:exists?).and_return(true)
15
+
16
+ @plugin.tag.should == 'vendor/plugins/devise/lib/**/*.rb'
17
+ end
18
+
19
+ it 'should return nil when plugin does not exist' do
20
+ @plugin.stub!(:exists?).and_return(false)
21
+
22
+ @plugin.tag.should be_nil
23
+ end
24
+ end
25
+
26
+ describe '#exists' do
27
+ before do
28
+ @plugin = Mactag::Tag::Plugin.new('devise')
29
+ end
30
+
31
+ it 'should be true when plugin exist' do
32
+ File.stub!(:directory?).and_return(true)
33
+
34
+ @plugin.send(:exists?).should be_true
35
+ end
36
+
37
+ it 'should be false when plugin does not exist' do
38
+ File.stub!(:directory?).and_return(false)
39
+
40
+ @plugin.send(:exists?).should be_false
41
+ end
42
+ end
43
+
44
+ describe '#all' do
45
+ it 'return plugins when they exist' do
46
+ Dir.stub!(:glob).and_return(['plugin/one', 'plugin/two'])
47
+
48
+ Mactag::Tag::Plugin.all.should =~ ['one', 'two']
49
+ end
50
+
51
+ it 'return empty array when no plugins exist' do
52
+ Dir.stub!(:glob).and_return([])
53
+
54
+ Mactag::Tag::Plugin.all.should be_empty
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag::Tag::Rails do
4
+ it 'should have correct packages' do
5
+ Mactag::Tag::Rails::PACKAGES.should =~ [:actionmailer, :actionpack, :activemodel, :activerecord, :activeresource, :railties, :activesupport]
6
+ end
7
+
8
+ describe '#tag' do
9
+ before do
10
+ @rails = Mactag::Tag::Rails.new({})
11
+ end
12
+
13
+ it 'return empty array if no packages' do
14
+ @rails.stub!(:packages).and_return([])
15
+
16
+ @rails.tag.should be_empty
17
+ end
18
+
19
+ it 'should return array with gem tags when packages' do
20
+ @rails.stub!(:packages).and_return([:activemodel, :activerecord])
21
+
22
+ o = Object.new
23
+ def o.tag
24
+ 'tag'
25
+ end
26
+
27
+ Mactag::Tag::Gem.stub!(:new).and_return(o)
28
+
29
+ @rails.tag.should =~ ['tag', 'tag']
30
+ end
31
+ end
32
+
33
+ describe '#packages' do
34
+ it 'should return all packages when no arguments' do
35
+ @rails = Mactag::Tag::Rails.new({})
36
+
37
+ @rails.send(:packages).should =~ Mactag::Tag::Rails::PACKAGES
38
+ end
39
+
40
+ it 'should return some packages when only specified' do
41
+ @rails = Mactag::Tag::Rails.new(:only => [:active_support, :activerecord])
42
+
43
+ @rails.send(:packages).should =~ [:activesupport, :activerecord]
44
+ end
45
+
46
+ it 'return some packages when except specified' do
47
+ @rails = Mactag::Tag::Rails.new(:except => [:active_support, :activerecord])
48
+
49
+ @rails.send(:packages).should =~ (Mactag::Tag::Rails::PACKAGES - [:activesupport, :activerecord])
50
+ end
51
+ end
52
+
53
+ describe '#packagize' do
54
+ before do
55
+ @rails = Mactag::Tag::Rails.new({})
56
+ end
57
+
58
+ context 'single package' do
59
+ before do
60
+ @packagized = @rails.send(:packagize!, 'active_record')
61
+ end
62
+
63
+ it 'should return package packagized' do
64
+ @packagized.should =~ [:activerecord]
65
+ end
66
+ end
67
+
68
+ context 'multiple packages' do
69
+ before do
70
+ @packagized = @rails.send(:packagize!, ['_active_support_', :action_view])
71
+ end
72
+
73
+ it 'should return packages packagized' do
74
+ @packagized.should =~ [:activesupport, :actionview]
75
+ end
76
+ end
77
+ end
78
+
79
+ describe '#version' do
80
+ it 'should pick specified version when given' do
81
+ @rails = Mactag::Tag::Rails.new({ :version => '3.0.0.rc' })
82
+
83
+ @rails.send(:version).should == '3.0.0.rc'
84
+ end
85
+
86
+ it 'pick same rails version as application when not specified version' do
87
+ Rails.stub!(:version).and_return('3.0.0.beta3')
88
+
89
+ @rails = Mactag::Tag::Rails.new({})
90
+
91
+ @rails.send(:version).should == '3.0.0.beta3'
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag::TagsFile do
4
+ before do
5
+ File.stub!(:join).and_return('_path_to.file.rb')
6
+
7
+ @tags_file = Mactag::TagsFile.new('file')
8
+ end
9
+
10
+ describe '#delete' do
11
+ it 'should delete output file' do
12
+ File.should_receive(:delete).with(@tags_file.instance_variable_get('@output'))
13
+
14
+ @tags_file.delete
15
+ end
16
+ end
17
+
18
+ describe 'exists?' do
19
+ it 'should exist when file exists' do
20
+ File.stub!(:exists?).and_return(true)
21
+
22
+ @tags_file.exist?.should be_true
23
+ end
24
+
25
+ it 'should not exist when file does not exist' do
26
+ File.stub!(:exists?).and_return(false)
27
+
28
+ @tags_file.exist?.should be_false
29
+ end
30
+ end
31
+
32
+ describe '#output' do
33
+ it 'return correct output file' do
34
+ File.stub!(:join).and_return { |*args| args.last }
35
+
36
+ @tags_file.send(:output, '/path/to/file.rb').should == '_path_to_file'
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mactag do
4
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mactag
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 15
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 3
8
- - 3
9
- version: 0.3.3
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Johan Andersson
@@ -14,39 +15,60 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-04 00:00:00 +02:00
18
+ date: 2010-10-13 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: shoulda
22
+ name: rails
23
+ prerelease: false
22
24
  requirement: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
25
- - - "="
27
+ - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: -1848230019
27
30
  segments:
28
- - 2
29
- - 11
30
- - 1
31
- version: 2.11.1
32
- type: :development
33
- prerelease: false
31
+ - 3
32
+ - 0
33
+ - 0
34
+ - beta1
35
+ version: 3.0.0.beta1
36
+ type: :runtime
34
37
  version_requirements: *id001
35
38
  - !ruby/object:Gem::Dependency
36
- name: mocha
39
+ name: bundler
40
+ prerelease: false
37
41
  requirement: &id002 !ruby/object:Gem::Requirement
38
42
  none: false
39
43
  requirements:
40
- - - "="
44
+ - - ">="
41
45
  - !ruby/object:Gem::Version
46
+ hash: 15
42
47
  segments:
43
48
  - 0
44
49
  - 9
45
- - 8
46
- version: 0.9.8
47
- type: :development
48
- prerelease: false
50
+ - 26
51
+ version: 0.9.26
52
+ type: :runtime
49
53
  version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 62196421
63
+ segments:
64
+ - 2
65
+ - 0
66
+ - 0
67
+ - beta
68
+ - 19
69
+ version: 2.0.0.beta.19
70
+ type: :development
71
+ version_requirements: *id003
50
72
  description: Mactag is DSL in ruby for creating a Ctags-file for Rails projects
51
73
  email: johan.rejeep@gmail.com
52
74
  executables: []
@@ -65,21 +87,27 @@ files:
65
87
  - lib/mactag/config.rb
66
88
  - lib/mactag/ctags.rb
67
89
  - lib/mactag/dsl.rb
90
+ - lib/mactag/event_handler.rb
68
91
  - lib/mactag/railtie.rb
92
+ - lib/mactag/server.rb
69
93
  - lib/mactag/tag.rb
70
94
  - lib/mactag/tag/app.rb
71
95
  - lib/mactag/tag/gem.rb
72
96
  - lib/mactag/tag/plugin.rb
73
97
  - lib/mactag/tag/rails.rb
98
+ - lib/mactag/tags_file.rb
74
99
  - lib/tasks/mactag.rake
75
- - test/mactag/builder_test.rb
76
- - test/mactag/config_test.rb
77
- - test/mactag/dsl_test.rb
78
- - test/mactag/tag/app_test.rb
79
- - test/mactag/tag/gem_test.rb
80
- - test/mactag/tag/plugin_test.rb
81
- - test/mactag/tag/rails_test.rb
82
- - test/mactag_test.rb
100
+ - spec/mactag/builder_spec.rb
101
+ - spec/mactag/config_spec.rb
102
+ - spec/mactag/ctags_spec.rb
103
+ - spec/mactag/dsl_spec.rb
104
+ - spec/mactag/server_spec.rb
105
+ - spec/mactag/tag/app_spec.rb
106
+ - spec/mactag/tag/gem_spec.rb
107
+ - spec/mactag/tag/plugin_spec.rb
108
+ - spec/mactag/tag/rails_spec.rb
109
+ - spec/mactag/tags_file_spec.rb
110
+ - spec/mactag_spec.rb
83
111
  has_rdoc: true
84
112
  homepage: http://github.com/rejeep/mactag
85
113
  licenses: []
@@ -94,6 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
122
  requirements:
95
123
  - - ">="
96
124
  - !ruby/object:Gem::Version
125
+ hash: 3
97
126
  segments:
98
127
  - 0
99
128
  version: "0"
@@ -102,6 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
131
  requirements:
103
132
  - - ">="
104
133
  - !ruby/object:Gem::Version
134
+ hash: 3
105
135
  segments:
106
136
  - 0
107
137
  version: "0"
@@ -113,11 +143,14 @@ signing_key:
113
143
  specification_version: 3
114
144
  summary: Ctags for Rails
115
145
  test_files:
116
- - test/mactag/builder_test.rb
117
- - test/mactag/config_test.rb
118
- - test/mactag/dsl_test.rb
119
- - test/mactag/tag/app_test.rb
120
- - test/mactag/tag/gem_test.rb
121
- - test/mactag/tag/plugin_test.rb
122
- - test/mactag/tag/rails_test.rb
123
- - test/mactag_test.rb
146
+ - spec/mactag/builder_spec.rb
147
+ - spec/mactag/config_spec.rb
148
+ - spec/mactag/ctags_spec.rb
149
+ - spec/mactag/dsl_spec.rb
150
+ - spec/mactag/server_spec.rb
151
+ - spec/mactag/tag/app_spec.rb
152
+ - spec/mactag/tag/gem_spec.rb
153
+ - spec/mactag/tag/plugin_spec.rb
154
+ - spec/mactag/tag/rails_spec.rb
155
+ - spec/mactag/tags_file_spec.rb
156
+ - spec/mactag_spec.rb
@@ -1,77 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BuilderTest < ActiveSupport::TestCase
4
- setup do
5
- @builder = Mactag::Builder.new
6
- end
7
-
8
- context '#<<' do
9
- setup do
10
- @tag = Mactag::Tag::App.new('app')
11
- end
12
-
13
- should 'add single tag to tags' do
14
- @builder << @tag
15
-
16
- assert_equal 1, @builder.instance_variable_get('@tags').size
17
- end
18
-
19
- should 'add multiple tags to tags' do
20
- @builder << [@tag, @tag]
21
-
22
- assert_equal 2, @builder.instance_variable_get('@tags').size
23
- end
24
- end
25
-
26
- context '#all' do
27
- should 'return all tags if existing tags' do
28
- app = Mactag::Tag::App.new('app')
29
- lib = Mactag::Tag::App.new('lib')
30
-
31
- @builder << app
32
- @builder << lib
33
-
34
- assert_same_elements ['app', 'lib'], @builder.all
35
- end
36
-
37
- should 'return an empty array if no tags' do
38
- assert_same_elements [], @builder.all
39
- end
40
- end
41
-
42
- context '#gems?' do
43
- should 'return true if existing tags' do
44
- @builder.stubs(:all).returns(['app'])
45
-
46
- assert @builder.gems?
47
- end
48
-
49
- should 'return false if no existing tags' do
50
- @builder.stubs(:all).returns([])
51
-
52
- assert !@builder.gems?
53
- end
54
- end
55
-
56
- context '#generate' do
57
- should 'accept a block as argument' do
58
- assert_nothing_raised do
59
- Mactag::Builder.generate {}
60
- end
61
- end
62
- end
63
-
64
- context '#gem_home_exists?' do
65
- should 'exist if directory exists in system' do
66
- File.stubs(:directory?).returns(true)
67
-
68
- assert Mactag::Builder.gem_home_exists?
69
- end
70
-
71
- should 'not exist if directory does not exist in system' do
72
- File.stubs(:directory?).returns(false)
73
-
74
- assert !Mactag::Builder.gem_home_exists?
75
- end
76
- end
77
- end
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigTest < ActiveSupport::TestCase
4
- context '#binary' do
5
- should 'be right command' do
6
- assert_equal 'ctags -o TAGS -e', Mactag::Config.binary
7
- end
8
- end
9
-
10
- context '#gem_home' do
11
- context 'when using RVM' do
12
- setup do
13
- Mactag::Config.stubs(:rvm).returns(true)
14
- File.stubs(:join).returns('/path/to/rvm/gems')
15
-
16
- @gem_home = Mactag::Config.gem_home
17
- end
18
-
19
- should 'be correct' do
20
- assert_equal '/path/to/rvm/gems', @gem_home
21
- end
22
- end
23
-
24
- context 'when not using RVM' do
25
- setup do
26
- Mactag::Config.stubs(:rvm).returns(false)
27
-
28
- @gem_home = Mactag::Config.gem_home
29
- end
30
-
31
- should 'correct' do
32
- assert_equal '/Library/Ruby/Gems/1.8/gems', @gem_home
33
- end
34
- end
35
- end
36
- end