Class: RSpec::CommandOption

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/command_option.rb,
lib/rspec/command_option/version.rb

Constant Summary collapse

NO_ARGS_OPTIONS =
%i( fail_fast dry_run color warnings backtrace )
ARGS_OPTIONS =
%i( options failure_exit_code format out deprecation_out tag )
OPTIONS =
NO_ARGS_OPTIONS + ARGS_OPTIONS
VERSION =
"0.5.2"

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ CommandOption

Returns a new instance of CommandOption.



12
13
14
# File 'lib/rspec/command_option.rb', line 12

def initialize(&block)
  block.call(self) if block
end

Instance Method Details

#buildObject Also known as: to_s



16
17
18
19
20
21
# File 'lib/rspec/command_option.rb', line 16

def build
  cmd = CommandBuilder.new(nil) # don't use command name
  NO_ARGS_OPTIONS.select {|opt| send(opt) }.map {|opt| cmd.argument(opt.to_s.gsub('_', '-')) }
  ARGS_OPTIONS.select {|opt| send(opt) }.map {|opt| cmd.argument(opt.to_s.gsub('_', '-'), send(opt)) }
  cmd.to_s.strip
end