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



69
70
71
72
73
74
75
76
77
78
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
# File 'lib/chemistrykit/cli/cli.rb', line 69

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']
    run_in_parallel beakers, config.concurrency, @tags, options
  else
    run_rspec beakers
  end

end

#tagsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/chemistrykit/cli/cli.rb', line 38

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]
      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