class LearnLab::Test::Strategies::Rspec

Test Strategy for RSpec. Mostly lifted from the `learn-test` gem without Ironboard specific code. Some other refactorings were also made to improve test coverage and fix Rubocop warnings.

Public Instance Methods

detect() click to toggle source
# File lib/learn_lab/test/strategies/rspec.rb, line 11
def detect
  spec_dir = fs.join(runner.working_directory, 'spec')
  fs.dir_exist?(spec_dir) && \
    (fs.dir_entries(spec_dir).include?('spec_helper.rb') || \
     fs.dir_entries(spec_dir).include?('rails_helper.rb'))
end
parser() click to toggle source
# File lib/learn_lab/test/strategies/rspec.rb, line 27
def parser
  @parser ||= LearnLab::Test::Parsers::Rspec.new(output)
end
run() click to toggle source
# File lib/learn_lab/test/strategies/rspec.rb, line 18
def run
  command_options = [
    '--format documentation',
    '--format j',
    "--out #{result_filename}"
  ]
  system("#{bundle_command}rspec #{command_options.join(' ')}")
end

Private Instance Methods

bundle_command() click to toggle source
# File lib/learn_lab/test/strategies/rspec.rb, line 33
def bundle_command
  bundler? ? 'bundle exec ' : ''
end
bundler?() click to toggle source
# File lib/learn_lab/test/strategies/rspec.rb, line 37
def bundler?
  fs.file_exist?('Gemfile') && \
    !!fs.read_file('Gemfile').match(/^\s*gem\s*('|")rspec(-[^'"]+)?('|").*$/)
end