Commit d2c016be authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Speed-up Command::Lib

parent c14c319a
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Command::Lib::Create do describe Command::Lib::Create do
before do
@sut = Command::Lib::Create
end
it "complains if wrong parameters" do it "complains if wrong parameters" do
lambda { run_command('lib', 'create') }.should.raise CLAide::Help lambda { run_command('lib', 'create') }.should.raise CLAide::Help
end end
...@@ -9,12 +15,50 @@ module Pod ...@@ -9,12 +15,50 @@ module Pod
it "complains if pod name contains spaces" do it "complains if pod name contains spaces" do
lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help
end end
it "should create a new dir for the newly created pod" do
@sut.any_instance.stubs(:configure_template)
url = @sut::TEMPLATE_REPO
@sut.any_instance.expects(:git!).with("clone '#{url}' TestPod").once
run_command('lib', 'create', 'TestPod')
end
it "configures the template after cloning it passing the name of the Pod as the argument" do
@sut.any_instance.stubs(:clone_template)
dir = SpecHelper.temporary_directory + 'TestPod'
dir.mkpath
@sut.any_instance.expects(:ruby!).with("_CONFIGURE.rb TestPod").once
run_command('lib', 'create', 'TestPod')
end
it "should show link to new pod guide after creation" do
@sut.any_instance.stubs(:clone_template)
@sut.any_instance.stubs(:configure_template)
output = run_command('lib', 'create', 'TestPod')
output.should.include? 'http://guides.cocoapods.org/making/making-a-cocoapod'
end
before do
@sut.any_instance.stubs(:configure_template)
end
it "should use the given template URL" do
template_url = 'https://github.com/custom/template.git'
@sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
sut = run_command('lib', 'create', 'TestPod', template_url)
end
it "should use the default URL if no template URL is given" do
template_url = 'https://github.com/CocoaPods/pod-template.git'
@sut.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
run_command('lib', 'create', 'TestPod')
end
end end
describe Command::Lib::Lint do describe Command::Lib::Lint do
it "lints the current working directory" do it "lints the current working directory" do
Dir.chdir(fixture('integration/Reachability')) do Dir.chdir(fixture('integration/Reachability')) do
cmd = command('lib', 'lint', '--only-errors') cmd = command('lib', 'lint', '--only-errors', '--quick')
cmd.run cmd.run
UI.output.should.include "passed validation" UI.output.should.include "passed validation"
end end
...@@ -35,14 +79,12 @@ module Pod ...@@ -35,14 +79,12 @@ module Pod
f << "spec.name = 'Broken'" f << "spec.name = 'Broken'"
f << 'end' f << 'end'
} }
tmp_validator = Validator.new('Broken.podspec') Validator.any_instance.expects(:no_clean=).with(false)
lint_path = tmp_validator.validation_dir Validator.any_instance.stubs(:perform_extensive_analysis)
should.raise Pod::Informative do
lambda { run_command('lib', 'lint', 'Broken.podspec') }.should.raise Pod::Informative run_command('lib', 'lint', 'Broken.podspec')
end
UI.output.should.include "Missing required attribute" UI.output.should.include "Missing required attribute"
lint_path.exist?.should == false
end end
end end
...@@ -53,46 +95,14 @@ module Pod ...@@ -53,46 +95,14 @@ module Pod
f << "spec.name = 'Broken'" f << "spec.name = 'Broken'"
f << 'end' f << 'end'
} }
lambda { run_command('lib', 'lint', 'Broken.podspec', '--no-clean') }.should.raise Pod::Informative Validator.any_instance.expects(:no_clean=).with(true)
Validator.any_instance.stubs(:perform_extensive_analysis)
UI.output.should.include "Pods project available at" should.raise Pod::Informative do
run_command('lib', 'lint', 'Broken.podspec', '--no-clean')
end
UI.output.should.include "Missing required attribute" UI.output.should.include "Missing required attribute"
UI.output.should.include "Pods project available at"
lint_dir = UI.output[/.*Pods project available at `(.*)` for inspection./,1]
Pathname.new(lint_dir).exist?.should == true
end end
end end
end end
describe Command::Lib do
it "should create a new dir for the newly created pod" do
run_command('lib', 'create', 'TestPod')
Dir.chdir(temporary_directory) do
Pathname.new(temporary_directory + 'TestPod').exist?.should == true
end
end
it "should show link to new pod guide after creation" do
output = run_command('lib', 'create', 'TestPod')
output.should.include? 'http://guides.cocoapods.org/making/making-a-cocoapod'
end
before do
Command::Lib::Create.any_instance.stubs(:configure_template)
Command::Lib::Create.any_instance.stubs(:git!)
end
it "should use the given template URL" do
template_url = 'https://github.com/custom/template.git'
Command::Lib::Create.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
sut = run_command('lib', 'create', 'TestPod', template_url)
end
it "should use the default URL if no template URL is given" do
template_url = 'https://github.com/CocoaPods/pod-template.git'
Command::Lib::Create.any_instance.expects(:git!).with("clone '#{template_url}' TestPod").once
run_command('lib', 'create', 'TestPod')
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment