Class: Test::Spec::ShouldNot

### Home Classes Methods

### In Files

- lib/test/spec.rb

### Parent

Object

### Methods

- ::new
- #==
- #=~
- #_raise
- #add_assertion
- #be
- #be_nil
- #equal
- #match
- #method_missing
- #nil
- #not
- #pass
- #satisfy
- #throw

### Included Modules

- Test::Unit::Assertions

### Files

- README
- ROADMAP
- SPECS

### Class/Module Index

Quicksearch

- Test
- Test::Spec
- Test::Spec::CustomShould
- Test::Spec::DefinitionError
- Test::Spec::Should
- Test::Spec::ShouldNot
- Test::Spec::TestCase
- Test::Spec::TestCase::ClassMethods
- Test::Spec::TestCase::InstanceMethods
- Test::Unit
- Test::Unit::UI
- Test::Unit::UI::RDox
- Test::Unit::UI::RDox::TestRunner
- Test::Unit::UI::SpecDox
- Test::Unit::UI::SpecDox::TestRunner
- Object

No matching classes.

# Test::Spec::ShouldNot

### Public Class Methods

new(object, message=nil) click to toggle source

    # File lib/test/spec.rb, line 204
    def initialize(object, message=nil)
      @object = object
      @message = message
    end

### Public Instance Methods

==(value) click to toggle source
Alias for: equal
=~(value) click to toggle source
Alias for: match
_raise(*args, &block) click to toggle source

    # File lib/test/spec.rb, line 246
    def _raise(*args, &block)
      block ||= @object
      args << @message  if @message
      assert_nothing_raised(*args, &block)
    end

add_assertion() click to toggle source

    # File lib/test/spec.rb, line 209
    def add_assertion
      $TEST_SPEC_TESTCASE && $TEST_SPEC_TESTCASE.__send__(:add_assertion)
    end

be(*value) click to toggle source

    # File lib/test/spec.rb, line 225
    def be(*value)
      case value.size
      when 0
        self
      when 1
        if CustomShould === value.first
          pass value.first
        else
          assert_not_same value.first, @object, @message
        end
      else
        Kernel.raise ArgumentError, "should.be needs zero or one argument"
      end
    end

be_nil() click to toggle source

    # File lib/test/spec.rb, line 260
    def be_nil
      warn "Test::Spec::ShouldNot#be_nil is deprecated and will be removed in future versions."
      self.nil
    end

equal(value) click to toggle source

    # File lib/test/spec.rb, line 220
    def equal(value)
      assert_not_equal value, @object, @message
    end

Also aliased as: ==
match(value) click to toggle source

    # File lib/test/spec.rb, line 240
    def match(value)
      # Icky Regexp check
      assert_no_match value, @object, @message
    end

Also aliased as: =~
method_missing(name, *args, &block) click to toggle source

    # File lib/test/spec.rb, line 284
    def method_missing(name, *args, &block)
      # This will make raise call Kernel.raise, and self.raise call _raise.
      return _raise(*args, &block)  if name == :raise

      if @object.respond_to?("#{name}?")
        assert_block("#{name}? expected to be false. #{@message}") {
          not @object.__send__("#{name}?", *args)
        }
      else
        if @object.respond_to?(name)
          assert_block("#{name} expected to be false. #{@message}") {
            not @object.__send__("#{name}", *args)
          }
        else
          super
        end
      end
    end

nil() click to toggle source

    # File lib/test/spec.rb, line 256
    def nil
      assert_not_nil @object, @message
    end

not(*args) click to toggle source

    # File lib/test/spec.rb, line 265
    def not(*args)
      case args.size
      when 0
        Should.new(@object, @message)
      when 1
        Should.new(@object, @message).pass(args.first)
      else
        raise ArgumentError, "#not takes zero or one argument(s)."
      end
    end

pass(custom) click to toggle source

    # File lib/test/spec.rb, line 276
    def pass(custom)
      _wrap_assertion {
        begin
          assert !custom.matches?(@object), @message || custom.failure_message
        end
      }
    end

satisfy(&block) click to toggle source

    # File lib/test/spec.rb, line 214
    def satisfy(&block)
      assert_block(@message || "not.satisfy block succeded.") {
        not yield @object
      }
    end

throw() click to toggle source

    # File lib/test/spec.rb, line 252
    def throw
      assert_nothing_thrown(@message, &@object)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.