Permalink
Browse files

added month abbreviation translation

  • Loading branch information...
1 parent a93a451 commit 03ca12e072b757a94293f8b8775d40d5355dcb37 @cheezy committed Feb 12, 2013
View
3 features/data_magic.feature
@@ -94,6 +94,9 @@ Feature: Functionality of the data_magic gem
Scenario: Getting a random month name
Then the value for "some_month" should be a valid month
+
+ Scenario: Getting a random month abbreviation
+ Then the value for "month_abbr" should be a valid month abbreviation
Scenario: It should allow one to add new translator methods
When I add the blah translator
View
4 features/step_definitions/data_magic_steps.rb
@@ -103,6 +103,10 @@ class TestClass
months.should include @data[key]
end
+Then /^the value for "(.*?)" should be a valid month abbreviation$/ do |key|
+ months = %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]
+ months.should include @data[key]
+end
When /^I add the blah translator$/ do
module Blah
View
1 features/yaml/example.yml
@@ -40,6 +40,7 @@ dm:
5daysfromtoday: ~5.days_from_today
5daysago: ~5.days_ago
some_month: ~month
+ month_abbr: ~month_abbr
dynamic:
blah: ~blah
View
7 lib/data_magic/date_translation.rb
@@ -49,5 +49,12 @@ def month
end
alias_method :dm_month, :month
+ #
+ # return a month abbreviation
+ #
+ def month_abbr
+ randomize(Date::ABBR_MONTHNAMES[1..-1])
+ end
+
end
end

0 comments on commit 03ca12e

Please sign in to comment.