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 '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 '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