Sha256: 2732992b3b98f30404eddce863f09a748cd6f764dee4a4e92b2687a983346a5d

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require "generators/socialite/install_generator"

describe Socialite::Generators::InstallGenerator do
  destination File.expand_path("../../../../tmp", __FILE__)

  before(:each) do
    prepare_destination
    %w(config script).each do |dir|
      `ln -s #{Rails.root + dir} #{destination_root}`
    end
  end

  after(:each) do
    unless example.exception
      prepare_destination
    end
  end

  # using mocks to ensure proper methods are called
  # invoke_all - will call all the tasks in the generator
  it 'should run all tasks in the generator' do
    gen = generator %w(install)
    gen.should_receive :copy_initializer
    capture(:stdout) { gen.invoke_all }
  end

  # custom matchers make it easy to verify what the generator creates
  describe 'the generated files' do
    before do
      run_generator %w(install)
    end
    describe 'the spec' do
      # file - gives you the absolute path where the generator will create the file
      subject { file('config/initializers/socialite.rb') }
       # should exist - verifies the file exists
      it { should exist }

      # should contain - verifies the file's contents
      it { should contain(/Socialite.setup do \|config\|/) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socialite-0.1.0.pre spec/generators/socialite/install_generator_spec.rb