Sha256: 35fdccafca3f4c9996ae773bc3fdce7b873825bc49c0a08a1a609586e328260b

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# Encoding: utf-8

require 'spec_helper'
require 'chemistrykit/catalyst'

describe ChemistryKit::Catalyst do

  before(:each) do

    Dir.mkdir(File.join(TEST_TMP_PATH, 'catalyst'))
    @data_file = File.join(TEST_TMP_PATH, 'catalyst', 'catalyst_data.csv')
    File.open(@data_file, 'w') { |f| f.write("first_key,first_value\nsecond_key,second_value") }
    @catalyst = ChemistryKit::Catalyst.new(@data_file)
  end

  it 'Should take a csv file on initialization.' do
    @catalyst.should be_an_instance_of ChemistryKit::Catalyst
  end

  it 'Should respond to a named key.' do
    @catalyst.first_key.should be == 'first_value'
    @catalyst.second_key.should be == 'second_value'
  end

  it 'Should respond to a convienence method.' do
    @catalyst.get_value_for('second_key').should be == 'second_value'
    @catalyst.get_value_for('first_key').should be == 'first_value'
  end

  it 'Should throw an exception for a non existant key.' do
    expect { @catalyst.get_value_for('third_key') }.to raise_error("Unknown \"third_key\"")
    expect { @catalyst.third_key }.to raise_error("Unknown \"third_key\"")
  end

  after(:each) do
    FileUtils.rm_rf(File.join(TEST_TMP_PATH, 'catalyst'))
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chemistrykit-3.10.1 spec/unit/lib/chemistrykit/catalyst_spec.rb
chemistrykit-3.10.0 spec/unit/lib/chemistrykit/catalyst_spec.rb
chemistrykit-3.9.1 spec/unit/lib/chemistrykit/catalyst_spec.rb
chemistrykit-3.9.0 spec/unit/lib/chemistrykit/catalyst_spec.rb
chemistrykit-3.9.0.rc3 spec/unit/lib/chemistrykit/catalyst_spec.rb