-
Notifications
You must be signed in to change notification settings - Fork 22
/
test_helper.rb
51 lines (42 loc) · 1.31 KB
/
test_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
srcdir = File.expand_path("../../src", __FILE__)
y2dirs = ENV.fetch("Y2DIR", "").split(":")
ENV["Y2DIR"] = y2dirs.unshift(srcdir).join(":")
# force English locale to avoid failing tests due to translations
# when running in non-English environment
ENV["LC_ALL"] = "en_US.UTF-8"
require "yast"
require "yast/rspec"
require "pathname"
TESTS_PATH = Pathname.new(File.dirname(__FILE__))
FIXTURES_PATH = TESTS_PATH.join("data")
RSpec.configure do |config|
config.extend Yast::I18n # available in context/describe
config.include Yast::I18n # available in it/let/before/...
end
# stub module to prevent its Import
# Useful for modules from different yast packages, to avoid build dependencies
def stub_module(name)
Yast.const_set name.to_sym, Class.new { def self.fake_method; end }
end
stub_module("Language")
stub_module("Proxy")
stub_module("FTP")
stub_module("HTTP")
stub_module("NtpClient")
stub_module("InstFunctions")
if ENV["COVERAGE"]
require "simplecov"
SimpleCov.start do
add_filter "/test/"
end
# track all ruby files under src
SimpleCov.track_files("#{srcdir}/**/*.rb")
# use coveralls for on-line code coverage reporting at Travis CI
if ENV["TRAVIS"]
require "coveralls"
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
end
end