Sha256: dc74f7d680a52db672849c26b05dd8b8c82caca08bc1773adf33e80d2d0728dc

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

# encoding: UTF-8

require 'gooddata'

describe GoodData::SmallGoodZilla do
  
  MAQL_EXAMPLE = 'SELECT SUM(#"Amount") WHERE @"Date"=#"X" AND ?"Snapshot EOP"=1'
  FACTS = {
    "Amount" => "a",
    "X" => "x"
  }
  ATTRIBUTES = {
    "Date" => "d"
  }
  METRICS = {
    "Snapshot EOP" => "snap"
  }
  DICT = {
    :facts => FACTS,
    :attributes => ATTRIBUTES,
    :metrics => METRICS,
  }
  
  it "should parse metrics out of the string" do
    x = GoodData::SmallGoodZilla.get_facts(MAQL_EXAMPLE)
    x.should == ["Amount", "X"]
  end

  it "should parse attributes out of the string" do
    x = GoodData::SmallGoodZilla.get_attributes(MAQL_EXAMPLE)
    x.should == ["Date"]
  end

  it "should parse metrics out of the string" do
    x = GoodData::SmallGoodZilla.get_metrics(MAQL_EXAMPLE)
    x.should == ["Snapshot EOP"]
  end

  it "should interpolate the values" do
    
    interpolated = GoodData::SmallGoodZilla.interpolate({
      :facts => ["Amount", "X"],
      :attributes => ["Date"],
      :metrics => ["Snapshot EOP"]
    }, DICT)
    
    interpolated.should == {
      :facts => [["Amount", "a"], ["X", "x"]],
      :attributes => [["Date", "d"]],
      :metrics => [["Snapshot EOP", "snap"]]
    }
  end

  it "should return interpolated metric" do
    interpolated = GoodData::SmallGoodZilla.interpolate_metric(MAQL_EXAMPLE, DICT)
    interpolated.should == "SELECT SUM([a]) WHERE [d]=[x] AND [snap]=1"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.3 spec/unit/godzilla/goodzilla_spec.rb
gooddata-0.6.2 spec/unit/godzilla/goodzilla_spec.rb