Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added day_of_week translator

  • Loading branch information...
commit afe31d09903efa0aaebff7f81577758c983d6220 1 parent da6cc87
Jeff Morgan authored February 14, 2013
1  ChangeLog
... ...
@@ -1,6 +1,7 @@
1 1
 === Version 0.14
2 2
 * Enhancements
3 3
   * Added months_abbr translator
  4
+  * Added day_of_week translator
4 5
   * Changed so translator methods are not call after mixing with class
5 6
 
6 7
 === Version 0.13 / 2013-2-7
3  features/data_magic.feature
@@ -98,6 +98,9 @@ Feature: Functionality of the data_magic gem
98 98
   Scenario: Getting a random month abbreviation
99 99
     Then the value for "month_abbr" should be a valid month abbreviation
100 100
 
  101
+  Scenario: Getting a day name
  102
+    Then the value for "some_day" should be a valid day
  103
+
101 104
   Scenario: It should allow one to add new translator methods
102 105
     When I add the blah translator
103 106
     Then the value for "blah" should be "foobar"
5  features/step_definitions/data_magic_steps.rb
@@ -108,6 +108,11 @@ class TestClass
108 108
   months.should include @data[key]
109 109
 end
110 110
 
  111
+Then /^the value for "(.*?)" should be a valid day$/ do |key|
  112
+  days = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
  113
+  days.should include @data[key]
  114
+end
  115
+
111 116
 When /^I add the blah translator$/ do
112 117
   module Blah
113 118
     def blah
1  features/yaml/example.yml
@@ -41,6 +41,7 @@ dm:
41 41
   5daysago: ~5.days_ago
42 42
   some_month: ~month
43 43
   month_abbr: ~month_abbr
  44
+  some_day: ~day_of_week
44 45
 
45 46
 dynamic:
46 47
   blah: ~blah
10  lib/data_magic/date_translation.rb
@@ -55,6 +55,16 @@ def month
55 55
     def month_abbr
56 56
       randomize(Date::ABBR_MONTHNAMES[1..-1])
57 57
     end
  58
+    alias_method :dm_month_abbr, :month_abbr
58 59
 
  60
+    #
  61
+    # return a day of the week
  62
+    #
  63
+    def day_of_week
  64
+      randomize(Date::DAYNAMES)
  65
+    end
  66
+    alias_method :dm_day_of_week, :day_of_week
  67
+
  68
+    
59 69
   end
60 70
 end

0 notes on commit afe31d0

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