require 'spec_helper'

describe Memory do
  describe Memory::Sources::GitHubSource do
    describe '#new' do
      it 'requires a GitHub username' do
        expect {
          Memory::Sources::GitHubSource.new
        }.to raise_error
      end

      describe '#feed_url' do
        it 'is built from the configured username' do
          source = Memory::Sources::GitHubSource.new(username: 'svankmajer')

          expect(source.feed_url).to include(source.username)
        end
      end

      describe '#update' do
        it 'updates the store returning the latest events' do
          source = Memory::Sources::GitHubSource.new(username: 'svankmajer')

          expect(source.update).to be_an(Array)
        end
      end
    end
  end
end

require 'spec_helper'

describe Memory do
  describe Memory::Sources::GitHubSource do
    subject(:github_source) {
      Memory::Sources::GitHubSource.new(username: 'svankmajer')
    }

    describe '#new' do
      it 'requires a GitHub username' do
        expect {
          Memory::Sources::GitHubSource.new
        }.to raise_error
      end

      describe '#feed_url' do
        it 'is built from the configured username' do
          expect(github_source.feed_url).to include(github_source.username)
        end
      end

      describe '#update' do
        it 'updates the store returning the latest events' do
          expect(github_source.update).to be_an(Array)
        end
      end
    end
  end
end

Introduce subject to GitHubSource specs.
Introduce subject to GitHubSource specs.

This commits adds a _named_ subject to Memory::Sources::GitHubSource specs to
avoid code duplication.
