Top Level Namespace
Defined Under Namespace
Modules: ApplicationFixtureHelper, PackageProtections, RuboCop
Instance Method Summary
collapse
Instance Method Details
#get_resulting_rubocop ⇒ Object
8
9
10
11
12
13
|
# File 'lib/package_protections/rspec/support.rb', line 8
def get_resulting_rubocop
write_file('config/default.yml', " <%= PackageProtections.rubocop_yml(root_pathname: Pathname.pwd) %>\n YML\n YAML.safe_load(ERB.new(File.read('config/default.yml')).result(binding))\nend\n".strip)
|
#offense(package_name, message, file, violation_type) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
|
# File 'lib/package_protections/rspec/matchers.rb', line 1
def offense(
package_name, message, file, violation_type
)
package = ParsePackwerk.all.find { |p| p.name == package_name }
PackageProtections::Offense.new(
package: package,
message: message,
file: file,
violation_type: violation_type
)
end
|
#serialize_offenses(actual_offenses) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/package_protections/rspec/matchers.rb', line 28
def serialize_offenses(actual_offenses)
actual_offenses.map do |offense|
" File: \#{offense.file}\n Message: \#{offense.message}\n Violation Type: \#{offense.violation_type}\n Package: \#{offense.package.name}\n SERIALIZED_OFFENSE\n end\nend\n"
|
#serialize_offenses_diff(actual_offenses, expected_offense) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/package_protections/rspec/matchers.rb', line 14
def serialize_offenses_diff(actual_offenses, expected_offense)
color_by_match = ->(actual, expected) { actual == expected ? Rainbow(actual).green : "#{Rainbow(actual).red} (expected: #{expected})" }
actual_offenses.map do |offense|
" File: \#{color_by_match.call(offense.file, expected_offense.file)}\n Message: \#{color_by_match.call(offense.message, expected_offense.message)}\n Violation Type: \#{color_by_match.call(offense.violation_type, expected_offense.violation_type)}\n Package: \#{color_by_match.call(offense.package.name, expected_offense.package.name)}\n SERIALIZED_OFFENSE\n end\nend\n"
|