Class: ViewSpec::Spec

Inherits:
Entry
  • Object
show all
Defined in:
lib/view_spec/spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#method_missing, #respond_to_missing?, #short_identifier, #spec, #title, #to_partial_path, type

Constructor Details

#initialize(source_file, subject, &block) ⇒ Spec

Returns a new instance of Spec.



5
6
7
8
9
# File 'lib/view_spec/spec.rb', line 5

def initialize(source_file, subject, &block)
  @source_file = source_file

  super(subject, nil, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewSpec::Entry

Instance Attribute Details

#source_fileObject (readonly)

Returns the value of attribute source_file.



3
4
5
# File 'lib/view_spec/spec.rb', line 3

def source_file
  @source_file
end

#subjectObject (readonly)

Returns the value of attribute subject.



3
4
5
# File 'lib/view_spec/spec.rb', line 3

def subject
  @subject
end

Instance Method Details

#lookup_pathObject



11
12
13
14
15
16
17
# File 'lib/view_spec/spec.rb', line 11

def lookup_path
  if @source_file.spec_file?
    @source_file.lookup_path
  else
    short_identifier
  end
end

#previews?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/view_spec/spec.rb', line 23

def previews?
  scenarios(flatten: true).select { _1.preview? }.any?
end

#to_paramObject



19
20
21
# File 'lib/view_spec/spec.rb', line 19

def to_param
  lookup_path
end