Sha256: b66c69d30bf3eaf8929025ce8529c41e23a4aea53bc1c74f28fc7e08701a83da

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
require_relative '../../lib/sredder/sredderc'

describe Sredder::Sredderc do

  def sample_file
    File.expand_path('spec/sample.sredderc')
  end

  describe 'initialization' do
    it 'sets the default file_path' do
      Sredder::Sredderc.new.file_path.should == File.expand_path('~/.sredderc')
    end
  end

  describe '#exists?' do

    it 'returns true if the file exists' do
      Sredder::Sredderc.new(sample_file).exists?.should be_true
    end

    it 'returns false if the file does not exist' do
      Sredder::Sredderc.new('/some/path').exists?.should be_false
    end

  end

  describe '#load' do

    it 'does not open the file if it does not exists' do
      File.should_receive(:open).never
      Sredder::Sredderc.new('/some/path').load
    end

    it 'loads the token and secret from the file if it exists' do
      rc = Sredder::Sredderc.new(sample_file)
      rc.load
      rc.credentials[:wrike_secret].should == 'secret'
      rc.credentials[:wrike_token].should == 'token'
    end

  end

  describe '#save' do

    it 'writes the data to the file' do
      io_stub = stub('io',:<< => {})
      File.stub(:open).and_yield(io_stub)

      rc = Sredder::Sredderc.new(sample_file)
      rc.credentials[:wrike_secret] = 'secret'
      rc.credentials[:token] = 'token'
      rc.save
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sredder-0.0.8 spec/sredder/sredderc_spec.rb
sredder-0.0.7 spec/sredder/sredderc_spec.rb
sredder-0.0.6 spec/sredder/sredderc_spec.rb
sredder-0.0.5 spec/sredder/sredderc_spec.rb