Categories: None [Edit]
socialcast_shoulda_ext
{}[http://travis-ci.org/socialcast/socialcast-shoulda-ext]
= Socialcast Shoulda Extensions
Adds new matchers and functionality to the shoulda test library
= Installation
In your Gemfile:
group :test do
gem 'socialcast_shoulda_ext', :git => '[email protected]:socialcast/socialcast-shoulda-ext.git', :require => 'shoulda_ext'
end
If you want to include the trigger_callbacks matcher, also add the following to your test helper:
ShouldaExt::Matchers::TriggerCallbackMatcher.attach_active_record_callback_hooks!
= Matchers
== RecordCountChangeMatcher
Test if the count for a model has changed, and by how much. Requires the context_with_matcher_before_hooks patch, which is included by default.
Provides the following matcher methods:
- create_record(klass_or_symbol)
Alias for change_record_count.for(klass_or_symbol).by(1)
- create_records(klass_or_symbol, amount)
Alias for change_record_count.for(klass_or_symbol).by(amount)
- destroy_record(klass_or_symbol)
Alias for change_record_count.for(klass_or_symbol).by(-1)
- destroy_records(klass_or_symbol, amount)
Alias for change_record_count.for(klass_or_symbol).by(-amount)
- change_record_count
Tests the difference in record count before and after the current setup/subject block
Can be used with the follow methods:
- for(klass_or_symbol)
Provides the class which the test is being performed on. Can be a constant or a symbol
- by(amount)
Provides an expected difference for the number of records for the specified class.
Excluding this number will allow the matcher to check for any difference
Examples:
context "creating a blog article" do
context "with good parameters" do
setup do
post :create, :blog => {:title => 'my blog post', :body => 'Ipsum lorem...'}
end
should create_record :blog
end
context "without a body" do
setup do
post :create, :blog => {:title => '...
Total
Ranking: 100,677 of 183,052
Downloads: 7,148
Daily
Ranking: 97,699 of 183,043
Downloads: 0
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|
Owners
# | Gravatar | Handle |
---|---|---|
1 | phene |