Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Sequel inflectors to get class name from table_name

  • Loading branch information...
commit 6bcc17b6f6d89e19281afded7ad354ae2038fd1e 1 parent 00ae9b9
Joseph HALTER authored
Showing with 5 additions and 5 deletions.
  1. +3 −3 lib/rspec_sequel/base.rb
  2. +2 −2 spec/have_column_matcher_spec.rb
View
6 lib/rspec_sequel/base.rb
@@ -1,3 +1,5 @@
+require "sequel/extensions/inflector"
+
module RspecSequel
class Base
@@ -13,9 +15,7 @@ def matches?(target)
@prefix = "expected #{target.inspect} to"
valid?(target.db, target, target.class, @attribute, @options)
else
- name = target.name
- name = target.table_name if name.nil? || name==""
- @prefix = "expected #{name} to"
+ @prefix = "expected #{target.table_name.to_s.singularize.humanize} to"
valid?(target.db, target.new, target, @attribute, @options)
end
end
View
4 spec/have_column_matcher_spec.rb
@@ -56,8 +56,8 @@
it "should set failure messages" do
@matcher = have_column :password
@matcher.matches? Sequel::Model(:comments)
- @matcher.failure_message.should == "expected comments to " + @matcher.description
- @matcher.negative_failure_message.should == "expected comments to not " + @matcher.description
+ @matcher.failure_message.should == "expected Comment to " + @matcher.description
+ @matcher.negative_failure_message.should == "expected Comment to not " + @matcher.description
end
end
describe "on Sequel::Model class" do
Please sign in to comment.
Something went wrong with that request. Please try again.