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 'controller' do it 'should exist' do expect(File.exist? "#{destination}/app/controllers/tests_controller.rb").to be_true end end describe 'helper' do it 'should exist' do expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_true end end describe 'resource route' do it 'should exist' do expect(File.read "#{destination}/config/routes.rb").to include( "resources :tests, :only => :show, :format => false, :constraints => { :id => /.+?/ }" ) end end end context 'destroy' do before(:all) do Dir.chdir(destination) { %x(rails destroy rails_pages:scaffold test) } end describe 'controller' do it 'should not exist' do expect(File.exist? "#{destination}/app/controllers/tests_controller.rb").to be_false end end describe 'helper' do it 'should not exist' do expect(File.exist? "#{destination}/app/helpers/tests_helper.rb").to be_false end end describe 'resource route' do it 'should not exist' do expect(File.read "#{destination}/config/routes.rb").to_not include( "resources :tests, :only => :show, :format => false, :constraints => { :id => /.+?/ }" ) end end end end