Class: ChemistryKit::CLI::CKitCLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/chemistrykit/cli/cli.rb

Overview

Main Chemistry Kit CLI Class

Instance Method Summary collapse

Instance Method Details

#brewObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/chemistrykit/cli/cli.rb', line 79

def brew
  config = load_config options['config']
  # TODO: perhaps the params should be rolled into the available
  # config object injected into the system?
  pass_params if options['params']

  # replace certain config values with run time flags as needed
  config = override_configs options, config

  load_page_objects

  # get those beakers that should be executed
  beakers = options['beakers'] ? options['beakers'] : Dir.glob(File.join(Dir.getwd, 'beakers/*'))

  if options['beakers']
    # if a beaker(s) defined use them
    beakers = options['beakers']
    # if tags are explicity defined, apply them to the selected beakers
    setup_tags(options['tag'])
  else
    # beakers default to everything
    beakers = Dir.glob(File.join(Dir.getwd, 'beakers/*'))

    if options['tag']

      # if tags are explicity defined, apply them to all beakers
      setup_tags(options['tag'])
    else
      # else choose the default tag
      setup_tags(['depth:shallow'])
    end
  end

  # configure rspec
  rspec_config(config)

  # based on concurrency parameter run tests
  if config.concurrency > 1 && ! options['parallel']
    exit_code = run_in_parallel beakers, config.concurrency, @tags, options
  else
    exit_code = run_rspec beakers
  end

  process_html unless options['parallel']
  exit_code unless options['parallel']
end

#tagsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/chemistrykit/cli/cli.rb', line 47

def tags
  beakers = Dir.glob(File.join(Dir.getwd, 'beakers/*'))
  ::RSpec.configure do |c|
    c.add_setting :used_tags
    c.before(:suite) { ::RSpec.configuration.used_tags = [] }
    c.around(:each) do |example|
      standard_keys = [:example_group, :example_group_block, :description_args, :caller, :execution_result, :full_description]
      example..each do |key, value|
        tag = "#{key}:#{value}" unless standard_keys.include?(key)
        ::RSpec.configuration.used_tags.push tag unless ::RSpec.configuration.used_tags.include?(tag) || tag.nil?
      end
    end
    c.after(:suite) do
      puts "\nTags used in harness:\n\n"
      puts ::RSpec.configuration.used_tags.sort
    end
  end
  ::RSpec::Core::Runner.run(beakers)
end