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.

test 'a Song should have name' do
  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 and assert_equal are all you get.

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


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

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

TODO

  • Write tests for the tests.
  • Automate setup/teardown method calls if they exist
  • More modularity for test groups
  • Better output

Caveats

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