A tiny Sass unit testing library.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
.gitignore
CODE_OF_CONDUCT.md
Gemfile
LICENSE.txt
README.md
Rakefile
sassunit.gemspec

README.md

SassUnit

A tiny Ruby utility for testing Sass libraries by comparing compiled output of short Sass tests to the expected CSS output.

For more information about the motivation and rationale behind SassUnit, read my introductory article, but, in short:

  • Prevents old functionality being accidentally broken by new changes
  • Easy to learn and use
  • Can enforce testing with minimum supported version of Sass for your project
  • Easy to use with continuous integration

Installation

Add this line to your application's Gemfile:

gem 'sassunit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sassunit

Usage

In your project’s root directory, create a folder called “test”. This is where your Sass test files live. Create a Sass file (classic Sass or SCSS) for each test, and for each Sass test file create a corresponding expected output file with the same name, but the “.css” extension.

Examples

# run the tests for the current project directory
$ bundle exec sassunit

# run a single test in the current project
$ bundle exec sassunit test/first_test.scss

# run tests for another project
$ bundle exec sassunit ~/projects/another_project # do not include /test

Running SassUnit using bundle exec will ensure it uses the version of Sass defined in your project’s Gemfile. This can be useful for ensuring that tests still pass with the minimum supported Sass version for your project.

Projects using SassUnit

My Sass-Web-Fonts library has a comprehensive test suite using SassUnit. If you have a project using SassUnit you should submit a pull request and I'll probably add it here.

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 a new Pull Request