Sha256: 0fe12a59c51ccbe02e248a6d00cecad4763e6ae602def25c2216e6a263cb6671

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

include RR

describe TableScanHelper do
  before(:each) do
    @scan = Object.new
    @scan.extend TableScanHelper
  end

  it "rank_rows should calculate the correct rank of rows based on their primary keys" do
    @scan.stub!(:primary_key_names).and_return(['first_id', 'second_id'])
    @scan.rank_rows({'first_id' => 1, 'second_id' => 1}, {'first_id' => 1, 'second_id' => 1}).should == 0
    @scan.rank_rows({'first_id' => 1, 'second_id' => 1}, {'first_id' => 1, 'second_id' => 2}).should == -1
    @scan.rank_rows({'first_id' => 2, 'second_id' => 1}, {'first_id' => 1, 'second_id' => 1}).should == 1
    lambda {@scan.rank_rows(nil,nil)}.should raise_error(RuntimeError, 'At least one of left_row and right_row must not be nil!')
    @scan.rank_rows(nil, {'first_id' => 1, 'second_id' => 1}).should == 1
    @scan.rank_rows({'first_id' => 1, 'second_id' => 1}, nil).should == -1
  end

  it "table_scan_class should return TableScan for non-proxied sessions" do
    TableScanHelper.scan_class(Session.new(standard_config)).should == DirectTableScan
  end

  it "table_scan_class should return ProxiedTableScan for proxied sessions" do
    ensure_proxy
    TableScanHelper.scan_class(Session.new(proxied_config)).should == ProxiedTableScan
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubyrep-1.1.2 spec/table_scan_helper_spec.rb
rubyrep-1.1.1 spec/table_scan_helper_spec.rb
rubyrep-1.1.0 spec/table_scan_helper_spec.rb
rubyrep-1.0.9 spec/table_scan_helper_spec.rb
rubyrep-1.0.8 spec/table_scan_helper_spec.rb
rubyrep-1.0.3 spec/table_scan_helper_spec.rb
rubyrep-1.0.4 spec/table_scan_helper_spec.rb
rubyrep-1.0.5 spec/table_scan_helper_spec.rb
rubyrep-1.0.6 spec/table_scan_helper_spec.rb
rubyrep-1.0.7 spec/table_scan_helper_spec.rb
rubyrep-1.0.0 spec/table_scan_helper_spec.rb
rubyrep-1.0.1 spec/table_scan_helper_spec.rb
rubyrep-1.0.2 spec/table_scan_helper_spec.rb