Sha256: e3cce46600cd663a221e3720188bf52330b7daf4b4fdbae225ba94c03315bb7a

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 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
    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

8 entries across 8 versions & 1 rubygems

Version Path
socialite-0.1.2 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.1 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.7 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.6 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.5 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.4 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.3 spec/generators/socialite/install_generator_spec.rb
socialite-0.1.0.pre.2 spec/generators/socialite/install_generator_spec.rb