Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing RSpec helpers to work with the newest API.
- Loading branch information
Showing
1 changed file
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
module Sequel::Plugins::Sluggable::SluggableRSpecHelper | ||
module Sequel::Plugins::Sluggable::RSpecHelper | ||
def it_should_behave_like_sluggable(klass) | ||
it "should have slug when created" do | ||
model = klass.make(klass.slug_source_column => 'Test String') | ||
model = klass.make(klass.sluggable_options[:source] => 'Test String') | ||
model.slug.should eql 'test-string' | ||
end | ||
|
||
it "should update slug when #{klass.slug_source_column} is updated" do | ||
model = klass.make(klass.slug_source_column => 'Test String') | ||
lambda { model.update(klass.slug_source_column => 'Test String Two') }.should change(model,:slug).to('test-string-two') | ||
it "should not update slug by default when #{klass.sluggable_options[:source]} is updated" do | ||
model = klass.make(klass.sluggable_options[:source] => 'Test String') | ||
model.update(klass.sluggable_options[:source] => 'Test String Two') | ||
model.send(klass.sluggable_options[:target]).should eql 'test-string' | ||
end | ||
|
||
it "should find #{klass} by it's ID" do | ||
model = klass.make(klass.slug_source_column => 'Test String') | ||
klass.find_by_id_or_slug(model.id).should eql model | ||
model = klass.make(klass.sluggable_options[:source] => 'Test String') | ||
klass.find_by_pk_or_slug(model.id).should eql model | ||
end | ||
|
||
it "should find #{klass} by it's slug" do | ||
model = klass.make(klass.slug_source_column => 'Test String') | ||
klass.find_by_id_or_slug('test-string').should eql model | ||
model = klass.make(klass.sluggable_options[:source] => 'Test String') | ||
klass.find_by_pk_or_slug('test-string').should eql model | ||
end | ||
end | ||
end |