class Object

Public Instance Methods

assert_class(klass, content) { |$strip| ... } click to toggle source

Asserts the given class exists in the given content. When a block is given, it yields the content of the class.

assert_file "test/functional/accounts_controller_test.rb" do |controller_test|
  assert_class "AccountsControllerTest", controller_test do |klass|
    assert_match /context "index action"/, klass
  end
end
# File test/test_helper.rb, line 41
def assert_class(klass, content)
  assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/, "Expected to have class #{klass}"
  yield $2.strip if block_given?
end
copy_routes() click to toggle source
# File test/test_helper.rb, line 25
def copy_routes
  routes = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb'))
  destination = File.join(Rails.root, "config")
  FileUtils.mkdir_p(destination)
  FileUtils.cp File.expand_path(routes), destination
end
generator_list() click to toggle source
# File test/test_helper.rb, line 46
def generator_list
  {
    :rails        => ['scaffold', 'controller', 'mailer'],
    :haml         => ['scaffold', 'controller', 'mailer']
  }
end
path_prefix(name) click to toggle source
# File test/test_helper.rb, line 53
def path_prefix(name)
  case name
  when :rails
    'rails/generators'
  else
    'generators'
  end
end
require_generator(generator_list) click to toggle source
Alias for: require_generators
require_generators(generator_list) click to toggle source
# File test/test_helper.rb, line 62
def require_generators(generator_list)
  generator_list.each do |name, generators|
    generators.each do |generator_name|
      if name.to_s == 'rails' && generator_name.to_s == 'mailer'
        require File.join(path_prefix(name), generator_name.to_s, "#{generator_name}_generator")
      else
        require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
      end
    end
  end
end
Also aliased as: require_generator