Class: RuboCop::RSpec::Hook

Inherits:
Concept
  • Object
show all
Defined in:
lib/rubocop/rspec/hook.rb

Overview

Wrapper for RSpec hook

Constant Summary

Constants included from Language

Language::ALL

Instance Method Summary collapse

Methods inherited from Concept

#eql?, #hash, #initialize, #to_node

Constructor Details

This class inherits a constructor from RuboCop::RSpec::Concept

Instance Method Details

#example?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rubocop/rspec/hook.rb', line 24

def example?
  scope.equal?(:each)
end

#knowable_scope?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/rubocop/rspec/hook.rb', line 14

def knowable_scope?
  return true unless scope_argument

  scope_argument.sym_type?
end

#nameObject



10
11
12
# File 'lib/rubocop/rspec/hook.rb', line 10

def name
  node.method_name
end

#scopeObject



28
29
30
31
32
33
34
35
36
# File 'lib/rubocop/rspec/hook.rb', line 28

def scope
  case scope_name
  when nil, :each, :example then :each
  when :context, :all       then :context
  when :suite               then :suite
  else
    scope_name
  end
end

#valid_scope?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rubocop/rspec/hook.rb', line 20

def valid_scope?
  STANDARDIZED_SCOPES.include?(scope)
end