Module: Polyamory

Defined in:
lib/polyamory.rb,
lib/polyamory/bats.rb,
lib/polyamory/rspec.rb,
lib/polyamory/runner.rb,
lib/polyamory/command.rb,
lib/polyamory/cucumber.rb,
lib/polyamory/test_unit.rb,
lib/polyamory/rooted_pathname.rb

Defined Under Namespace

Classes: Bats, Command, Cucumber, RSpec, RootedPathname, Runner, TestUnit

Constant Summary collapse

VERSION =
'0.6.2'

Class Method Summary collapse

Class Method Details

.parse_options!(args) ⇒ Object



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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/polyamory.rb', line 12

def self.parse_options!(args)
  options = {
    :warnings     => false,
    :verbose      => false,
    :backtrace    => nil,
    :test_seed    => nil,
    :bundler      => nil,
    :name_filters => [],
    :tag_filters  => [],
    :load_paths   => [],
  }

  OptionParser.new do |opts|
    opts.banner  = 'Usage: polyamory [<dirname>] [<file>[:<line>]] [-n <pattern>] [-t <tag>]'
    opts.version = VERSION

    opts.summary_indent = " " * 4

    opts.separator "\n  Ruby options:"

    opts.on '-w', "Turn on Ruby warnings" do
      options[:warnings] = true
    end

    opts.on '-I PATH', "Directory to load on $LOAD_PATH" do |str|
      options[:load_paths] << str
    end

    opts.separator "\n  Test options:"

    opts.on '-s', '--seed SEED', Integer, "Set random seed" do |m|
      options[:test_seed] = m.to_i
    end

    opts.on '-b', '--[no-]backtrace', "Show full backtrace" do |set|
      options[:backtrace] = set
    end

    opts.on '-n', '--name PATTERN', "Filter test names on pattern" do |str|
      options[:name_filters] << str
    end

    opts.on '-t', '--tag TAG', "Filter tests on tag" do |str|
      options[:tag_filters] << str
    end

    opts.on '-v', '--verbose', "Show progress processing files" do
      options[:verbose] = true
    end

    opts.on '--[no-]bundler', "Use `bundle exec' for running tests" do |set|
      options[:bundler] = set
    end

    opts.separator "\n  Other options:"

    opts.on_tail '-h', '--help', 'Display this help' do
      puts opts
      exit
    end

    begin
      opts.parse! args
    rescue OptionParser::InvalidOption
      abort opts.banner
    end
  end

  options
end

.run(args, dir) ⇒ Object



7
8
9
10
# File 'lib/polyamory.rb', line 7

def self.run(args, dir)
  options = parse_options! args
  Runner.new(args, dir, options).run
end