Class: Kamaze::Project::Tools::Rspec
- Inherits:
-
BaseTool
- Object
- Observable
- BaseTool
- Kamaze::Project::Tools::Rspec
- Includes:
- Concern::Cli::WithExitOnFailure
- Defined in:
- lib/kamaze/project/tools/rspec.rb
Overview
Instance Attribute Summary collapse
-
#defaults ⇒ Arguments
Default arguments used by
RSpec::Core::Runner
. - #observer_peers ⇒ Hash|nil included from Concern::Observable readonly protected
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
- #tags ⇒ Array<String>
Instance Method Summary collapse
-
#arguments ⇒ Arguments
Arguments used by
CLI
(during execution/run
). - #core ⇒ RSpec::Core::Runner protected
-
#failure? ⇒ Boolean
(also: #failed?)
included
from Concern::Cli
Denote execution is a failure.
- #mutable_attributes ⇒ Object
- #options_arguments ⇒ Array<String> protected
-
#reset ⇒ self
protected
Reset arguments + retcode.
-
#retcode ⇒ Fixnum
included
from Concern::Cli
Status code usable to eventually initiates the termination.
- #run ⇒ self
- #setup ⇒ Object protected
-
#success? ⇒ Boolean
(also: #successful?)
included
from Concern::Cli
Denote execution is a success.
-
#with_exit_on_failure {|Object| ... } ⇒ Object
included
from Concern::Cli::WithExitOnFailure
protected
Initiates termination by raising
SystemExit
exception depending onsuccess
of given block.
Constructor Details
This class inherits a constructor from Kamaze::Project::Tools::BaseTool
Instance Attribute Details
#defaults ⇒ Arguments
Default arguments used by RSpec::Core::Runner
32 33 34 |
# File 'lib/kamaze/project/tools/rspec.rb', line 32 def defaults @defaults end |
#observer_peers ⇒ Hash|nil (readonly, protected) Originally defined in module Concern::Observable
#stderr ⇒ Object
Returns the value of attribute stderr.
36 37 38 |
# File 'lib/kamaze/project/tools/rspec.rb', line 36 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
34 35 36 |
# File 'lib/kamaze/project/tools/rspec.rb', line 34 def stdout @stdout end |
#tags ⇒ Array<String>
39 40 41 |
# File 'lib/kamaze/project/tools/rspec.rb', line 39 def @tags end |
Instance Method Details
#arguments ⇒ Arguments
Arguments used by CLI
(during execution/run
)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/kamaze/project/tools/rspec.rb', line 61 def arguments @arguments = @defaults if @arguments.to_a.size.zero? .to_a.each do |tag| next if @arguments.slice_before('--tag').to_a.include?(['--tag', tag]) @arguments += ['--tag', tag] end { true => @arguments, false => @arguments.clone.concat().map(&:to_s).freeze }.fetch(caller_locations(1..1).first.path == __FILE__) end |
#core ⇒ RSpec::Core::Runner (protected)
98 99 100 101 102 |
# File 'lib/kamaze/project/tools/rspec.rb', line 98 def core require 'rspec/core' RSpec::Core::Runner end |
#failure? ⇒ Boolean Also known as: failed? Originally defined in module Concern::Cli
Denote execution is a failure.
#mutable_attributes ⇒ Object
41 42 43 |
# File 'lib/kamaze/project/tools/rspec.rb', line 41 def mutable_attributes [:defaults, :stdout, :stderr] end |
#options_arguments ⇒ Array<String> (protected)
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/kamaze/project/tools/rspec.rb', line 105 def = Pathname.new(Dir.pwd).join('.rspec') defaults = [] if .file? and .readable? defaults += ['-O', '.rspec'] end defaults end |
#reset ⇒ self (protected)
Reset arguments + retcode
81 82 83 84 85 86 |
# File 'lib/kamaze/project/tools/rspec.rb', line 81 def reset @arguments = nil self.retcode = nil if retcode.to_i.zero? self end |
#retcode ⇒ Fixnum Originally defined in module Concern::Cli
Status code usable to eventually initiates the termination.
#run ⇒ self
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kamaze/project/tools/rspec.rb', line 47 def run with_exit_on_failure do = arguments.concat().map(&:to_s) self.retcode = core.run(, stderr, stdout).to_i reset end self end |
#setup ⇒ Object (protected)
88 89 90 91 92 93 94 95 |
# File 'lib/kamaze/project/tools/rspec.rb', line 88 def setup reset @tags = [] @stdout ||= $stdout @stderr ||= $stderr @defaults ||= [] end |
#success? ⇒ Boolean Also known as: successful? Originally defined in module Concern::Cli
Denote execution is a success.
#with_exit_on_failure {|Object| ... } ⇒ Object (protected) Originally defined in module Concern::Cli::WithExitOnFailure
Initiates termination by raising SystemExit
exception
depending on success
of given block.