Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added dummy_value_for for non-db-backed 'attributes'

  • Loading branch information...
commit 66c23b450e6534ead5a9e018328122263648acac 1 parent 9efc44f
RSL authored
Showing with 13 additions and 10 deletions.
  1. +13 −10 lib/lucky_sneaks/common_spec_helpers.rb
23 lib/lucky_sneaks/common_spec_helpers.rb
View
@@ -3,7 +3,7 @@ module LuckySneaks
# methods but you're welcome to use them as needed in your own specs.
module CommonSpecHelpers
# Stubs out Time.now and returns value to use when comparing it. Example:
- #
+ #
# time_now = stub_time_now
# @foo.some_method_that_resets_updated_at
# @foo.updated_at.should == time_now
@@ -12,9 +12,9 @@ def stub_time_now
Time.stub!(:now).and_return(now)
end
end
-
+
# Returns class for the specified name. Example:
- #
+ #
# class_for("foo") # => Foo
def class_for(name)
name.to_s.constantize
@@ -24,18 +24,18 @@ def class_for(name)
end
# Returns instance variable for the specified name. Example:
- #
+ #
# instance_for("foo") # => @foo
def instance_for(name)
instance_variable_get("@#{name.to_s.underscore}")
end
-
- # Wraps a matcher that checks if the receiver contains an <tt>A</tt> element (link)
+
+ # Wraps a matcher that checks if the receiver contains an <tt>A</tt> element (link)
# whose <tt>href</tt> attribute is set to the specified path.
def have_link_to(path)
have_tag("a[href='#{path}']")
end
-
+
# Returns dummy value for specified attribute based on the datatype expected for that
# attribute.
def dummy_value_for(instance, attribute)
@@ -51,9 +51,12 @@ def dummy_value_for(instance, attribute)
when :date, :datetime, :time, :timestamp
actual == 1.week.ago ? 2.years.ago : 1.week.ago
end
+ else
+ # Not a column
+ "string should work at least for the uses in the internals"
end
end
-
+
# Returns class description text
def class_description_text
if self.class.respond_to?(:description_text)
@@ -64,7 +67,7 @@ def class_description_text
self.class.description
end
end
-
+
# Returns description text
def self_description_text
if respond_to?(:description_text)
@@ -75,7 +78,7 @@ def self_description_text
description
end
end
-
+
def described_type
self.class.described_type
end
Please sign in to comment.
Something went wrong with that request. Please try again.