Class: CukePack::Profiles

Inherits:
Object
  • Object
show all
Defined in:
lib/cuke-pack/profiles.rb

Class Method Summary collapse

Class Method Details

.std_optsObject



3
4
5
# File 'lib/cuke-pack/profiles.rb', line 3

def self.std_opts
  "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} -f Cucumber::StepWriter --out features/step_definitions --strict"
end

.std_wip_optsObject



7
8
9
# File 'lib/cuke-pack/profiles.rb', line 7

def self.std_wip_opts
  %{#{std_opts} --tags @wip}
end

.writeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cuke-pack/profiles.rb', line 11

def self.write
  in_progress_file = 'in_progress.txt'
  rerun_file = 'rerun.txt'

  in_progress = nil
  if File.file?(in_progress_file)
    in_progress = File.readlines(in_progress_file).first

    if in_progress
      in_progress = nil if in_progress.empty?
    end
  end

  if in_progress
    File.open(rerun_file, 'wb') { |fh| fh.print in_progress }

    wip_opts = %{RERUN_FILE=#{rerun_file} RUN_INPROGRESS=#{in_progress_file} #{std_opts} @#{rerun_file}}
  else
    wip_opts = %{#{std_wip_opts} features}
  end

  headless_driver = ENV['DRIVER'] || 'poltergeist'

  headless_opts = %{DRIVER=#{headless_driver} INPROGRESS=#{in_progress_file} #{std_opts}}

  <<-YML
default: #{headless_opts} features
wip: #{wip_opts}
precommit: #{headless_opts} --tags ~@no-precommit --tags ~@wip:0 features
cleanup: #{headless_opts} -f Cucumber::CleanupFormatter --out unused.txt features
YML
end