Class: ActiveSupport::TestCase

Inherits:
Cybertrain::Test::Base show all
Defined in:
cybertrain/test/test_case.rb

Overview

Rails’ base class for model, job, mailer and other tests: every assertion, the time helpers and the fixture accessors.

Examples:

test/models/article_test.rb

require "test_helper"

class ArticleTest < ActiveSupport::TestCase
  test "title must be present" do
    refute Article.new(body: "a body long enough").save
  end
end

Class Method Summary collapse

Methods inherited from Cybertrain::Test::Base

#setup, #teardown

Class Method Details

.fixtures(name) ⇒ nil

fixtures :all is accepted and does nothing: every fixture is loaded for every test. Any other set is refused.

Parameters:

  • name (Symbol) —

    :all

Returns:

  • (nil)

Raises:

  • (ArgumentError) —

    for anything but :all



114
115
116
117
118
119
120
121
# File 'cybertrain/test/test_case.rb', line 114

def self.fixtures(name)
  unless name == :all
    message = "fixtures :all is the only form: every fixture is loaded for every test"
    raise ArgumentError, message
  end

  nil
end