Skip to content

Developing Teaspoon

Jeremy Jackson edited this page Aug 19, 2016 · 4 revisions

Teaspoon is largely conventional, meaning it shouldn't surprise you with its choices. If it does, submit a PR!

Running the tests should be straightforward:

  1. git clone https://github.com/jejacks0n/teaspoon.git
  2. cd teaspoon
  3. bundle
  4. rake

The default tests run 8 suites:

  1. teaspoon core's ruby tests (rake spec)
  2. teaspoon core's javascript tests (rake teaspoon)
  3. teaspoon-jasmine's integration tests (rake teaspoon:jasmine:spec)
  4. teaspoon-jasmine's javascript tests (rake teaspoon:jasmine:jsspec)
  5. teaspoon-mocha's integration tests (rake teaspoon:mocha:spec)
  6. teaspoon-mocha's javascript tests (rake teaspoon:mocha:jsspec)
  7. teaspoon-qunit's integration tests (rake teaspoon:qunit:spec)
  8. teaspoon-qunit's javascript tests (rake teaspoon:qunit:jsspec)

Most of the framework extension happens in javascript. Therefore, there aren't many (if at all) framework-specific ruby tests because frameworks don't contain much ruby code. The framework-specific tests generally check that teaspoon installs correctly, the framework javascript tests run, dummy tests run in the browser, and dummy tests run on the CLI.

Organization

The core library code follows a standard Rails engine file structure. Officially supported framework extensions live in sub-directories teaspoon-jasmine, teaspoon-mocha and teaspoon-qunit. Third party libraries could use these framework extensions as a template to create extensions for other frameworks. Each extension is its own gem.

Working on extensions

If you're working within an extension's coffeescript files, you'll want to run those tests:

TEASPOON_DEVELOPMENT=true TEASPOON_RAILS_ENV=./spec/dummy/config/environment.rb TEASPOON_ENV=./teaspoon-jasmine/spec/teaspoon_env.rb teaspoon

TEASPOON_DEVELOPMENT indicates that we'd like to use the framework's coffeescript development files. Without this, teaspoon will use the compiled, static javascript files that get created with each release and distributed as part of the gem.

TEASPOON_RAILS_ENV indicates that the host Rails environment to run the tests should be the dummy Rails app. The framework extensions do not have their own dummy app.

TEASPOON_ENV indicates the teaspoon_env.rb file to use, which tells teaspoon what framework is being used and where to find the specs.

We're wrapped all of this up into rake tasks, so you can run the javascript tests with:

rake teaspoon:jasmine:jsspec

Building

When it's time to release, all coffeescript code should be compiled into a static javascript file containing the core teaspoon library and the framework-specific extensions.

To build all frameworks, run:

rake teaspoon:build

To build a specific framework, run:

rake teaspoon:jasmine:build