Class: Ruber::RSpec::FilterModel

Inherits:
FilteredOutputWidget::FilterModel show all
Defined in:
plugins/rspec/rspec.rb,
plugins/rspec/tool_widget.rb

Overview

Filter model used by the RSpec output widget

It allows to choose whether to accept items corresponding to output to standard error or to reject it. To find out if a given item corresponds to the output of standard error or standard output, this model uses the data contained in a custom role in the output. The index of this role is RSpec::OutputWidget::OutputTypeRole.

Instance Attribute Summary (collapse)

Attributes inherited from FilteredOutputWidget::FilterModel

exclude

Instance Method Summary (collapse)

Methods inherited from FilteredOutputWidget::FilterModel

#exclude_from_filtering?, #filter_ignored?, #filter_reg_exp=, #ignore_filter=

Methods inherited from Qt::SortFilterProxyModel

#each

API for feature rspec

Constructor Details

- (FilterModel) initialize(parent = nil)

Create a new instance

The new instance is set not to show the output from standard error

Parameters:

  • parent (Qt::Object, nil) (defaults to: nil)

    the parent object



566
567
568
569
# File 'plugins/rspec/rspec.rb', line 566

def initialize parent = nil
  super
  @display_stderr = false
end

Instance Attribute Details

- (Boolean) display_stderr

Whether output from standard error should be displayed or not

Returns:

  • (Boolean)


557
558
559
# File 'plugins/rspec/rspec.rb', line 557

def display_stderr
  @display_stderr
end

Instance Method Details

- (Boolean) filterAcceptsRow(r, parent)

Override of FilteredOutputWidget::FilterModel#filterAcceptsRow

According to the value of #display_stderr, it can filter out items corresponding to standard error. In all other respects, it behaves as the base class method.

Parameters:

  • r (Integer)

    the row number

  • parent (Qt::ModelIndex)

    the parent index

Returns:

  • (Boolean)

    true if the row should be displayed and false otherwise



595
596
597
598
599
600
601
# File 'plugins/rspec/rspec.rb', line 595

def filterAcceptsRow r, parent
  if !@display_stderr
    idx = source_model.index(r,0,parent)
    return false if idx.data(OutputWidget::OutputTypeRole).to_string == 'output1'
  end
  super
end