require 'rake/tasklib' require 'rubygems' require 'xcodebuild' require 'cucumber/rake/task' module FWToolkit module Tasks class BuildTask < ::Rake::TaskLib include Rake::DSL if defined?(Rake::DSL) attr_accessor :workspace attr_accessor :scheme def initialize(&block) yield self if block_given? define end private def define namespace :xcode do XcodeBuild::Tasks::BuildTask.new :debug_simulator do |t| t.invoke_from_within = '.' t.configuration = "Debug" t.sdk = "iphonesimulator" t.workspace = @workspace t.scheme = @scheme t.formatter = XcodeBuild::Formatters::ProgressFormatter.new end end namespace :frank do desc 'Setup Frank' task :setup do sh "frank setup" end desc 'Build the frankified App' task :build do sh "frank build --workspace #{@workspace} --scheme #{@scheme}" end Cucumber::Rake::Task.new(:ci_test, 'Run Frank acceptance tests with CI options') do |t| ENV['APP_BUNDLE_PATH'] = File.join( Dir.pwd, 'Frank/frankified_build/Frankified.app' ) ENV['USE_SIM_LAUNCHER_SERVER'] = 'YES' artifacts_dir = ENV['CC_BUILD_ARTIFACTS'] t.cucumber_opts = "Frank/features --tags ~@wip --format pretty --format html --out '#{artifacts_dir}/frank_results.html' --format rerun --out '#{artifacts_dir}/frank_rerun.txt'" end desc 'Run Frank acceptance tests' task :test, :target, :tag do |t, args| args.with_defaults(:target => 'Frank/features', :tag => '~@wip') ENV['APP_BUNDLE_PATH'] = File.join( Dir.pwd, 'Frank/frankified_build/Frankified.app' ) ENV['USE_SIM_LAUNCHER_SERVER'] = nil sh "cucumber #{args.target} --tags #{args.tag}" end end namespace :pod do task :clean do FileUtils.rm_rf('Pods') end task :install do sh 'pod install' end end namespace :ci do task :bundle_install do sh 'bundle' end desc 'Clean, build and test' task :build => ["ci:bundle_install", "xcode:debug_simulator:cleanbuild", "frank:build", "frank:ci_test"] desc 'Clean, build and test for Cocoapods projects' task :pod_build => ["ci:bundle_install", "pod:clean", "pod:install", "ci:build"] end end end end end