Sha256: e1da1c902d44bbb59c04b1416b36a02c83a0829f40251727ca81e93e92f76eef

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Multiset do
  let(:d1){ create(:dataset, data_table: Quandl::Data::Random.table( rows: 10, columns: 4, nils: false ) ) }
  let(:d2){ create(:dataset, data_table: Quandl::Data::Random.table( rows: 10, columns: 4, nils: false ) ) }
  
  it "should retrieve the requested columns" do
    m = Multiset.columns("#{d1.id.to_i}.1,#{d2.id.to_i}.1").to_dataset
    m.data_table[0][1].should eq d1.data_table[0][1]
    m.data_table[0][2].should eq d2.data_table[0][1]
  end
  
  it "should retrieve the requested columns" do
    m = Multiset.columns("#{d2.id.to_i}.2,#{d1.id.to_i}.2").to_dataset
    m.data_table[0][1].should eq d2.data_table[0][2]
    m.data_table[0][2].should eq d1.data_table[0][2]
  end
  
  it "should be in the right order" do
    m = Multiset.columns("#{d2.id.to_i}.1,#{d1.id.to_i}.1,#{d2.id.to_i}.3,#{d1.id.to_i}.2").to_dataset
    m.column_ids.should eq [
      Dataset.find(d2.id).column_ids[0],
      Dataset.find(d1.id).column_ids[0],
      Dataset.find(d2.id).column_ids[2],
      Dataset.find(d1.id).column_ids[1],
    ]
  end
  
  it "should retrieve the requested columns" do
    m = Multiset.columns("#{d2.id.to_i}.1,#{d1.id.to_i}.1,#{d2.id.to_i}.3,#{d1.id.to_i}.2").to_dataset
    m.data_table[0][1].should eq d2.data_table[0][1]
    m.data_table[0][2].should eq d1.data_table[0][1]
    m.data_table[0][3].should eq d2.data_table[0][3]
    m.data_table[0][4].should eq d1.data_table[0][2]
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quandl_cassinatra-0.1.11 spec/quandl/cassinatra/multiset_spec.rb