require 'spec_helper' require 'generators/rails_pages/resource_route/resource_route_generator' describe RailsPages::Generators::ResourceRouteGenerator do destination = File.expand_path('../../dummy', __FILE__) context 'generate' do before(:all) do Dir.chdir(destination) { %x(rails generate rails_pages:resource_route test) } end describe 'resources :tests' do it 'should be defined' 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:resource_route test) } end describe 'resources :tests' do it 'should not be defined' do expect(File.read "#{destination}/config/routes.rb").to_not include( "resources :tests, :only => :show, :format => false, :constraints => { :id => /.+?/ }" ) end end end end