Permalink
Browse files

Fixing RSpec helpers to work with the newest API.

  • Loading branch information...
1 parent 3d762d2 commit 1d8acf3f33ed9253f12e7116163280fe18500ea0 @pk committed May 2, 2010
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/sequel_sluggable/rspec_helper.rb
@@ -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

0 comments on commit 1d8acf3

Please sign in to comment.