rspec-compliance_table 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/rspec/compliance_table.rb +14 -9
- data/lib/rspec/compliance_table/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90750874c85953a18b4a5d3c5214100fce700c235afb6be8b79ba194f46caa08
|
|
4
|
+
data.tar.gz: eddd6559b4d0abb2cdb8588f8059edf21f179580b45bad99bd82cd74d78087d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e13b3913f917d8b5a569b117b5919e729f880b6afd83d97b46bf6bd7f185a262cfe09628d0a1494efd07e4c1c287c81545c6f8a1a807a8e45cb0a7afca51714b
|
|
7
|
+
data.tar.gz: b35cdfe77124c98c06253124c70793cfd1c6a6942a0ec91a0b6ec2929156d15a85e99dbc229a0c5115e24ca723facc6f897ecc2048b38c4ad853fa26b50dd8d1
|
data/Gemfile.lock
CHANGED
|
@@ -10,23 +10,24 @@ require 'rspec/compliance_table/version'
|
|
|
10
10
|
require 'active_support/core_ext/object/blank'
|
|
11
11
|
require 'active_support/core_ext/array/access'
|
|
12
12
|
|
|
13
|
+
# rubocop:disable all
|
|
13
14
|
module RSpec
|
|
14
15
|
# Adds `compliance_for`
|
|
15
16
|
# as a RSpec custom example
|
|
16
17
|
module ComplianceTable
|
|
17
|
-
COMPLIANCE_TOKEN = '
|
|
18
|
+
COMPLIANCE_TOKEN = 'yay'
|
|
18
19
|
SCENARIO_HEADER_TOKEN = 'scenario'
|
|
19
20
|
|
|
20
21
|
class MissingAction < StandardError; end
|
|
21
22
|
|
|
22
|
-
def compliance_for(record_name, table)
|
|
23
|
+
def compliance_for(record_name, table, options = {})
|
|
23
24
|
table = prepare_table(table)
|
|
24
25
|
|
|
25
26
|
actions = actions(table)
|
|
26
27
|
scenarios = scenarios(table)
|
|
27
28
|
compliance = compliance(table)
|
|
28
29
|
|
|
29
|
-
raise_if_missing_permission(actions)
|
|
30
|
+
raise_if_missing_permission(actions, options)
|
|
30
31
|
|
|
31
32
|
expected_table = {}.tap do |parsed_table|
|
|
32
33
|
actions.each_with_index do |act, act_index|
|
|
@@ -37,7 +38,7 @@ module RSpec
|
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
run_compliance_matchers(
|
|
41
|
+
run_compliance_matchers(expected_table, actions, scenarios, compliance, record_name)
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
private
|
|
@@ -58,9 +59,14 @@ module RSpec
|
|
|
58
59
|
table.split("\n").reject(&:blank?)
|
|
59
60
|
end
|
|
60
61
|
|
|
61
|
-
def raise_if_missing_permission(actions)
|
|
62
|
+
def raise_if_missing_permission(actions, options)
|
|
63
|
+
options[:ignore] ||= []
|
|
64
|
+
|
|
62
65
|
existing_actions = described_class.instance_methods(false).map(&:to_s)
|
|
63
|
-
|
|
66
|
+
|
|
67
|
+
if (actions.map(&:to_s) & existing_actions).length == (existing_actions - options[:ignore].map(&:to_s)).length
|
|
68
|
+
return
|
|
69
|
+
end
|
|
64
70
|
|
|
65
71
|
raise MissingAction, "The compliance table provided doesn't have every possible action for this permission"
|
|
66
72
|
end
|
|
@@ -69,8 +75,6 @@ module RSpec
|
|
|
69
75
|
actual_table = {}
|
|
70
76
|
|
|
71
77
|
example do
|
|
72
|
-
must_break = false
|
|
73
|
-
|
|
74
78
|
scenarios.each do |scenario|
|
|
75
79
|
send(record_name).reload
|
|
76
80
|
permission = described_class.new(send(scenario), send(record_name))
|
|
@@ -80,7 +84,7 @@ module RSpec
|
|
|
80
84
|
actual_table[scenario][action] = permission.send(action)
|
|
81
85
|
|
|
82
86
|
if actual_table[scenario][action] != expected_table[scenario][action]
|
|
83
|
-
|
|
87
|
+
actual_table[scenario][action] = "#{expected_table[scenario][action].to_s.upcase}*"
|
|
84
88
|
end
|
|
85
89
|
end
|
|
86
90
|
end
|
|
@@ -122,3 +126,4 @@ RSpec::Matchers.define :be_compliant do |_expected|
|
|
|
122
126
|
end
|
|
123
127
|
|
|
124
128
|
RSpec::SharedContext.include RSpec::ComplianceTable
|
|
129
|
+
# rubocop:enable all
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-compliance_table
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luis Vasconcellos
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-04-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|