Sha256: 73e06584e5bc2b89570af7c2e581e8206d453647eebab1c31218e0417fd93d9c

Contents?: true

Size: 754 Bytes

Versions: 4

Compression:

Stored size: 754 Bytes

Contents

require File.join(File.dirname(__FILE__), "/../spec_helper")

describe DataFrame, "model" do
  before do
    @csv = %{a,b,c
1,2,3
2,2,2
4,5,6}
    @df = DataFrame.from_csv(@csv)
  end
  
  it "should be able to define a model with a block" do
    @df.model(:b2) do |m|
      m.b 2
    end
    
    @df.models.table.keys.should eql([:b2])
    @df.models.b2.size.should eql(2)
    @df.models.b2.b.should eql([2,2])
  end
  
  it "should be able to define a model with a range of values" do
    @df.model(:a12) do |m|
      m.a (1..2)
    end
    @df.models.a12.a.should eql([1,2])
  end
  
  it "should be able to define a model with a set of values" do
    @df.model(:a14) do |m|
      m.a [1,4]
    end
    @df.models.a14.a.should eql([1,4])
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
davidrichards-data_frame-0.0.17 spec/data_frame/model_spec.rb
davidrichards-data_frame-0.0.18 spec/data_frame/model_spec.rb
davidrichards-data_frame-0.0.19 spec/data_frame/model_spec.rb
davidrichards-data_frame-0.0.20 spec/data_frame/model_spec.rb