Sha256: 87f4764c55e4c8177a4908a154b142fd384dbb652d56f6062d6f352dc6d621df

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

require 'gooddata'

describe "Spin a project", :constraint => 'slow' do

  before(:all) do
    spec = JSON.parse(File.read("./spec/test_project_model_spec.json"), :symbolize_names => true)
    GoodData.connect("svarovsky+gem_tester@gooddata.com", "jindrisska")
    GoodData.logging_on

    @project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => "INTNA000000GDPM"})
  end

  after(:all) do
    @project.delete unless @project.nil?
  end

  it "should compute a metric" do
    GoodData.with_project(@project) do |p|
      f = GoodData::Fact.find_first_by_title('Lines changed')
      metric = GoodData::Metric.xcreate("SELECT SUM(#\"#{f.title}\")")
      metric.execute.should == 9
    end
  end

  it "should execute an anonymous metric twice and not fail" do
    GoodData.with_project(@project) do |p|
      f = GoodData::Fact.find_first_by_title('Lines changed')
      metric = GoodData::Metric.xcreate("SELECT SUM(#\"#{f.title}\")")
      metric.execute.should == 9
      # Since GD platform cannot execute inline specified metric the metric has to be saved
      # The code tries to resolve this as transparently as possible
      metric.execute.should == 9
    end
  end

  it "should compute a report" do
    GoodData.with_project(@project) do |p|
      f = GoodData::Fact.find_first_by_title('Lines changed')
      metric = GoodData::Metric.xcreate(:title => "My metric", :expression => "SELECT SUM(#\"#{f.title}\")")
      metric.save

      result = GoodData::ReportDefinition.execute(:title => "My report", :top => [metric], :left => ['label.devs.email'])
      result[1][1].should == 3
      result.include_row?(["jirka@gooddata.com", 5]).should == true
    end
  end

  it "should contain metadata for each dataset in project metadata" do
    GoodData.with_project(@project) do |p|
      k = GoodData::ProjectMetadata.keys
      k.should include("manifest_devs")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre8 spec/full_project_spec.rb
gooddata-0.6.0.pre7 spec/full_project_spec.rb