class FWToolkit::Rake::TestTask

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/fwtoolkit/rake/tasks/test.rb, line 13
def initialize(&block)
  yield self if block_given?
  define_task
end

Private Instance Methods

define_task() click to toggle source
# File lib/fwtoolkit/rake/tasks/test.rb, line 21
def define_task
  namespace :test do

    tasklib = Cucumber::Rake::Task.new(:frank, 'Run Frank acceptance tests')
    task = ::Rake::Task['test:frank'] 
    task.set_arg_names [:tags, :cucumber_options, :sim_launcher]
    task.enhance_r do |t, args|
      Projectfile.load! projectfile_path
      args.with_defaults(:tags => '~@wip', :cucumber_options => '', :sim_launcher => nil)
      ENV['APP_BUNDLE_PATH'] = File.join Dir.pwd, Projectfile.frankified_app
      ENV['USE_SIM_LAUNCHER_SERVER'] = nil || args[:sim_launcher]
      tasklib.cucumber_opts = "#{Projectfile.frank_root}/Features --tags=\"#{args[:tags]}\" #{args[:cucumber_options]}"
    end
  end

  namespace :test do

    desc 'Build the frankified App'
    task :build do
      Projectfile.load! projectfile_path
      `frank build --workspace #{Projectfile.xcode_workspace} --scheme #{Projectfile.xcode_scheme}`
    end

    namespace :ci do
      desc 'Run Frank acceptance tests with CI options'
      task :frank, :tags do |t, args|
        Projectfile.load! projectfile_path

        artifacts_dir = ENV['CC_BUILD_ARTIFACTS'] || '/tmp'
        cucumber_options = "--format pretty --format html --out '#{artifacts_dir}/frank_results.html' --format rerun --out '#{artifacts_dir}/frank_rerun.txt'"
        ::Rake::Task['test:frank'].invoke args[:tags], cucumber_options, 'yes'

      end
    end
  end
end