Class: MountainBerryFields::Test::RSpec

Inherits:
Object
  • Object
show all
Includes:
Strategy
Defined in:
lib/mountain_berry_fields/test/rspec.rb,
lib/mountain_berry_fields/test/rspec_formatter.rb

Defined Under Namespace

Classes: Formatter

Instance Method Summary collapse

Instance Method Details

#failure_messageObject



43
44
45
46
47
48
49
50
# File 'lib/mountain_berry_fields/test/rspec.rb', line 43

def failure_message
  syntax_error_message ||
    "#{spec_failure_description.chomp}:\n"      \
    "  #{spec_failure_message.chomp}\n"         \
    "\n"                                        \
    "backtrace:\n"                              \
    "  #{spec_failure_backtrace.join "\n  "}\n"
end

#pass?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mountain_berry_fields/test/rspec.rb', line 23

def pass?
  @passed ||= syntax_checker.valid? && begin
    dir_class.mktmpdir 'mountain_berry_fields_rspec' do |dir|
      @tempdir_name = dir
      file_class.write "#{dir}/spec.rb", @code_to_test
      @output, @error, status = open3_class.capture3 "rspec '#{dir}/spec.rb' " \
                                                     "-r '#{formatter_filename}' " \
                                                     "-f MountainBerryFields::Test::RSpec::Formatter " \
                                                     "--fail-fast"
      status.success?
    end
  end
  @passed
end

#syntax_checkerObject



15
16
17
# File 'lib/mountain_berry_fields/test/rspec.rb', line 15

def syntax_checker
  @syntax_checker ||= syntax_checker_class.new code_to_test
end

#syntax_error_messageObject



38
39
40
41
# File 'lib/mountain_berry_fields/test/rspec.rb', line 38

def syntax_error_message
  return if syntax_checker.valid?
  syntax_checker.invalid_message
end