Module: MiniTest::Spec::Magic::Expectations

Included in:
Test::Unit::TestCase
Defined in:
lib/minitest/spec/magic/expectations.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
# File 'lib/minitest/spec/magic/expectations.rb', line 3

def self.included(base)
  base.extend ClassMethods
  super
end

Instance Method Details

#should(matcher) ⇒ Object

Tests a matcher for validity. Example:

class UserTest < ActiveSupport::TestCase
  it { should validate_presesence_of(:email) }
end

Parameters:

  • matcher (Matcher)

    the matcher to test



16
17
18
# File 'lib/minitest/spec/magic/expectations.rb', line 16

def should(matcher)
  assert_accepts matcher, subject
end

#should_not(matcher) ⇒ Object

Tests a matcher for negative validity. Example:

class UserTest < ActiveSupport::TestCase
  it { should_not validate_presesence_of(:email) }
end

Parameters:

  • matcher (Matcher)

    the matcher to test



27
28
29
# File 'lib/minitest/spec/magic/expectations.rb', line 27

def should_not(matcher)
  assert_rejects matcher, subject
end