Skip to content
Browse files

renamed database matcher have_db_column_matcher

  • Loading branch information...
1 parent 7bbcff0 commit a159fc5d95beb78614999ad2a7cc42d54fcf5247 @croaky croaky committed with jferris Jan 24, 2009
View
9 lib/shoulda/active_record/macros.rb
@@ -267,14 +267,13 @@ def should_ensure_length_is(attribute, length, opts = {})
# should_ensure_value_in_range :age, (0..100)
#
def should_ensure_value_in_range(attribute, range, opts = {})
- low_message, high_message =
- get_options!([opts], :low_message, :high_message)
+ message = get_options!([opts], :message)
+ message ||= default_error_message(:inclusion)
klass = model_class
matcher = ensure_inclusion_of(attribute).
in_range(range).
- with_low_message(low_message).
- with_high_message(high_message)
+ with_message(message)
should matcher.description do
assert_accepts matcher, get_instance_of(klass)
end
@@ -429,7 +428,7 @@ def should_have_db_columns(*columns)
:default, :null, :scale, :sql_type)
klass = model_class
columns.each do |name|
- matcher = has_db_column(name).
+ matcher = have_db_column(name).
of_type(column_type).
with_options(:precision => precision, :limit => limit,
:default => default, :null => null,
View
2 lib/shoulda/active_record/matchers.rb
@@ -8,7 +8,7 @@
require 'shoulda/active_record/matchers/require_acceptance_of_matcher'
require 'shoulda/active_record/matchers/only_allow_numeric_values_matcher'
require 'shoulda/active_record/matchers/association_matcher'
-require 'shoulda/active_record/matchers/database_matcher'
+require 'shoulda/active_record/matchers/have_db_column_matcher'
require 'shoulda/active_record/matchers/have_readonly_attribute_matcher'
require 'shoulda/active_record/matchers/protect_attribute_matcher'
require 'shoulda/active_record/matchers/have_named_scope_matcher'
View
6 ...ctive_record/matchers/database_matcher.rb → ...record/matchers/have_db_column_matcher.rb
@@ -2,7 +2,7 @@ module Shoulda # :nodoc:
module ActiveRecord # :nodoc:
module Matchers # :nodoc:
- class DatabaseMatcher
+ class HaveDbColumnMatcher
def initialize(macro, column)
@macro = macro
@column = column
@@ -133,8 +133,8 @@ def expectation
end
end
- def has_db_column(column)
- DatabaseMatcher.new(:has_db_column, column)
+ def have_db_column(column)
+ HaveDbColumnMatcher.new(:have_db_column, column)
end
end
View
26 test/matchers/database_matcher_test.rb
@@ -1,10 +1,10 @@
require File.join(File.dirname(__FILE__), '..', 'test_helper')
-class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
+class HaveDbColumnMatcherTest < Test::Unit::TestCase # :nodoc:
- context "has_db_column" do
+ context "have_db_column" do
setup do
- @matcher = has_db_column(:nickname)
+ @matcher = have_db_column(:nickname)
end
should "accept an existing database column" do
@@ -21,9 +21,9 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
end
- context "has_db_column with column_type option" do
+ context "have_db_column with column_type option" do
setup do
- @matcher = has_db_column(:nickname).of_type(:string)
+ @matcher = have_db_column(:nickname).of_type(:string)
end
should "accept a column of correct type" do
@@ -48,9 +48,9 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
end
- context "has_db_column with precision option" do
+ context "have_db_column with precision option" do
setup do
- @matcher = has_db_column(:money).with_options(:precision => 15)
+ @matcher = have_db_column(:money).with_options(:precision => 15)
end
should "accept a column of correct precision" do
@@ -70,9 +70,9 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
end
- context "has_db_column with limit option" do
+ context "have_db_column with limit option" do
setup do
- @matcher = has_db_column(:email).
+ @matcher = have_db_column(:email).
of_type(:string).
with_options(:limit => 255)
end
@@ -94,9 +94,9 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
end
- context "has_db_column with default option" do
+ context "have_db_column with default option" do
setup do
- @matcher = has_db_column(:admin).
+ @matcher = have_db_column(:admin).
of_type(:boolean).
with_options(:default => false)
end
@@ -118,9 +118,9 @@ class DatabaseMatcherTest < Test::Unit::TestCase # :nodoc:
end
end
- context "has_db_column with null option" do
+ context "have_db_column with null option" do
setup do
- @matcher = has_db_column(:admin).
+ @matcher = have_db_column(:admin).
of_type(:boolean).
with_options(:null => false)
end

0 comments on commit a159fc5

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