Permalink
Browse files

Add unit test coverage for Column

  • Loading branch information...
1 parent b03bdeb commit 8f367012e73ea246249e0acef8c4b889fd7ee1dc @nertzy nertzy committed Apr 2, 2013
Showing with 29 additions and 0 deletions.
  1. +29 −0 spec/lib/pg_search/configuration/column_spec.rb
@@ -0,0 +1,29 @@
+require "spec_helper"
+
+describe PgSearch::Configuration::Column do
+ describe "#full_name" do
+ with_model :Model do
+ table do |t|
+ t.string :name
+ end
+ end
+
+ it "returns the fully-qualified table and column name" do
+ column = described_class.new("name", nil, Model)
+ column.full_name.should == %Q{#{Model.quoted_table_name}."name"}
+ end
+ end
+
+ describe "#to_sql" do
+ with_model :Model do
+ table do |t|
+ t.string :name
+ end
+ end
+
+ it "returns an expression that casts the column to text and coalesces it with an empty string" do
+ column = described_class.new("name", nil, Model)
+ column.to_sql.should == %Q{coalesce(#{Model.quoted_table_name}."name"::text, '')}
+ end
+ end
+end

0 comments on commit 8f36701

Please sign in to comment.