spec/command/plugins/create_spec.rb in cocoapods-plugins-0.1.1 vs spec/command/plugins/create_spec.rb in cocoapods-plugins-0.2.0
- old
+ new
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
+require 'tmpdir'
# The CocoaPods namespace
#
module Pod
describe Command::Plugins::Create do
@@ -17,32 +18,48 @@
#--- Validation
it 'should require a name is passed in' do
@command = create_command
- # rubocop:disable Lambda
- lambda { @command.validate! }
- .should.raise(CLAide::Help)
- .message.should.match(/A name for the plugin is required./)
- # rubocop:enable Lambda
+ should.raise(CLAide::Help) do
+ @command.validate!
+ end.message.should.match(/A name for the plugin is required./)
end
it 'should require a non-empty name is passed in' do
@command = create_command('')
- # rubocop:disable Lambda
- lambda { @command.validate! }
- .should.raise(CLAide::Help)
- .message.should.match(/A name for the plugin is required./)
- # rubocop:enable Lambda
+ should.raise(CLAide::Help) do
+ @command.validate!
+ end.message.should.match(/A name for the plugin is required./)
end
it 'should require the name does not have spaces' do
@command = create_command('my gem')
- # rubocop:disable Lambda
- lambda { @command.validate! }
- .should.raise(CLAide::Help)
- .message.should.match(/The plugin name cannot contain spaces./)
- # rubocop:enable Lambda
+ should.raise(CLAide::Help) do
+ @command.validate!
+ end.message.should.match(/The plugin name cannot contain spaces./)
+ end
+
+ #--- Naming
+
+ it 'should prefix the given name if not already' do
+ @command = create_command('unprefixed')
+ Dir.mktmpdir do |tmpdir|
+ Dir.chdir(tmpdir) do
+ @command.run
+ end
+ end
+ UI.output.should.include('Creating `cocoapods-unprefixed` plugin')
+ end
+
+ it 'should not prefix the name if already prefixed' do
+ @command = create_command('cocoapods-prefixed')
+ Dir.mktmpdir do |tmpdir|
+ Dir.chdir(tmpdir) do
+ @command.run
+ end
+ end
+ UI.output.should.include('Creating `cocoapods-prefixed` plugin')
end
#--- Template download
it 'should download the default template repository' do