Sha256: 82319b675cf2265652fc9a2d7d284ff9951daac475a6438c6fa8ac99f4a37dae

Contents?: true

Size: 1.38 KB

Versions: 14

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'fileutils'
require 'generator_spec/test_case'
require_relative '../../../lib/generators/lolita/uninstall_generator'

describe Lolita::Generators::UninstallGenerator do
  include GeneratorSpec::TestCase
  destination File.expand_path("../../../tmp", __FILE__)

  before do
    prepare_destination
    Rails.stub(:root).and_return(Pathname.new(destination_root))
    create_initializer(destination_root)
    create_routesrb(destination_root)
    run_generator
  end

  specify "removes lolita.rb initializer" do
    destination_root.should have_structure {
      directory "config" do
        directory "initializers" do
          no_file "lolita.rb"
        end
      end
    }
  end

  specify "removes lolita_for from routes.rb" do
    destination_root.should have_structure {
      directory "config" do
        file "routes.rb" do
          if open(@name, &:read).include?('lolita_for')
            throw :failure, 'lolita_for not removed from routes.rb'
          end
        end
      end
    }
  end
end

def create_initializer destination_root
  initializers_dir = File.join(destination_root, 'config', 'initializers')
  FileUtils.mkdir_p(initializers_dir)
  FileUtils.touch(File.join(initializers_dir, 'lolita.rb'))
end

def create_routesrb destination_root
  File.open(File.join(destination_root, 'config', 'routes.rb'), 'w') { |file| file.write("lolita_for :some_model") }
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
lolita-3.4.2 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.4.1 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.4.0 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.9 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.8 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.7 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.6 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.5 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.4 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.3 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.2 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.1 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.3.0 spec/generators/lolita/uninstall_generator_spec.rb
lolita-3.2.1 spec/generators/lolita/uninstall_generator_spec.rb