Skip to content

Instantly share code, notes, and snippets.

@blazingpair
Last active December 11, 2015 03:58
Show Gist options
  • Save blazingpair/4541144 to your computer and use it in GitHub Desktop.
Save blazingpair/4541144 to your computer and use it in GitHub Desktop.
Kiwi integrated with OCHamcrest
Pod::Spec.new do |s|
s.name = 'Kiwi'
s.version = '2.0.3.dev'
s.summary = 'A Behavior Driven Development library for iOS and OS X.'
s.homepage = 'https://github.com/allending/Kiwi'
s.authors = { 'Allen Ding' => 'alding@gmail.com', 'Luke Redpath' => 'luke@lukeredpath.co.uk' }
s.license = { :type => 'MIT', :file => 'License.txt' }
s.source = { :git => 'https://github.com/allending/Kiwi.git', :commit => 'b5b4223884a60fa9842986421ace13ec576b54e1'}
s.source_files = FileList['Classes/*.{h,m}'].exclude(/KWStringPrefixMatcher/).exclude(/KWStringContainsMatcher/)
s.framework = 'SenTestingKit'
# HC_SHORTHAND is defined for project test target for naming convenience
s.xcconfig = {
'FRAMEWORK_SEARCH_PATHS' => '"$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) HC_SHORTHAND'
}
# Cocoapods use above xcconfig to compile this Pod as well as project test target that uses this Pod
# we need to undefine HC_SHORTHAND to avoid compiler warnings when building Pod static library
s.prefix_header_contents = '#undef HC_SHORTHAND'
s.dependency 'OCHamcrest'
def s.post_install(target)
# Fix an Hamcrest integration by using Hamcrest matcher, instead of the minimal version of matcher protocol
header = (pod_destroot + 'Classes/KWHCMatcher.h')
header_contents = File.read(header)
header_contents.gsub!(/@protocol.+@end/m,'#import <HCMatcher.h>')
File.write(header, header_contents)
# Remove uses of minimal version of matcher protocol
header = (pod_destroot + 'Classes/Kiwi.h')
header_contents = File.read(header)
header_contents.gsub!(/#import "KWStringPrefixMatcher.h"/,'')
header_contents.gsub!(/#import "KWStringContainsMatcher.h"/,'')
File.write(header, header_contents)
end
end
@blazingpair
Copy link
Author

This pod helps to solve conflict in integrating Kiwi with Hamcrest. See https://github.com/allending/Kiwi/pull/151
It also enables use of shorthand names for Hamcrest matchers within Kiwi specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment