Sha256: 70d20a258c0acddd6d240835bfa701fc6d8f6c8f7f8bbc8d189a1d8cb057cad4

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'generators/rails_pages/scaffold/scaffold_generator'

describe RailsPages::Generators::ScaffoldGenerator do
  destination = File.expand_path('../../dummy', __FILE__)

  context 'generate' do
    before(:all) do
      Dir.chdir(destination) { %x(rails generate rails_pages:scaffold test) }
    end

    describe 'tests_controller.rb' do
      it 'should exist' do
        expect(File.exist? "#{destination}/app/controllers/tests_controller.rb").to be_true
      end
    end

    describe 'tests_helper.rb' do
      it 'should exist' do
        expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_true
      end
    end

    describe 'resources :tests' do
      it 'should be defined' do
        expect(File.read "#{destination}/config/routes.rb").to include('resources :tests')
      end
    end
  end

  context 'destroy' do
    before(:all) do
      Dir.chdir(destination) { %x(rails destroy rails_pages:scaffold test) }
    end

    describe 'tests_controller.rb' do
      it 'should not exist' do
        expect(File.exist? "#{destination}/app/controllers/tests_controller.rb").to be_false
      end
    end

    describe 'tests_helper.rb' do
      it 'should not exist' do
        expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_false
      end
    end

    describe 'resources :tests' do
      it 'should not be defined' do
        expect(File.read "#{destination}/config/routes.rb").to_not include('resources :tests')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_pages-0.0.3 spec/integration/scaffold_generator_spec.rb