Class: Rdm::SpecRunner::CommandGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/spec_runner/command_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_name:, package_path:, spec_matcher:, show_output: true) ⇒ CommandGenerator

Returns a new instance of CommandGenerator.



3
4
5
6
7
8
# File 'lib/rdm/spec_runner/command_generator.rb', line 3

def initialize(package_name:, package_path:, spec_matcher:, show_output: true)
  @package_name = package_name
  @package_path = package_path
  @spec_matcher = spec_matcher
  @output       = show_output ? '$stdout' : 'File::NULL'
end

Instance Attribute Details

#package_nameObject

Returns the value of attribute package_name.



2
3
4
# File 'lib/rdm/spec_runner/command_generator.rb', line 2

def package_name
  @package_name
end

#package_pathObject

Returns the value of attribute package_path.



2
3
4
# File 'lib/rdm/spec_runner/command_generator.rb', line 2

def package_path
  @package_path
end

#spec_matcherObject

Returns the value of attribute spec_matcher.



2
3
4
# File 'lib/rdm/spec_runner/command_generator.rb', line 2

def spec_matcher
  @spec_matcher
end

Instance Method Details

#commandObject



14
15
16
17
18
19
# File 'lib/rdm/spec_runner/command_generator.rb', line 14

def command
  "print_message(
      '**** Package: #{package_name}  *****') \\
        && system('cd #{package_path} \\
        && bundle exec rspec --color --tty #{spec_matcher}', out: #{@output.to_s}, err: :out)"
end

#generateObject



21
22
23
24
25
26
27
28
# File 'lib/rdm/spec_runner/command_generator.rb', line 21

def generate
  Rdm::SpecRunner::CommandParams.new.tap do |cp|
    cp.package_name = package_name
    cp.package_path = package_path
    cp.command      = command
    cp.spec_count   = spec_count
  end
end

#spec_countObject



10
11
12
# File 'lib/rdm/spec_runner/command_generator.rb', line 10

def spec_count
  Dir[File.join(package_path, 'spec/**/*_spec.rb')].size
end