Fis::Test

Testing frameworks are amazing. RSpec, Minitest, all of them are great. For beginners though, those frameworks add so many levels of abstraction and features that teaching the core of test-driven development gets sidetracked by learning framework specific conventions and syntax. Instead of teaching the significance of an assertion, you end up going over let{} or setup. That's important, but not as important as assert or assert_equal.

The Flatiron School test framework is 32 lines of code and provides the essential methods to write a unit test.

Installation

Add this line to your application's Gemfile:

gem 'fis-test'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fis-test

Usage

The core of fis-test is the following structure.

require 'fis/test'

extend Fis::Test

test 'a Song should have name' do
  s = Song.new
  s.name = "Get Lucky"
  assert_equal s.name, "Get Lucky"
end

You can easily skip a test if necessary

require 'fis/test'

extend Fis::Test

test 'a Song should have name' do
  skip("skip this for now")
  s = Song.new
  s.name = "Get Lucky"
  assert_equal s.name, "Get Lucky"
end

test is a simple wrapper method to give you some nice output.

assert, assert_equal, and skip are all you get.

No setup/teardown. You can DRY your code with simple helper methods.

require 'fis/test'

class SongTest
  extend Fis::Test

  def setup_song
    @song = Song.new
  end

  def teardown_song
    @song = nil
  end

  test 'a Song should have name' do
    setup_song
    @song.name = "Get Lucky"
    assert_equal @song.name, "Get Lucky"
    teardown_song
  end
end

That's it! Write tests. Stop writing code.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Notes

This is a very early release. It needs a lot of work. I would wait to use this for a bit.

TODO

  • Write tests for the tests.
  • Automate setup/teardown method calls if they exist
  • More modularity for test groups
  • Better output
  • fix extend / include confusion, better/easier way to get to testing methods.

Caveats

I'd like to see this framework stay below 100 loc forever.