Home > shoulda_deferred

shoulda_deferred

Shoulda_deferred is a project mainly written in Ruby, based on the MIT license.

Always wanted to defer or postpone shoulda tests? Well, then this is the plugin for you! You can put an 'x' in front of any shoulda macro to run that test later.

= ShouldaDeferred

ShouldaDeferred is a take on a few shoulda extensions to defer context and should blocks, like xshould and xcontext.

NOTE: You will need to have Shoulda installed before you can use this plugin.

== Installation

ShouldaDeferred is available as plugin:

script/plugin install git://github.com/rudionrails/shoulda_deferred.git

You will need to manually require this plugin in your test helper. That is, because otherwise it would get automatically loaded in every environment.

in test/test_helper.rb

require 'shoulda_deferred'

== Usage

You are able to put an 'x' before any shoulda macro or block in order to run it later.

xshould will postpone a single should statement. xcontext will delay that context and anything within the context block. You will see a " * DEFERRED... " message in the console for all deferred test. For xcontext, you will see a deferred message for all containing should blocks and subcontexts. This plugin also works for any other shoulda macro, like xshould_change, xshould_validate_presence_of, xshould_respond_with, etc.

=== Examples

xshould 'do something awesome' do flunk "defer" end

=> DEFERRED: SomeController should do something awesome.

xcontext 'a deferred context' do should 'do something' do flunk "defer" end end

=> DEFERRED: a deferred context should do something.

xcontext 'a deferred context' do context 'with another subcontext' do should 'do something awesome' do flunk "defer" end end end

=> DEFERRED: a deferred context with another subcontext should do something awesome.

context 'a regular context' do xcontext 'with a deferred subcontext' do should 'make me happy' do assert true end end

should 'assert true' do assert true # this will run! end end

=> DEFERRED: a regular context with a deferred subcontext should make me happy.

xshould_respond_with :success

=> DEFERRED: SomeController should respond with success.

context 'a regular context' do xshould_render_template :index end

=> DEFERRED: a regular context should render template index.

... and on and on and on and on...

== Known Issues None at the moment :-)

Copyright (c) 2009 Rudolf Schmidt, released under the MIT license.

Previous:wheresmycar