Sha256: 60db948cf2b19ea44d8dd91b7fae0cf2bd7a61e75b452d186cada6003acf22b2

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe EagleLabels, '-> Initializations' do

  it 'Initialize from hash' do
    spec = Specification.new category: {'code' => 'C', 'features' => {'feature' => {'value1' => 1, 'value2' => 2}}}

    spec.should have(1).categories
    spec.categories.first.name.should eq :category
    spec.categories.first.code.should eq 'C'
    spec.categories.first.should have(1).features
    spec.categories.first.features.first.name.should eq 'feature'
    spec.categories.first.features.first.codes.should eq %w(1 2 0)
  end

  it 'Initialize from yml file' do
    spec = Specification.new 'dummy_spec.yml'

    spec.should have(3).categories
    spec.categories.map(&:name).should eq %w(category_1 category_2 category_3)
    spec.categories.map(&:code).should eq %w(1 2 3)

    spec.categories.each do |category|
      category.should have(2).features
      category.features.map(&:name).should eq %w(letter number)

      category.features[0].values[0].name.should eq 'value_a'
      category.features[0].values[0].code.should eq 'A'
      category.features[0].values[1].name.should eq 'value_b'
      category.features[0].values[1].code.should eq 'B'
      category.features[0].values[2].name.should eq 'value_c'
      category.features[0].values[2].code.should eq 'C'

      category.features[1].values[0].name.should eq 'value_1'
      category.features[1].values[0].code.should eq '1'
      category.features[1].values[1].name.should eq 'value_2'
      category.features[1].values[1].code.should eq '2'
      category.features[1].values[2].name.should eq 'value_3'
      category.features[1].values[2].code.should eq '3'
    end
  end

  it 'Initialize with default configuration' do
    spec = Specification.new

    spec.should have(13).categories
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eagle_labels-0.0.1 spec/initializations_spec.rb