Skip to content

Commit

Permalink
Use Sequel inflectors to get class name from table_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph HALTER committed Aug 22, 2009
1 parent 00ae9b9 commit 6bcc17b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/rspec_sequel/base.rb
@@ -1,3 +1,5 @@
require "sequel/extensions/inflector"

module RspecSequel module RspecSequel


class Base class Base
Expand All @@ -13,9 +15,7 @@ def matches?(target)
@prefix = "expected #{target.inspect} to" @prefix = "expected #{target.inspect} to"
valid?(target.db, target, target.class, @attribute, @options) valid?(target.db, target, target.class, @attribute, @options)
else else
name = target.name @prefix = "expected #{target.table_name.to_s.singularize.humanize} to"
name = target.table_name if name.nil? || name==""
@prefix = "expected #{name} to"
valid?(target.db, target.new, target, @attribute, @options) valid?(target.db, target.new, target, @attribute, @options)
end end
end end
Expand Down
4 changes: 2 additions & 2 deletions spec/have_column_matcher_spec.rb
Expand Up @@ -56,8 +56,8 @@
it "should set failure messages" do it "should set failure messages" do
@matcher = have_column :password @matcher = have_column :password
@matcher.matches? Sequel::Model(:comments) @matcher.matches? Sequel::Model(:comments)
@matcher.failure_message.should == "expected comments to " + @matcher.description @matcher.failure_message.should == "expected Comment to " + @matcher.description
@matcher.negative_failure_message.should == "expected comments to not " + @matcher.description @matcher.negative_failure_message.should == "expected Comment to not " + @matcher.description
end end
end end
describe "on Sequel::Model class" do describe "on Sequel::Model class" do
Expand Down

0 comments on commit 6bcc17b

Please sign in to comment.