Class: RailsInfo::Logs::Test::RspecPresenter

Inherits:
Presenter
  • Object
show all
Defined in:
app/presenters/rails_info/logs/test/rspec_presenter.rb

Instance Method Summary collapse

Methods inherited from Presenter

#subject=

Constructor Details

#initialize(subject, options = {}) ⇒ RspecPresenter

Returns a new instance of RspecPresenter.



2
3
4
5
6
7
8
# File 'app/presenters/rails_info/logs/test/rspec_presenter.rb', line 2

def initialize(subject, options = {})
  super(subject, options)
  
  @rails_info_log = ::RailsInfo::Logs::Test::Rspec.new(
    log: options[:log], debug: options[:debug]
  )
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsInfo::Presenter

Instance Method Details

#accordionObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/presenters/rails_info/logs/test/rspec_presenter.rb', line 17

def accordion
  @index = 0
  
  if @rails_info_log.hash.is_a?(Hash)
     :div, id: 'files', class: 'accordions' do
      html = ''
    
      @rails_info_log.hash.each do |file, examples|
        file_presenter = ::RailsInfo::Logs::Test::Rspec::FilePresenter.new(
          @subject, name: "#{file} (#{examples.length})", 
          tabs_data: examples, index: @index, rails_root: @rails_info_log.rails_root
        )
        @index += 1
        html += raw file_presenter.tabs
      end  
      
      raw html
    end  
  else
     :pre, @rails_info_log.hash.join("\n")
  end
end

#summaryObject



10
11
12
13
14
15
# File 'app/presenters/rails_info/logs/test/rspec_presenter.rb', line 10

def summary
  text = ["#{@rails_info_log.number_of_files} files"]
  text << @rails_info_log.summary unless @rails_info_log.summary.blank?
  
   :p, text.join(', ')
end