Sha256: 24eb1ac330e3c89b291f424e1be7de7225be12e4f4f4edd3fd32c03c58caff09

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'nanotest'
require 'lib/nanocontexts'

include NanoTest

# test: API
assert { NanoContexts.respond_to?(:context) }
assert { NanoContexts.respond_to?(:setup) }
assert { NanoContexts.respond_to?(:teardown) }
assert { NanoContexts.respond_to?(:test) }

class API
  include NanoContexts
end
assert { API.new.respond_to?(:context) }
assert { API.new.respond_to?(:setup) }
assert { API.new.respond_to?(:teardown) }
assert { API.new.respond_to?(:test) }


# the rest of the tests are self-hosted, for great justice
include NanoContexts

context do
  setup do
    @parent = 'parent'
  end
  test do
    # test: simple setup
    assert { @parent == 'parent' }
  end
  context do
    setup do
      @child = 'child'
    end
    teardown do
      @child =  nil; @sibling = 'sibling'
    end
    test do
      # test: parent setups are called
      assert { @parent == 'parent' }
      # test: descendent setups are also called
      assert { @child  == 'child'  }
    end
  end
  context do
    test do
      # test: teardown
      assert { @sibling == 'sibling' }
      # test: setups from sibling contexts are discarted
      # (setup from sibling context would set @child)
      assert { @child.nil? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanocontexts-0.9 test/test_nanocontexts.rb