Class: Minitest::Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/matchers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.must(&block) ⇒ Object

Expects that matcher matches the subject

Example:

describe Post do
  subject { Post.new }

  must { have_valid(:title).when("Good") }
end


86
87
88
# File 'lib/minitest/matchers.rb', line 86

def self.must(&block)
  it { subject.must instance_eval(&block) }
end

.wont(&block) ⇒ Object

Expects that matcher does not match the subject

Example:

describe Post do
  subject { Post.new }

  wont { have_valid(:title).when("Bad") }
end


100
101
102
# File 'lib/minitest/matchers.rb', line 100

def self.wont(&block)
  it { subject.wont instance_eval(&block) }
end

Instance Method Details

#must(*args, &block) ⇒ Object

Define a ‘must` expectation for implicit subject

Example:

describe Post do
  subject { Post.new }

  it { must have_valid(:title).when("Good") }
end


115
116
117
# File 'lib/minitest/matchers.rb', line 115

def must(*args, &block)
  subject.must(*args, &block)
end

#wont(*args, &block) ⇒ Object

Define a ‘wont` expectation for implicit subject

Example:

describe Post do
  subject { Post.new }

  it { wont have_valid(:title).when("") }
end


130
131
132
# File 'lib/minitest/matchers.rb', line 130

def wont(*args, &block)
  subject.wont(*args, &block)
end