Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Validate that a spec has the minimum required attributes. Testing if …

…it compiles is for later.
  • Loading branch information...
commit 1bb68e0e275a87d32894c03b541aecf935b4307c 1 parent 9ba5654
@alloy alloy authored
View
2  .kick
@@ -5,7 +5,7 @@ Ruby.runner_bin = 'macbacon'
process do |files|
specs = files.take_and_map do |file|
case file
- when %r{lib/cocoa_pods/(.+?)\.rb$}
+ when %r{lib/cocoapods/(.+?)\.rb$}
s = Dir.glob("spec/**/#{$1}_spec.rb")
s unless s.empty?
end
View
12 lib/cocoapods/command/spec.rb
@@ -56,16 +56,18 @@ def create
source_files 'Classes', 'Classes/**/*.{h,m}'
xcconfig 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework'
+
+ dependency 'SomeLibraryThat#{@name}DependsOn', '>= 1.0.0'
end
SPEC
(Pathname.pwd + "#{@name}.podspec").open('w') { |f| f << spec }
end
- #def lint
- #file = @name ? Pathname.new(@name) : config.project_podfile
- #spec = Specification.from_podspec(file)
- #spec.validate!
- #end
+ def lint
+ file = @name ? Pathname.new(@name) : config.project_podfile
+ spec = Specification.from_podspec(file)
+ spec.validate!
+ end
#def push
View
16 lib/cocoapods/specification.rb
@@ -144,6 +144,22 @@ def inspect
"#<#{self.class.name} for #{to_s}>"
end
+ def validate!
+ attrs = []
+ attrs << "`name'" unless @name
+ attrs << "`version'" unless @version
+ attrs << "`summary'" unless @summary
+ attrs << "`homepage'" unless @homepage
+ attrs << "`author(s)'" unless @authors
+ attrs << "either `source' or `part_of'" unless @source || @part_of
+ attrs << "`source_files'" unless @source_files
+ unless attrs.empty?
+ raise Informative, "The following required " \
+ "#{attrs.size == 1 ? 'attribute is' : 'attributes are'} " \
+ "missing: #{attrs.join(", ")}"
+ end
+ end
+
# Install and download hooks
# Places the activated specification in the project's pods directory.
View
1  spec/functional/command_spec.rb
@@ -53,6 +53,7 @@ def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
spec.read(:description).should == 'An optional longer description of Bananas.'
spec.read(:source_files).should == [Pathname.new('Classes'), Pathname.new('Classes/**/*.{h,m}')]
spec.read(:xcconfig).should == { 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework' }
+ spec.read(:dependencies).should == [Pod::Dependency.new('SomeLibraryThatBananasDependsOn', '>= 1.0.0')]
end
before do
View
9 spec/unit/specification_spec.rb
@@ -138,3 +138,12 @@
# @spec.pod_destroot
#end
end
+
+describe "A Pod::Specification, in general," do
+ it "raises if the specification does not contain the minimum required attributes" do
+ exception = lambda {
+ Pod::Spec.new.validate!
+ }.should.raise Pod::Informative
+ exception.message =~ /name.+?version.+?summary.+?homepage.+?authors.+?(source|part_of).+?source_files/
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.