Sha256: d99e7e4d6d95c9319cc5199f8dc8060f93b277f4b27ebef7500cc4f1c6e2d020

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

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

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

  before(:each) do
    pending
    prepare_destination
    %w(config script).each do |dir|
      `ln -sf #{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
    gen.should_receive :mount_engine
    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 configuration file' 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

    describe 'the routes file' do
      subject { file('config/routes.rb') }
      it { should contain(/mount Socialite::Engine, :at => '\/socialite'/) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
socialite-0.2.1 spec/generators/socialite/install_generator_spec.rb
socialite-0.2.0 spec/generators/socialite/install_generator_spec.rb