-
Notifications
You must be signed in to change notification settings - Fork 551
/
defaults_spec.rb
48 lines (39 loc) · 1.43 KB
/
defaults_spec.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
# frozen_string_literal: true
require "helper"
describe SimpleCov do
skip "requires the default configuration" if ENV["SIMPLECOV_NO_DEFAULTS"]
context "profiles" do
let(:config_class) do
Class.new do
include SimpleCov::Configuration
def load_profile(name)
configure(&SimpleCov.profiles[name.to_sym])
end
end
end
let(:config) { config_class.new }
def filtered?(config, filename)
path = File.join(SimpleCov.root, filename)
file = SimpleCov::SourceFile.new(path, [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
config.filters.any? { |filter| filter.matches?(file) }
end
it "provides a sensible test_frameworks profile" do
config.load_profile(:test_frameworks)
expect(filtered?(config, "foo.rb")).not_to be
expect(filtered?(config, "test/foo.rb")).to be
expect(filtered?(config, "spec/bar.rb")).to be
end
it "provides a sensible rails profile" do
config.load_profile(:rails)
expect(filtered?(config, "app/models/user.rb")).not_to be
expect(filtered?(config, "db/schema.rb")).to be
expect(filtered?(config, "config/environment.rb")).to be
end
end
context "exit hook" do
it "uses Minitest if available" do
expect { system RbConfig.ruby, "spec/fixtures/frameworks/minitest.rb" }
.to output(Regexp.new(Regexp.escape("4 / 5 LOC (80.0%) covered"))).to_stdout_from_any_process
end
end
end