Sha256: 1c9db2d14975e9a952719f94fd7240bcb187fcc651701539df63469cd2d7749f

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 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 ) ) }
  
  context "given ascending columns" do
    
    it "should return the expected column_ids" do
      [d1, d2]
      sleep 0.2
      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 return the expected columns" do
      [d1, d2]
      sleep 1
      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
  
  context "given descending columns" do
  
    it "should return the expected columns" do
      m = Multiset.columns("#{d1.id.to_i}.2,#{d1.id.to_i}.1").to_dataset
      m.data_table[0][1].should_not eq m.data_table[0][2]
    end
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
quandl_cassinatra-0.2.0 spec/quandl/cassinatra/multiset_spec.rb
quandl_cassinatra-0.1.16 spec/quandl/cassinatra/multiset_spec.rb
quandl_cassinatra-0.1.15 spec/quandl/cassinatra/multiset_spec.rb
quandl_cassinatra-0.1.14 spec/quandl/cassinatra/multiset_spec.rb
quandl_cassinatra-0.1.13 spec/quandl/cassinatra/multiset_spec.rb