Class: RSpec::Generator::TestCase

Inherits:
Rails::Generators::TestCase
  • Object
show all
Defined in:
lib/generator-spec/rspec/generator/test_case.rb

Instance Method Summary collapse

Constructor Details

#initialize(test_method_name) ⇒ TestCase

Returns a new instance of TestCase.



7
8
9
10
11
12
13
# File 'lib/generator-spec/rspec/generator/test_case.rb', line 7

def initialize(test_method_name)
  @method_name = test_method_name
  @test_passed = true
  @interrupted = false
  routes_file = File.join(File.dirname(__FILE__), 'routes.rb')        
  copy_routes routes_file
end

Instance Method Details

#copy_routes(routes_file) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
# File 'lib/generator-spec/rspec/generator/test_case.rb', line 15

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