Rspice
A dash of custom matchers, a pinch of shared contexts, and shared examples (to taste) for RSpec
Installation
Add this line to your application's Gemfile:
gem "rspice"
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspice
Usage
To include the RSpice tools add the following to your rails_helper.rb
:
require 'rspice'
Custom Matchers
- alias_method tests usages of Module#alias_method
- extend_module tests usages of Object#extend
- have_error_on_attribute tests usages of ActiveModel::Errors
- include_module tests usages of Module#include
- inherit_from tests inheritance of Classes
- not_change negated
change
matcher - validate tests application and configuration of custom validators
Shared Context
- with_an_example_descendant_class creates a named descendant of
described_class
- with_callbacks defines callbacks for ActiveSupport::Callbacks
- with_example_class_having_callback creates a class with
Shared Examples
- a_class_pass_method tests class methods which take arguments that instantiate and call instance method of the same name
- a_class_with_callback tests usage of ActiveSupport::Callbacks
- a_versioned_spicerack_gem ensures gem compliance with internal standard of Spicerack
- an_example_class_with_callbacks tests for defined ActiveSupport::Callbacks
- an_inherited_property tests usages of inherited Class.class_attributes
- an_instrumented_event tests usage of ActiveSupport::Notification
Development
See Spicerack development instructions here.
To add a new example, context or matcher, add a new file to the appropriate directory in lib/rspice. Next, require the added file in its respective include file (such as lib/rspice/custom_matchers.rb
).
Contributing
See Spicerack contribution instructions here.
License
The gem is available as open source under the terms of the MIT License.