Sha256: e94ff9009e7ba76ae4b99c240487660d02bb7436f6ea9932b641ac14f20b1cdc

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe SPV::Fixtures::Modifiers::ShortcutPath do
  describe '#modify' do
    let(:path)          { 'some home path' }
    let(:shortcut_path) { 'some shortcut' }
    let(:options)       { instance_double('SPV::Options') }
    let(:fixture) do
      instance_double(
        'SPV::Fixture',
        name:          'test_with_home_path',
        shortcut_path: shortcut_path
      )
    end

    subject { described_class.new(options).modify(fixture) }

    context 'when a name of the fixture has a shortcut path' do
      context 'when a given shortcut path is defined' do
        it 'writes a proper path to the fixture' do
          expect(options).to receive(:shortcut_path).with(shortcut_path).and_return(path)
          expect(fixture).to receive(:set_home_path).with(path)

          subject
        end
      end

      context 'when a given shortcut path is not defined' do
        before do
          allow(options).to receive(:shortcut_path).and_return(nil)
        end

        it 'raises an argument error about wrong way of defining fixtures' do
          msg = "You are trying to use the 'some shortcut' shortcut path " \
            "for test_with_home_path fixture. This shortcut path cannot be " \
            "used since it is not defined, please refer to the documentation to make " \
            "sure you properly define the shortcut path."

          expect { subject }.to raise_error(
            ArgumentError, msg
          )
        end
      end
    end

    context 'when a name of the fixture has not a shortcut path' do
      let(:fixture) do
        instance_double(
          'SPV::Fixture',
          shortcut_path: nil
        )
      end

      it 'does not set any home path' do
        expect(fixture).to_not receive(:set_home_path)

        subject
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
site_prism.vcr-0.3.0 spec/unit/fixtures/modifiers/shortcut_path_spec.rb
site_prism.vcr-0.2.0 spec/unit/fixtures/modifiers/shortcut_path_spec.rb