Skip to content
Browse files

give better info to user when has_tags called incorrectly

  • Loading branch information...
1 parent 1d399ea commit 79e0971fd4cf9f61a26dc60af35ac7b458fd89ff @jackdempsey committed
Showing with 14 additions and 24 deletions.
  1. +2 −1 lib/sequel_taggable/sequel_taggable.rb
  2. +12 −23 spec/sequel_taggable/sequel_taggable_spec.rb
View
3 lib/sequel_taggable/sequel_taggable.rb
@@ -31,7 +31,8 @@ def self.extended(klass)
klass.has_tags
end
- def has_tags
+ def has_tags(*args)
+ raise "has_tags takes no arguments, use 'has_tags_on :#{args.first}, ...' instead" unless args.empty?
has_tags_on :tags
end
View
35 spec/sequel_taggable/sequel_taggable_spec.rb
@@ -30,7 +30,7 @@ class HasTagsOnTestModel < Sequel::Model
it "should create taggable functionality for each of the context names passed" do
class TestModel < Sequel::Model
is :taggable
- has_tags_on(:pets, 'skills', :tags)
+ has_tags_on :pets, 'skills', :tags
end
TestModel.should be_taggable
a = TestModel.new
@@ -43,26 +43,15 @@ class TestModel < Sequel::Model
a.should respond_to(:tag_list=)
end
end
- #
- # describe ".has_tags" do
- # it "should create a taggable with 'tags' context regardless of passed arguments" do
- # class TagsOnly
- # include DataMapper::Resource
- # property :id, Integer, :serial => true
- # has_tags :pets, :skills
- # end
- # TagsOnly.should be_taggable
- # TagsOnly.new.should be_taggable
- # a = TagsOnly.new
- # a.should respond_to(:tag_list)
- # a.should respond_to(:tag_list=)
- # a.should respond_to(:tags)
- # a.should_not respond_to(:pet_list)
- # a.should_not respond_to(:pet_list=)
- # a.should_not respond_to(:pets)
- # a.should_not respond_to(:skill_list)
- # a.should_not respond_to(:skill_list=)
- # a.should_not respond_to(:skills)
- # end
- #end
+
+ describe ".has_tags" do
+ it "should raise an error message if someone uses has_tags with an argument list" do
+ lambda do
+ class TagsOnly < Sequel::Model
+ is :taggable
+ has_tags :pets, :skills
+ end
+ end.should raise_error(RuntimeError)
+ end
+ end
end

0 comments on commit 79e0971

Please sign in to comment.
Something went wrong with that request. Please try again.