Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glv-micronaut-unit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glv-micronaut-unit

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

micronaut-unit

Test::Unit compatibility for micronaut.

Just add this to your code:

require 'micronaut/unit'

and then you can write test classes like this:

class FooTest < Micronaut::Unit::TestCase
  def test_foo
    assert_equal 3, Foo::major_version
  end
end

Using the testinfo method, you can attach metadata to the next defined test (this works much the same way Rake's desc method attaches a description string to the next defined task):

testinfo :speed => 'slow', :run => 'nightly' def
test_tarantula_multipass
  # ...
end

Each instance of Micronaut::Unit::TestCase is equivalent to a micronaut describe block, so it can also include it blocks, before and after blocks, and nested describe blocks. Test methods and it blocks can contain either assertions or should expressions. test blocks (as found in Rails 2.x) also work.

Additionally, assertions can be used inside ordinary micronaut examples.

Rationale

The point of this gem is not that I think test/unit is a better way to write tests than the RSpec style. I admit that I'm a TDD oldtimer who sees RSpec as mostly a cosmetic (rather than fundamental) change, but that doesn't mean it's not an important change. My curmudgeonly nature has its limits, and I do find specs a big improvement.

So why micronaut-unit? Three reasons:

  1. I wanted to show off the generality of Micronaut's architecture. On the surface, Micronaut might not seem all that compelling (since it's basically an RSpec work-alike). But it's really a fantastic tool; it's just that the innovation is all under the hood, in a way that makes it easy to change the surface aspects. I hope micronaut-unit can serve as an example for anyone who wants to experiment with new ways of expressing tests and specs on top of Micronaut.
  2. Many projects with existing test/unit test suites might want to benefit from Micronaut's metadata goodness, or begin a gradual, piecemeal change to an RSpec style. That's pretty easy to do with micronaut-unit.
  3. Even when writing specs and examples, I frequently encounter cases where an assertion is more expressive than a should expression. It's nice just to have assertions supported within Micronaut examples.

To Do

It would be nice to try using the assertion code from minitest, which is much more compact and seems less coupled than that from test/unit.

Copyright (c) 2009 Glenn Vanderburg. See LICENSE for details.

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc