Sha256: 092fdea6a912ac8ab6093affb1aa668e7abd4013de3c90926b3e9c5f80318af9

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

module RSpec         
  module Generators
    class TestCase < ::Rails::Generators::TestCase   
      setup :prepare_destination
      # setup :copy_routes
      destination File.join(::Rails.root)      
            
      def initialize(test_method_name)
        @method_name = test_method_name
        @test_passed = true
        @interrupted = false
        routes_file = File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb')        
        copy_routes routes_file
      end 
      
      def copy_routes routes_file        
        routes = File.expand_path(routes_file)
        raise ArgumentError, "No routes file exists at #{routes_file}" if !File.exist?(routes)
        destination = File.join(::Rails.root, "config")
        FileUtils.mkdir_p(destination) # create dir
        FileUtils.cp routes, destination # copy
      end
           
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_for_generators-0.2.1 lib/rspec_for_generators/rspec_test_case.rb
rspec_for_generators-0.2.0 lib/rspec_for_generators/rspec_test_case.rb