Module: Ast::Merge::RSpec::ConformanceFixtures

Defined in:
lib/ast/merge/rspec/conformance_fixtures.rb

Class Method Summary collapse

Class Method Details

.apply_conformance_fixture_support!(support) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/ast/merge/rspec/conformance_fixtures.rb', line 46

def apply_conformance_fixture_support!(support)
   = normalize_conformance_fixture_support(support)
  return unless 

  message = [:reason] || "conformance fixture marked #{[:status]}"
  [:status] == 'pending' ? pending(message) : skip(message)
end

.normalize_conformance_fixture_support(value = nil, default_status: nil, **keywords) ⇒ Object



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
# File 'lib/ast/merge/rspec/conformance_fixtures.rb', line 9

def normalize_conformance_fixture_support(value = nil, default_status: nil, **keywords)
  value = keywords unless keywords.empty?

  case value
  when nil, false
    nil
  when true
    { status: (default_status || 'pending').to_s }
  when String, Symbol
    { status: (default_status || value).to_s }
  when Hash
    support = value[:support] || value['support'] || value
    return nil if support == false

    status = support[:status] || support['status'] || support[:state] || support['state']
    status ||= 'unsupported' if support[:unsupported] || support['unsupported']
    status ||= 'pending' if support[:pending] || support['pending']
    status ||= default_status
    return nil unless %w[pending unsupported skipped].include?(status.to_s)

     = { status: status.to_s }
    reason = support[:reason] || support['reason'] ||
             support[:message] || support['message'] ||
             support[:unsupported_reason] || support['unsupported_reason'] ||
             support[:pending_reason] || support['pending_reason']
    [:reason] = reason if reason
    [:category] = support[:category] || support['category'] if support[:category] || support['category']
    
  end
end

.support_for_conformance_fixture(role, pending_roles: nil, unsupported_roles: nil, fixture: nil) ⇒ Object



40
41
42
43
44
# File 'lib/ast/merge/rspec/conformance_fixtures.rb', line 40

def support_for_conformance_fixture(role, pending_roles: nil, unsupported_roles: nil, fixture: nil)
  role_support(pending_roles, role, default_status: 'pending') ||
    role_support(unsupported_roles, role, default_status: 'unsupported') ||
    normalize_conformance_fixture_support(fixture)
end