Sha256: a4d5905e7f589bb81084933b63c4507dc7799ab6d19d2a244d82952d9e9262e8

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

RSpec.describe Warp::Dir::Config do
  let(:c1) { Warp::Dir::Config.new(blah: 'blah blah') }

  it 'should have a default folder' do
    expect(c1.warprc).to eql(ENV['HOME'] + '/.warprc')
  end

  it 'should automatically create accessors' do
    expect(c1.blah).to eql('blah blah')
  end

  it 'should add new parameter to the params array' do
    expect(c1.variables).to eql([:warprc, :shell, :force, :debug, :blah])
  end

  it 'should be able to create a attr_writer also' do
    c1.blah = 'another blah'
    expect(c1.blah).to eql('another blah')
  end

  it 'should be possible to add a new value after instance was created' do
    c1.new_field = 'really new here'
    expect(c1.new_field?).to be_truthy
    expect(c1.new_field).to eql('really new here')
  end

  describe 'when another instance of the config is created' do
    let(:c2) { Warp::Dir::Config.new(poo: 'boo') }

    it 'should only have one parameter for this class' do
      expect(c1.respond_to?(:poo)).to be_falsey
      expect(c2.respond_to?(:poo)).to be_truthy

      expect(c1.respond_to?(:blah)).to be_truthy
      expect(c2.respond_to?(:blah)).to be_falsey
    end

    it 'should add new parameter to the params array' do
      expect(c2.variables).to eql([:warprc, :shell, :force, :debug, :poo])
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
warp-dir-1.1.3 spec/warp/dir/config_spec.rb
warp-dir-1.1.2 spec/warp/dir/config_spec.rb
warp-dir-1.1.1 spec/warp/dir/config_spec.rb
warp-dir-1.1.0 spec/warp/dir/config_spec.rb