citrus / minitest_should

minitest_should allows you to write unit tests with shoulda style syntax

Home Page:http://rubygems.org/gems/minitest_should

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minitest Should Build Status Dependency Status

minitest_should allows you to write unit tests with shoulda style context syntax for minitest.


Usage

When writing your mini-tests, inherit from Minitest::Should::TestCase.

gem "minitest"

require "minitest/autorun"
require "minitest/should"


# instead of this
class TestWithUnderscores < Minitest::Unit::TestCase
  
  def test_should_just_work
    assert true
  end
  
  def test_something_else_should_be_nothing
    @something = "nothing"
    assert_equal "nothing", @something
  end
  
end

# use this!
class TestWithShould < Minitest::Should::TestCase
  
  should "just work" do
    assert true
  end
  
  context "Something else" do
    
    setup do
      @something = "nothing"
    end
    
    should "be nothing" do
      assert_equal "nothing", @something
    end
    
  end
  
end

Installation

As usual, just use the gem install command:

(sudo) gem install minitest_should

Or add minitest_should as a gem in your Gemfile:

gem 'minitest_should' 

Run bundle install then require minitest_should like so:

require "minitest/autorun"
require "minitest/should"

Make sure your test classes inherit from Minitest::Should::TestCase

class MyTest < Minitest::Should::TestCase

  # ...

end

Testing

Testing is done with minitest. (duh!) Run the tests with:

rake

Changelog

**2014/8/19 - v0.3.2

  • refactor to Minitest v5.4 for Rails 4.1

2012/1/26 - v0.3.1

  • always alias setup to before, even if rails is present

2012/1/20 - v0.3.0

  • don't pollute minitest/unit/testcase
  • subclass minitest/spec as minitest/should/test_case
  • alias before and after as setup and teardown

2011/12/8 - v0.2.0

  • add contexts

2011/11/8 - v0.1.1

  • ensure dynamic methods have safe names

2011/11/8 - v0.1.0

  • it exists!

License

Copyright (c) 2011 - 2012 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.

About

minitest_should allows you to write unit tests with shoulda style syntax

http://rubygems.org/gems/minitest_should

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Ruby 100.0%