Module: Kernel

Defined in:
lib/spec/runner/extensions/kernel.rb,
lib/spec/expectations/extensions/kernel.rb

Instance Method Summary collapse

Instance Method Details

#debugger(steps = 1) ⇒ Object

Start a debugging session if ruby-debug is loaded with the -u/–debugger option



4
5
6
7
# File 'lib/spec/runner/extensions/kernel.rb', line 4

def debugger(steps=1)
  # If not then just comment and proceed
  $stderr.puts "debugger statement ignored, use -u or --debugger option on rspec to enable debugging"
end

#should(matcher = nil, message = nil, &block) ⇒ Object

:call-seq:

should(matcher)
should == expected
should === expected
should =~ expected

receiver.should(matcher)
  => Passes if matcher.matches?(receiver)

receiver.should == expected #any value
  => Passes if (receiver == expected)

receiver.should === expected #any value
  => Passes if (receiver === expected)

receiver.should =~ regexp
  => Passes if (receiver =~ regexp)

See Spec::Matchers for more information about matchers

Warning

NOTE that this does NOT support receiver.should != expected. Instead, use receiver.should_not == expected



26
27
28
# File 'lib/spec/expectations/extensions/kernel.rb', line 26

def should(matcher=nil, message=nil, &block)
  Spec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
end

#should_not(matcher = nil, message = nil, &block) ⇒ Object

:call-seq:

should_not(matcher)
should_not == expected
should_not === expected
should_not =~ expected

receiver.should_not(matcher)
  => Passes unless matcher.matches?(receiver)

receiver.should_not == expected
  => Passes unless (receiver == expected)

receiver.should_not === expected
  => Passes unless (receiver === expected)

receiver.should_not =~ regexp
  => Passes unless (receiver =~ regexp)

See Spec::Matchers for more information about matchers



49
50
51
# File 'lib/spec/expectations/extensions/kernel.rb', line 49

def should_not(matcher=nil, message=nil, &block)
  Spec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
end