Permalink
Browse files

added day_of_week translator

  • Loading branch information...
1 parent da6cc87 commit afe31d09903efa0aaebff7f81577758c983d6220 @cheezy committed Feb 15, 2013
View
@@ -1,6 +1,7 @@
=== Version 0.14
* Enhancements
* Added months_abbr translator
+ * Added day_of_week translator
* Changed so translator methods are not call after mixing with class
=== Version 0.13 / 2013-2-7
@@ -98,6 +98,9 @@ Feature: Functionality of the data_magic gem
Scenario: Getting a random month abbreviation
Then the value for "month_abbr" should be a valid month abbreviation
+ Scenario: Getting a day name
+ Then the value for "some_day" should be a valid day
+
Scenario: It should allow one to add new translator methods
When I add the blah translator
Then the value for "blah" should be "foobar"
@@ -108,6 +108,11 @@ class TestClass
months.should include @data[key]
end
+Then /^the value for "(.*?)" should be a valid day$/ do |key|
+ days = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
+ days.should include @data[key]
+end
+
When /^I add the blah translator$/ do
module Blah
def blah
@@ -41,6 +41,7 @@ dm:
5daysago: ~5.days_ago
some_month: ~month
month_abbr: ~month_abbr
+ some_day: ~day_of_week
dynamic:
blah: ~blah
@@ -55,6 +55,16 @@ def month
def month_abbr
randomize(Date::ABBR_MONTHNAMES[1..-1])
end
+ alias_method :dm_month_abbr, :month_abbr
+ #
+ # return a day of the week
+ #
+ def day_of_week
+ randomize(Date::DAYNAMES)
+ end
+ alias_method :dm_day_of_week, :day_of_week
+
+
end
end

0 comments on commit afe31d0

Please sign in to comment.