Module: Workarea::TestCase::RunnerLocation

Instance Method Summary collapse

Instance Method Details

#running_from_source?Boolean

Returns:

  • (Boolean)


92
93
94
95
96
97
98
99
100
101
# File 'lib/workarea/test_case.rb', line 92

def running_from_source?
  return false unless running_in_dummy_app?

  calling_test = caller.detect do |path|
    /_test\.(rb|#{Rails::Decorators.extension})/.match?(path)
  end

  Rails.root.to_s.include?('test/dummy') &&
    Rails.root.to_s.split('/test/').first.eql?(calling_test.split('/test/').first)
end

#running_in_dummy_app?Boolean

Returns:

  • (Boolean)


116
117
118
119
# File 'lib/workarea/test_case.rb', line 116

def running_in_dummy_app?
  return @running_in_dummy_app if defined?(@running_in_dummy_app)
  @running_in_dummy_app = Rails.root.to_s.include?('test/dummy')
end

#running_in_gem?Boolean

TODO remove in v3.6

Returns:

  • (Boolean)


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/workarea/test_case.rb', line 104

def running_in_gem?
  Workarea.deprecation.warn(
    <<~eos.squish
      running_in_gem? is deprecated, use running_from_dummy_app? if
      you want to know if the test suite is running from a plugin or
      running_from_source? if you want to know if the currently executing test
      is defined in the current Rails project.
    eos
  )
  running_from_source?
end