Sha256: 78f28a52527f8809b8793e7cda21def4b52aa9b9be42dca4458aadf55d27bd5a

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

# encoding: utf-8
require 'quandl/operation/qdformat'
require 'spec_helper'

describe Quandl::Operation::QDFormat do
  
  let(:qdf_dataset){
    %Q{
      # YAML metadata
      code:           DATASET_CODE
      source_code:    SOURCE_CODE
      name:           Test Dataset Name 1
      description:    Here is a description with multiple lines.\\n This is the second line.
      # CSV data
      Date, Value, High, Low
      2013-11-20,9.99470588235294,11.003235294117646,14.00164705882353
      2013-11-19,10.039388096885814,,14.09718770934256
      
      # Second dataset
      code:           DATASET_CODE_2
      source_code:    SOURCE_CODE_2
      name:           Test Dataset Name 2
      description:    Here is a description with multiple lines.
      # CSV data
      Date, Value, High, Low
      2013-11-20,9.99470588235294,11.003235294117646,14.00164705882353
      2013-11-19,10.039388096885814,,14.09718770934256
      2013-11-18,11.039388096885814,,15.09718770934256
    }
  }
  
  let(:collection){ Quandl::Operation::QDFormat.load(qdf_dataset) }
  
  describe ".load" do
    
    subject{ collection }
    
    its(:count){ should eq 2 }
    
    describe "#first" do
      subject{ collection.first }

      it{ should be_a Quandl::Operation::QDFormat::Node }
      its(:source_code){ should eq 'SOURCE_CODE' }
      its(:code){ should eq 'DATASET_CODE' }
      its(:name){ should eq 'Test Dataset Name 1' }
      its(:description){ should eq 'Here is a description with multiple lines.\n This is the second line.' }
      its(:column_names){ should eq ['Date', 'Value', 'High', 'Low'] }
      its(:data){ should eq [
        ["2013-11-20", "9.99470588235294", "11.003235294117646", "14.00164705882353"], 
        ["2013-11-19", "10.039388096885814", nil, "14.09718770934256"]] }
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quandl_operation-0.1.20 spec/lib/quandl/operation/qdformat_spec.rb