Sha256: 85123663f17fc9c03ef480035feb4b62e61f1ba6971df46a61fcf7efb8f601bc

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe Facemock do
  let(:version) { "0.0.2" }
  let(:db_name) { ".test" }

  describe 'VERSION' do
    subject { Facemock::VERSION }
    it { is_expected.to eq version }
  end

  it 'should have a config module' do
    expect(Facemock::Config).to be_truthy
  end

  it 'should have a fb_graph module' do
    expect(Facemock::FbGraph).to be_truthy
  end

  it 'should have a errors module' do
    expect(Facemock::Errors).to be_truthy
  end

  before do
    stub_const("Facemock::Config::Database::DEFAULT_DB_NAME", db_name)
  end
  after  { Facemock::Config.database.drop }

  describe '#on' do
    subject { Facemock.on }
    it { is_expected.to be_truthy }

    context 'FbGraph' do
      context 'without option' do
        before { Facemock.on }
        it { expect(::FbGraph).to eq Facemock::FbGraph }
        it { expect( lambda { Facemock.on } ).not_to raise_error }
      end

      context 'with database_name option' do
        before do
          @options = { database_name: db_name}
          Facemock.on(@options)
        end
        it { expect(::FbGraph).to eq Facemock::FbGraph }
        it { expect( lambda { Facemock.on } ).not_to raise_error }
        it { expect( lambda { Facemock.on(@options) } ).not_to raise_error }
      end
    end
  end

  describe '#off' do
    subject { Facemock.off }
    it { is_expected.to be_truthy }

    context 'FbGraph' do
      before { Facemock.off }
      it { expect(FbGraph).to eq FbGraph }
      it { expect( lambda { Facemock.off } ).not_to raise_error }

      context 'when Mock is on' do
        before do
          Facemock.on
          Facemock.off
        end

        subject { ::FbGraph }
        it { is_expected.to eq FbGraph }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facemock-0.0.2 spec/facemock_spec.rb