Commit 1bb68e0e authored by Eloy Duran's avatar Eloy Duran

Validate that a spec has the minimum required attributes. Testing if it compiles is for later.

parent 9ba5654d
......@@ -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
......
......@@ -56,16 +56,18 @@ module Pod
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
......
......@@ -144,6 +144,22 @@ module Pod
"#<#{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.
......
......@@ -53,6 +53,7 @@ describe "Pod::Command" do
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
......
......@@ -138,3 +138,12 @@ describe "A Pod::Specification that's part of another pod's source" do
# @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
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