rspec-compliance_table 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c6887f23438db74cdecd4fcbbe32f79215f189ac74ca2d378758b944ee35ef
4
- data.tar.gz: 55bc282613425512b2cf0340083d804e9064de328b1094fa6892f6f54faf1956
3
+ metadata.gz: 90750874c85953a18b4a5d3c5214100fce700c235afb6be8b79ba194f46caa08
4
+ data.tar.gz: eddd6559b4d0abb2cdb8588f8059edf21f179580b45bad99bd82cd74d78087d8
5
5
  SHA512:
6
- metadata.gz: 5a7fb736049b972a399740a89df656a49f180ff7908d6d9bc4683548db6f4d4ad5228e7219162ce3eee257e064e0c5de845b2fcd83eb4c155bfae549e57b22a3
7
- data.tar.gz: '098962bf3818fe5f4685fb059dd3cd651ba62988c32fd74c66f0d7c43d6d76833a77e1e2de8e4d71cdf321c03233c3adf15bd2f3c596d83b89cb4f18f4897ecd'
6
+ metadata.gz: e13b3913f917d8b5a569b117b5919e729f880b6afd83d97b46bf6bd7f185a262cfe09628d0a1494efd07e4c1c287c81545c6f8a1a807a8e45cb0a7afca51714b
7
+ data.tar.gz: b35cdfe77124c98c06253124c70793cfd1c6a6942a0ec91a0b6ec2929156d15a85e99dbc229a0c5115e24ca723facc6f897ecc2048b38c4ad853fa26b50dd8d1
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-compliance_table (0.1.0)
5
- activesupport (~> 6.0)
4
+ rspec-compliance_table (0.1.5)
5
+ activesupport (>= 4.0.0)
6
6
  pastel (~> 0.7)
7
7
  terminal-table (~> 1.8)
8
8
 
@@ -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 = 'yes'
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( expected_table, actions, scenarios, compliance, record_name)
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
- return if (actions.map(&:to_s) & existing_actions).length == existing_actions.length
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
- must_break = true && actual_table[scenario][action] = "#{expected_table[scenario][action].to_s.upcase}*"
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rspec
4
4
  module ComplianceTable
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
7
7
  end
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.5
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-01-06 00:00:00.000000000 Z
11
+ date: 2020-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport