jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Add ability to configure hooks. #135

Closed rwjblue closed 10 years ago

rwjblue commented 10 years ago

Adds custom callback hooks to be executed when triggered by a POST to /:suite/hooks/:group.

This is helpful in our application to allow better integration testing while still being able to reset the database at key intervals.

We are using the following:

# config/initializers/teaspoon.rb

Teaspoon.setup do |config|

  config.suite do |suite|
    suite.hook :clean do
      DatabaseCleaner.clean
    end
  end
end
// support/cleanDatabase.js (required from test_helper.js)
window.cleanDatabase = function(suite){
  if (!suite) { suite = 'default' };

  jQuery.ajax('/teaspoon/' + suite + '/hooks/clean', {
    async: false,
    type: 'POST'
  });
}
jejacks0n commented 10 years ago

:+1: I like this, and will merge it when specs are passing. =)

Thanks!

rwjblue commented 10 years ago

The test failure has been fixed (I forgot that the tmp/ directory was not present in the repo so writing to it throws an error when run by Travis).

@jejacks0n - Please let me know if there is anything else that needs tweaking/modification...

jejacks0n commented 10 years ago

@rjackson, nope, everything looked pretty good from my review.

Thanks again! I'm thankful for good pull requests with good specs. =)

rwjblue commented 10 years ago

Awesome, thank you!