Class: RSpecDocumentation::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_documentation/configuration.rb

Overview

Configures the rspec-documentation gem, allows setting a context that makes values available to each example.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
# File 'lib/rspec_documentation/configuration.rb', line 9

def initialize
  @context_defined = false
  @consistent_height = false
  @max_height = '30rem'
  @fail_fast = false
  @full_backtrace = false
  @table_of_contents = true
  @index_search = true
  @hooks = {}
end

Instance Attribute Details

#consistent_heightObject

Returns the value of attribute consistent_height.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def consistent_height
  @consistent_height
end

#fail_fastObject

Returns the value of attribute fail_fast.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def fail_fast
  @fail_fast
end

#full_backtraceObject

Returns the value of attribute full_backtrace.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def full_backtrace
  @full_backtrace
end

#hooksObject (readonly)

Returns the value of attribute hooks.



6
7
8
# File 'lib/rspec_documentation/configuration.rb', line 6

def hooks
  @hooks
end

#index_searchObject

Returns the value of attribute index_search.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def index_search
  @index_search
end

#max_heightObject

Returns the value of attribute max_height.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def max_height
  @max_height
end

#table_of_contentsObject

Returns the value of attribute table_of_contents.



7
8
9
# File 'lib/rspec_documentation/configuration.rb', line 7

def table_of_contents
  @table_of_contents
end

Instance Method Details

#attributionObject



24
25
26
27
28
29
# File 'lib/rspec_documentation/configuration.rb', line 24

def attribution
  return @attribution if defined?(@attribution)

  'Documentation generated by ' \
    '<a target="_blank" href="https://github.com/bobf/rspec-documentation">rspec-documentation</a>'
end

#context(&block) ⇒ Object

Raises:



31
32
33
34
35
36
# File 'lib/rspec_documentation/configuration.rb', line 31

def context(&block)
  raise Error, 'RSpecDocumentation context has already been defined.' if context_defined?

  @context_defined = true
  ::RSpec.shared_context('__rspec_documentation', &block)
end

#context_defined?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rspec_documentation/configuration.rb', line 20

def context_defined?
  @context_defined
end

#hook(name, &block) ⇒ Object



38
39
40
# File 'lib/rspec_documentation/configuration.rb', line 38

def hook(name, &block)
  hooks[name] = block
end