Sha256: 6d1c79d0f7d9edbe2cb32e33b76f8ef0eddd92ecfb675da347601c627ad4fa59

Contents?: true

Size: 1.58 KB

Versions: 22

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

module Relish
  describe OptionsFile do
    let(:path) { Dir.tmpdir + '/.relish' }
    let(:global_options) { described_class.new(path) }
  
    after { FileUtils.rm_rf(path) }
  
    describe '#[]' do
    
      context 'with options file that exists' do
        let(:options) do
          {'organization' => 'rspec', 'project' => 'rspec-core'}
        end
      
        before do
          File.open(path, 'w') { |f| YAML.dump(options, f) }
        end
      
        it 'parses the organization' do
          global_options['organization'].should eq('rspec')
        end
      
        it 'parses the project' do
          global_options['project'].should eq('rspec-core')
        end
      end
    
      context 'with options file that does not exist' do
        before do
          FileUtils.rm_rf(path)
        end
      
        it 'returns an empty hash' do
          global_options.should eq({})
        end
      end
    end
  
    describe '#store' do
      context 'with options file that exists' do
      
        let(:options) do
          {'organization' => 'rspec', 'project' => 'rspec-core'}
        end
      
        before do
          File.open(path, 'w') { |f| YAML.dump(options, f) }
          global_options.store('organization' => 'relish')
        end
      
        it "over-writes existing values" do
          OptionsFile.new(path).options['organization'].should == 'relish'
        end
      
        it 'leaves existing options alone' do
          OptionsFile.new(path).options['project'].should == 'rspec-core'
        end 
      
      end
    end
  
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
relish-0.5.3 spec/relish/options_file_spec.rb
relish-0.5.2 spec/relish/options_file_spec.rb
relish-0.5.1 spec/relish/options_file_spec.rb
relish-0.5.0 spec/relish/options_file_spec.rb
relish-0.4.0 spec/relish/options_file_spec.rb
relish-0.3.0 spec/relish/options_file_spec.rb
relish-0.3.0.pre spec/relish/options_file_spec.rb
relish-0.2.3 spec/relish/options_file_spec.rb
relish-0.2.2 spec/relish/options_file_spec.rb
relish-0.2.1 spec/relish/options_file_spec.rb
relish-0.2.0 spec/relish/options_file_spec.rb
relish-0.1.6 spec/relish/options_file_spec.rb
relish-0.1.5 spec/relish/options_file_spec.rb
relish-0.1.4 spec/relish/options_file_spec.rb
relish-0.1.3 spec/relish/options_file_spec.rb
relish-0.1.2 spec/relish/options_file_spec.rb
relish-0.1.1 spec/relish/options_file_spec.rb
relish-0.1.0 spec/relish/options_file_spec.rb
relish-0.0.9 spec/relish/options_file_spec.rb
relish-0.0.8 spec/relish/options_file_spec.rb