Sha256: ea163cb83034c42f598ed2cfcb21133a36836a47427b634ffc3888a0e67aee89

Contents?: true

Size: 1.84 KB

Versions: 12

Compression:

Stored size: 1.84 KB

Contents

# encoding: UTF-8
require 'gooddata'

include GoodData::Model

describe GoodData::Model::ProjectBlueprint do

  before(:each) do
    @spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
    @result = JSON.parse(File.read("./spec/data/wire_test_project.json"), :symbolize_names => true)
  end

  it "should parse the model view and return the blueprint" do
    expect(ToWire.to_wire(@spec)).to eq @result
  end

  it "should generate anchor" do

    dataset_with_anchor = {
      type: "dataset",
      name: "repos",
      columns: [{ type: "anchor", name: "repo_id"}]}

    dataset_without_anchor = {
      type: "dataset",
      name: "repos",
      columns: [{ type: "attribute", name: "repo_id"}]}

    res = ToWire.anchor_to_wire(@spec, dataset_without_anchor)
    expect(res).to eq({ attribute: { identifier: "attr.repos.factsof", title: "Records of Repos"}})

    res = ToWire.anchor_to_wire(@spec, dataset_with_anchor)
    expect(res).to eq({:attribute=>
      {:identifier=>"attr.repos.repo_id",
       :title=>"Repo",
       :labels=>
        [{:label=>
           {:identifier=>"label.repos.repo_id",
            :title=>"Repo",
            :type=>nil,
            :dataType=>nil}}],
       :defaultLabel=>"label.repos.repo_id"}})
  end

  it "should parse the model view and return the blueprint" do
    fact_table = {
      :type=>"dataset",
      :name=>"commits",
      :columns=>
       [{:type=>"reference",
         :name=>"dev_id",
         :dataset=>"devs",
         :reference=>"dev_id"}]}
    expect(ToWire.references_to_wire(@spec, fact_table)).to eq ["dataset.devs"]

    fact_table = {
      :type=>"dataset",
      :name=>"commits",
      :columns=>
       [{:type=>"date", :name=>"committed_on", :dataset=>"committed_on"}]}
    expect(ToWire.references_to_wire(@spec, fact_table)).to eq ["committed_on"]
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gooddata-0.6.16 spec/unit/models/to_wire_spec.rb
gooddata-0.6.15 spec/unit/models/to_wire_spec.rb
gooddata-0.6.14 spec/unit/models/to_wire_spec.rb
gooddata-0.6.13 spec/unit/models/to_wire_spec.rb
gooddata-0.6.12 spec/unit/models/to_wire_spec.rb
gooddata-0.6.11 spec/unit/models/to_wire_spec.rb
gooddata-0.6.10 spec/unit/models/to_wire_spec.rb
gooddata-0.6.9 spec/unit/models/to_wire_spec.rb
gooddata-0.6.8 spec/unit/models/to_wire_spec.rb
gooddata-0.6.7 spec/unit/models/to_wire_spec.rb
gooddata-0.6.6 spec/unit/models/to_wire_spec.rb
gooddata-0.6.5 spec/unit/models/to_wire_spec.rb