Class: RSpec::Generators::TestCase

Inherits:
Rails::Generators::TestCase
  • Object
show all
Defined in:
lib/rspec_for_generators/rspec_test_case.rb

Instance Method Summary collapse

Constructor Details

#initialize(test_method_name) ⇒ TestCase

Returns a new instance of TestCase.



8
9
10
11
12
13
14
# File 'lib/rspec_for_generators/rspec_test_case.rb', line 8

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

Instance Method Details

#copy_routes(routes_file) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
# File 'lib/rspec_for_generators/rspec_test_case.rb', line 16

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