Sha256: bdd59444cdb2d514c1b81f67683b1164e88debb20522fd2cfdf7dde9279c0185

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require "spec_helper"

describe Table do

  context 'rows_with' do

    specify 'can select rows based on an optimized key (metric)' do
      table = Table.new(:column_names => %w{foo metric})
      table << {'metric' => 'flay', 'foo' => 1}
      table << {'metric' => 'flay', 'foo' => 2}
      table << {'metric' => 'flog', 'foo' => 1}
      table << {'metric' => 'saikuro', 'foo' => 2}
      matching_rows = table.rows_with(:metric => 'flay')
      matching_rows.length.should == 2
      matching_rows.each do |row|
        row.metric.should == 'flay'
      end
    end

    specify 'can select on arbitrary (non-optimized) field' do
      table = Table.new(:column_names => %w{foo baz})
      table << {'baz' => 'str1', 'foo' => 1}
      table << {'baz' => 'str2', 'foo' => 2}
      table << {'baz' => 'str3', 'foo' => 1}
      table << {'baz' => 'str4', 'foo' => 3}
      matching_rows = table.rows_with(:foo => 1)
      matching_rows.length.should == 2
      matching_rows.each do |row|
        row.foo.should == 1
      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
metric_fu-4.4.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.3.1 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.3.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.2.1 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.2.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.1.3 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.1.2 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.1.1 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.1.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-4.0.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-3.0.1 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-3.0.0 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-2.1.4.pre5 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-2.1.4.pre4 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-2.1.4.pre2 spec/metric_fu/metrics/hotspots/analysis/table_spec.rb
metric_fu-2.1.4.pre spec/metric_fu/metrics/hotspots/analysis/table_spec.rb