claide-plugins 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require 'tmpdir'
3
+
4
+ # The CocoaPods namespace
5
+ #
6
+ module CLAide
7
+ describe Command::Plugins::Create do
8
+ extend SpecHelper::PluginsCreateCommand
9
+
10
+ before do
11
+ UI_OUT.reopen
12
+ end
13
+
14
+ it 'registers itself' do
15
+ Command.parse(%w(plugins create)).
16
+ should.be.instance_of Command::Plugins::Create
17
+ end
18
+
19
+ #--- Validation
20
+
21
+ it 'should require a name is passed in' do
22
+ @command = create_command
23
+ should.raise(CLAide::Help) do
24
+ @command.validate!
25
+ end.message.should.match(/A name for the plugin is required./)
26
+ end
27
+
28
+ it 'should require a non-empty name is passed in' do
29
+ @command = create_command('')
30
+ should.raise(CLAide::Help) do
31
+ @command.validate!
32
+ end.message.should.match(/A name for the plugin is required./)
33
+ end
34
+
35
+ it 'should require the name does not have spaces' do
36
+ @command = create_command('my gem')
37
+ should.raise(CLAide::Help) do
38
+ @command.validate!
39
+ end.message.should.match(/The plugin name cannot contain spaces./)
40
+ end
41
+
42
+ #--- Naming
43
+
44
+ it 'should prefix the given name if not already' do
45
+ @command = create_command('unprefixed')
46
+ Dir.mktmpdir do |tmpdir|
47
+ Dir.chdir(tmpdir) do
48
+ @command.run
49
+ end
50
+ end
51
+ UI_OUT.string.should.include('Creating `claide-unprefixed` plugin')
52
+ end
53
+
54
+ it 'should not prefix the name if already prefixed' do
55
+ @command = create_command('claide-prefixed')
56
+ Dir.mktmpdir do |tmpdir|
57
+ Dir.chdir(tmpdir) do
58
+ @command.run
59
+ end
60
+ end
61
+ UI_OUT.string.should.include('Creating `claide-prefixed` plugin')
62
+ end
63
+
64
+ #--- Template download
65
+
66
+ it 'should download the default template repository' do
67
+ @command = create_command('claide-banana')
68
+
69
+ template_repo = 'https://github.com/CocoaPods/' \
70
+ 'cocoapods-plugin-template.git'
71
+ git_command = ['clone', template_repo, 'claide-banana']
72
+ @command.expects(:git!).with(git_command)
73
+ @command.expects(:configure_template)
74
+ @command.run
75
+ UI_OUT.string.should.include('Creating `claide-banana` plugin')
76
+ end
77
+
78
+ it 'should download the passed in template repository' do
79
+ alt_repo = 'https://github.com/CocoaPods/' \
80
+ 'claide-banana-plugin-template.git'
81
+ @command = create_command('claide-banana', alt_repo)
82
+
83
+ @command.expects(:git!).with(['clone', alt_repo, 'claide-banana'])
84
+ @command.expects(:configure_template)
85
+ @command.run
86
+ UI_OUT.string.should.include('Creating `claide-banana` plugin')
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module CLAide
6
+ describe Command::Plugins::List do
7
+ extend SpecHelper::PluginsStubs
8
+
9
+ before do
10
+ UI_OUT.reopen
11
+ @command = CLAide::Command::Plugins::List.new CLAide::ARGV.new []
12
+ end
13
+
14
+ it 'registers itself' do
15
+ Command.parse(%w(plugins list)).
16
+ should.be.instance_of Command::Plugins::List
17
+ end
18
+
19
+ #--- Output printing
20
+
21
+ it 'prints out all plugins' do
22
+ stub_plugins_json_request
23
+ @command.run
24
+ UI_OUT.string.should.include('github.com/CLAide/claide-fake-1')
25
+ UI_OUT.string.should.include('github.com/CLAide/claide-fake-2')
26
+ UI_OUT.string.should.include('github.com/chneukirchen/bacon')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module CLAide
6
+ describe Command::Plugins::Search do
7
+ extend SpecHelper::PluginsStubs
8
+ extend SpecHelper::PluginsSearchCommand
9
+
10
+ before do
11
+ UI_OUT.reopen
12
+ end
13
+
14
+ it 'registers itself' do
15
+ Command.parse(%w(plugins search)).
16
+ should.be.instance_of Command::Plugins::Search
17
+ end
18
+
19
+ #--- Validation
20
+
21
+ it 'should require a non-empty query' do
22
+ @command = search_command
23
+ should.raise(CLAide::Help) do
24
+ @command.validate!
25
+ end.message.should.match(/A search query is required./)
26
+ end
27
+
28
+ it 'should require a valid RegExp as query' do
29
+ @command = search_command('[invalid')
30
+ should.raise(CLAide::Help) do
31
+ @command.validate!
32
+ end.message.should.match(/A valid regular expression is required./)
33
+ end
34
+
35
+ #--- Output printing
36
+
37
+ it 'should filter plugins only by name without full search' do
38
+ stub_plugins_json_request
39
+ @command = search_command('search')
40
+ @command.run
41
+ UI_OUT.string.should.not.include('-> CLAide Fake Gem')
42
+ UI_OUT.string.should.include('-> CLAide Searchable Fake Gem')
43
+ UI_OUT.string.should.not.include('-> Bacon')
44
+ end
45
+
46
+ it 'should filter plugins by name, author, description with full search' do
47
+ stub_plugins_json_request
48
+ @command = search_command('--full', 'search')
49
+ @command.run
50
+ UI_OUT.string.should.include('-> CLAide Fake Gem')
51
+ UI_OUT.string.should.include('-> CLAide Searchable Fake Gem')
52
+ UI_OUT.string.should.not.include('-> Bacon')
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module CLAide
6
+ describe Command::PluginsHelper do
7
+ extend SpecHelper::PluginsStubs
8
+
9
+ it 'downloads the json file' do
10
+ stub_plugins_json_request
11
+ json = Command::PluginsHelper.download_json
12
+ json.should.not.be.nil?
13
+ json.should.be.is_a? Hash
14
+ json['plugins'].size.should.eql? 3
15
+ end
16
+
17
+ it 'handles empty/bad JSON' do
18
+ stub_plugins_json_request 'This is not JSON'
19
+ expected_error = /Invalid plugins list from cocoapods-plugins/
20
+ should.raise(CLAide::Informative) do
21
+ Command::PluginsHelper.download_json
22
+ end.message.should.match(expected_error)
23
+ end
24
+
25
+ it 'notifies the user if the download fails' do
26
+ stub_plugins_json_request '', [404, 'Not Found']
27
+ expected_error = /Could not download plugins list from cocoapods-plugins/
28
+ should.raise(CLAide::Informative) do
29
+ Command::PluginsHelper.download_json
30
+ end.message.should.match(expected_error)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ # The CocoaPods namespace
4
+ #
5
+ module CLAide
6
+ describe Command::Plugins do
7
+ before do
8
+ argv = CLAide::ARGV.new([])
9
+ @command = Command::Plugins.new(argv)
10
+ end
11
+
12
+ it 'registers itself and uses the default subcommand' do
13
+ Command.parse(%w(plugins)).should.be.instance_of Command::Plugins::List
14
+ end
15
+
16
+ it 'exists' do
17
+ @command.should.not.be.nil?
18
+ end
19
+ end
20
+
21
+ describe Plugins do
22
+ it 'should have a default config' do
23
+ config = CLAide::Plugins.config
24
+ config.should.be.instance_of CLAide::Plugins::Configuration
25
+ end
26
+
27
+ it 'should default to a CLAide plugin config' do
28
+ config = CLAide::Plugins.config
29
+ config.name.should.equal('default name')
30
+ config.plugin_prefix.should.equal('claide')
31
+ config.plugin_list_url.should.equal('https://github.com/cocoapods/claide-plugins/something.json')
32
+ url = config.plugin_template_url
33
+ url.should.equal('https://github.com/cocoapods/claide-plugins-template')
34
+ end
35
+
36
+ it 'should set the plugin_prefix in the claide plugin manager' do
37
+ CLAide::Plugins.config =
38
+ CLAide::Plugins::Configuration.new('testing',
39
+ 'pants',
40
+ 'http://example.com/pants.json',
41
+ 'http://example.com/pants_template')
42
+ CLAide::Plugins.config.plugin_prefix.should.equal('pants')
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = 'claide-foo1'
4
+ spec.version = '2.0.1'
5
+ spec.authors = ['Author 1']
6
+ spec.summary = 'Gem Summary 1'
7
+ spec.description = 'Gem Description 1'
8
+ spec.homepage = 'https://github.com/proper-man/claide-foo1'
9
+ spec.license = 'MIT'
10
+ end
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = 'claide-foo2'
4
+ spec.version = '2.0.2'
5
+ spec.authors = ['Author 1', 'Author 2']
6
+ spec.description = 'Gem Description 2'
7
+ spec.homepage = 'https://github.com/proper-man/claide-foo2'
8
+ spec.license = 'MIT'
9
+ end
@@ -0,0 +1,22 @@
1
+ {
2
+ "plugins":[
3
+ {
4
+ "gem":"claide-fake-fake-fake-1",
5
+ "name":"CLAide Fake Gem",
6
+ "url":"https://github.com/CLAide/claide-fake-1",
7
+ "description":"A Pod that should not exist and should only be found by full search"
8
+ },
9
+ {
10
+ "gem":"bacon",
11
+ "name":"Bacon",
12
+ "url":"https://github.com/chneukirchen/bacon",
13
+ "description":"A minimal RSpec clone."
14
+ },
15
+ {
16
+ "gem":"claide-fake-fake-fake-2",
17
+ "name":"CLAide Searchable Fake Gem",
18
+ "url":"https://github.com/CLAide/claide-fake-2",
19
+ "description":"A Pod that should not exist but should be found with search"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,10 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = 'unprefixed-plugin'
4
+ spec.version = '1.2.3'
5
+ spec.authors = ['Author 1', 'Author 2']
6
+ spec.summary = 'Gem Summary'
7
+ spec.description = 'Gem Description'
8
+ spec.homepage = 'https://github.com/messy-man/unprefixed-plugins'
9
+ spec.license = 'MIT'
10
+ end
@@ -0,0 +1,93 @@
1
+ # Set up coverage analysis
2
+ #-----------------------------------------------------------------------------#
3
+
4
+ require 'codeclimate-test-reporter'
5
+ CodeClimate::TestReporter.configure do |config|
6
+ config.logger.level = Logger::WARN
7
+ end
8
+ CodeClimate::TestReporter.start
9
+
10
+ # Set up
11
+ #-----------------------------------------------------------------------------#
12
+
13
+ require 'pathname'
14
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
15
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
16
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
17
+
18
+ require 'bundler/setup'
19
+ require 'bacon'
20
+ require 'mocha-on-bacon'
21
+ require 'pretty_bacon'
22
+
23
+ require 'webmock'
24
+ include WebMock::API
25
+
26
+ require 'claide_plugin'
27
+
28
+ # VCR
29
+ #--------------------------------------#
30
+
31
+ require 'vcr'
32
+ VCR.configure do |c|
33
+ c.cassette_library_dir = ROOT + 'spec/fixtures/vcr_cassettes'
34
+ c.hook_into :webmock
35
+ c.ignore_hosts 'codeclimate.com'
36
+ end
37
+
38
+ #-----------------------------------------------------------------------------#
39
+
40
+ # Disable the wrapping so the output is deterministic in the tests.
41
+ #
42
+ UI_OUT = StringIO.new
43
+ UI_ERR = StringIO.new
44
+ UI = Cork::Board.new(:out => UI_OUT, :err => UI_ERR)
45
+
46
+ UI.disable_wrap = true
47
+
48
+ #-----------------------------------------------------------------------------#
49
+
50
+ # Bacon namespace
51
+ #
52
+ module Bacon
53
+ # Add a fixture helper to the Bacon Context
54
+ class Context
55
+ ROOT = ::ROOT + 'spec/fixtures'
56
+
57
+ def fixture(name)
58
+ ROOT + name
59
+ end
60
+ end
61
+ end
62
+
63
+ #-----------------------------------------------------------------------------#
64
+
65
+ # SpecHelper namespace
66
+ #
67
+ module SpecHelper
68
+ # Add this as an extension into the Search and List specs
69
+ # to help stub the plugins.json request
70
+ module PluginsStubs
71
+ def stub_plugins_json_request(json = nil, status = 200)
72
+ body = json || File.read(fixture('plugins.json'))
73
+ stub_request(:get, 'http://example.com/pants.json').
74
+ to_return(:status => status, :body => body, :headers => {})
75
+ stub_request(:get, 'https://github.com/cocoapods/claide-plugins/something.json').
76
+ to_return(:status => status, :body => body, :headers => {})
77
+ end
78
+ end
79
+
80
+ # Add this as an extension into the Create specs
81
+ module PluginsCreateCommand
82
+ def create_command(*args)
83
+ CLAide::Command::Plugins::Create.new CLAide::ARGV.new(args)
84
+ end
85
+ end
86
+
87
+ # Add this as an extension into the Search specs
88
+ module PluginsSearchCommand
89
+ def search_command(*args)
90
+ CLAide::Command::Plugins::Search.new CLAide::ARGV.new(args)
91
+ end
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: claide-plugins
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - David Grandinetti
8
+ - Olivier Halligon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nap
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: cork
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: open4
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.3'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: bundler
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: |2
85
+ This CLAide plugin shows information about all available CLAide plugins
86
+ (yes, this is very meta!).
87
+ This plugin adds the "plugins" subcommand to a binary so that you can list
88
+ all plugins (registered in the reference JSON hosted at CocoaPods/cocoapods-plugins)
89
+ email:
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rubocop.yml"
96
+ - ".rubocop_cocoapods.yml"
97
+ - ".tm_properties"
98
+ - ".travis.yml"
99
+ - CHANGELOG.md
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE
103
+ - README.md
104
+ - Rakefile
105
+ - claide-plugins.gemspec
106
+ - lib/claide/command/gem_helper.rb
107
+ - lib/claide/command/gem_index_cache.rb
108
+ - lib/claide/command/plugins.rb
109
+ - lib/claide/command/plugins/create.rb
110
+ - lib/claide/command/plugins/list.rb
111
+ - lib/claide/command/plugins/search.rb
112
+ - lib/claide/command/plugins_config.rb
113
+ - lib/claide/command/plugins_helper.rb
114
+ - lib/claide/executable.rb
115
+ - lib/claide_plugin.rb
116
+ - lib/claide_plugins.rb
117
+ - spec/command/gem_helper_spec.rb
118
+ - spec/command/gem_index_cache_spec.rb
119
+ - spec/command/plugins/create_spec.rb
120
+ - spec/command/plugins/list_spec.rb
121
+ - spec/command/plugins/search_spec.rb
122
+ - spec/command/plugins_helper_spec.rb
123
+ - spec/command/plugins_spec.rb
124
+ - spec/fixtures/claide-foo1.gemspec
125
+ - spec/fixtures/claide-foo2.gemspec
126
+ - spec/fixtures/plugins.json
127
+ - spec/fixtures/unprefixed.gemspec
128
+ - spec/spec_helper.rb
129
+ homepage: https://github.com/cocoapods/claide-plugins
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 2.0.0
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.4.8
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: CLAide plugin which shows info about available CLAide plugins.
153
+ test_files:
154
+ - spec/command/gem_helper_spec.rb
155
+ - spec/command/gem_index_cache_spec.rb
156
+ - spec/command/plugins/create_spec.rb
157
+ - spec/command/plugins/list_spec.rb
158
+ - spec/command/plugins/search_spec.rb
159
+ - spec/command/plugins_helper_spec.rb
160
+ - spec/command/plugins_spec.rb
161
+ - spec/fixtures/claide-foo1.gemspec
162
+ - spec/fixtures/claide-foo2.gemspec
163
+ - spec/fixtures/plugins.json
164
+ - spec/fixtures/unprefixed.gemspec
165
+ - spec/spec_helper.rb