Posted By: David Chelimsky
Date: 2007-05-03 07:53
Summary: rspec 0.9.1
Project: RSpec
This release introduces #describe and #it (aliased as #context and #specify for
backwards compatibility). This allows you to express specs like this:
describe SomeClass do # Creates a Behaviour
it "should do something" do # Creates an Example
end
end
The command line features four new options that give you more control over what specs
are being run and in what order. This can be used to verify that your specs are
independent (by running in opposite order with --reverse). It can also be used to cut
down feedback time by running the most recently modified specs first (--loadby mtime --reverse).
Further, --example replaces the old --spec option, and it can now take a file name of
spec names as an alternative to just a spec name. The --format failing_examples:file.txt
option allows you to output an --example compatible file, which makes it possible to only
rerun the specs that failed in the last run. Spec::Rails uses all of these four options
by default to optimise your RSpec experience.
There is now a simple configuration model. For Spec::Rails, you do something like this:
Spec::Runner.configure do |config|
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + '/spec/fixtures'
end
You can now use mocha or flexmock with RSpec if you prefer either to
RSpec's own mock framework. Just put this:
Spec::Runner.configure do |config|
config.mock_with :mocha
end
or this:
Spec::Runner.configure do |config|
config.mock_with :flexmock
end
in a file that is loaded before your specs. You can also
configure included modules and predicate_matchers:
Spec::Runner.configure do |config|
config.include SomeModule
config.predicate_matchers[:does_something?] = :do_something
end
See Spec::DSL::Behaviour for more on predicate_matchers
|
|