Class: LearnLab::Test::Strategies::Rspec

Inherits:
LearnLab::Test::Strategy show all
Defined in:
lib/learn_lab/test/strategies/rspec.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from LearnLab::Test::Strategy

#fs, #options, #out, #runner

Instance Method Summary collapse

Methods inherited from LearnLab::Test::Strategy

#check_dependencies, #cleanup, #initialize, #output, #result_filename, #results

Constructor Details

This class inherits a constructor from LearnLab::Test::Strategy

Instance Method Details

#detectObject

[View source]

11
12
13
14
15
16
# 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

#parserObject

[View source]

27
28
29
# File 'lib/learn_lab/test/strategies/rspec.rb', line 27

def parser
  @parser ||= LearnLab::Test::Parsers::Rspec.new(output)
end

#runObject

[View source]

18
19
20
21
22
23
24
25
# 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