data_magic 0.19 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,307 +1,14 @@
1
1
  require 'data_magic/date_translation'
2
+ require 'data_magic/standard_translation'
2
3
 
3
4
  module DataMagic
4
5
  class Translation
6
+ include StandardTranslation
5
7
  include DateTranslation
6
8
 
7
- attr_reader :parent
8
-
9
9
  def initialize(parent)
10
10
  @parent = parent
11
11
  end
12
12
 
13
- #
14
- # return a random name (first and last)
15
- #
16
- def full_name
17
- Faker::Name.name
18
- end
19
- alias_method :dm_full_name, :full_name
20
-
21
- #
22
- # return a random first name
23
- #
24
- def first_name
25
- Faker::Name.first_name
26
- end
27
- alias_method :dm_first_name, :first_name
28
-
29
- #
30
- # return a random last name
31
- #
32
- def last_name
33
- Faker::Name.last_name
34
- end
35
- alias_method :dm_last_name, :last_name
36
-
37
- #
38
- # return a random name prefix
39
- #
40
- def name_prefix
41
- Faker::Name.prefix
42
- end
43
- alias_method :dm_name_prefix, :name_prefix
44
-
45
- #
46
- # return a random name suffix
47
- #
48
- def name_suffix
49
- Faker::Name.suffix
50
- end
51
- alias_method :dm_name_suffix, :name_suffix
52
-
53
- #
54
- # return a random title
55
- #
56
- def title
57
- Faker::Name.title
58
- end
59
- alias_method :dm_title, :title
60
-
61
- #
62
- # return a random street address
63
- #
64
- def street_address(include_secondary=false)
65
- Faker::Address.street_address(include_secondary)
66
- end
67
- alias_method :dm_street_address, :street_address
68
-
69
- #
70
- # return a random secondary address
71
- #
72
- def secondary_address
73
- Faker::Address.secondary_address
74
- end
75
- alias_method :dm_secondary_address, :secondary_address
76
-
77
- #
78
- # return a random city
79
- #
80
- def city
81
- Faker::Address.city
82
- end
83
- alias_method :dm_city, :city
84
-
85
- #
86
- # return a random state
87
- #
88
- def state
89
- Faker::Address.state
90
- end
91
- alias_method :dm_state, :state
92
-
93
- #
94
- # return a random state abbreviation
95
- #
96
- def state_abbr
97
- Faker::Address.state_abbr
98
- end
99
- alias_method :dm_state_abbr, :state_abbr
100
-
101
- #
102
- # return a random 5 or 9 digit zip code
103
- #
104
- def zip_code
105
- Faker::Address.zip
106
- end
107
- alias_method :dm_zip_code, :zip_code
108
-
109
- #
110
- # return a random country
111
- #
112
- def country
113
- Faker::Address.country
114
- end
115
- alias_method :dm_country, :country
116
-
117
-
118
- #
119
- # return a random company name
120
- #
121
- def company_name
122
- Faker::Company.name
123
- end
124
- alias_method :dm_company_name, :company_name
125
-
126
- #
127
- # return a random catch phrase
128
- #
129
- def catch_phrase
130
- Faker::Company.catch_phrase
131
- end
132
- alias_method :dm_catch_phrase, :catch_phrase
133
-
134
- #
135
- # return random words - default is 3 words
136
- #
137
- def words(number = 3)
138
- Faker::Lorem.words(number).join(' ')
139
- end
140
- alias_method :dm_words, :words
141
-
142
- #
143
- # return a random sentence - default minimum word count is 4
144
- #
145
- def sentence(min_word_count = 4)
146
- Faker::Lorem.sentence(min_word_count)
147
- end
148
- alias_method :dm_sentence, :sentence
149
-
150
- #
151
- # return random sentences - default is 3 sentences
152
- #
153
- def sentences(sentence_count = 3)
154
- Faker::Lorem.sentences(sentence_count).join(' ')
155
- end
156
- alias_method :dm_sentences, :sentences
157
-
158
- #
159
- # return random paragraphs - default is 3 paragraphs
160
- #
161
- def paragraphs(paragraph_count = 3)
162
- Faker::Lorem.paragraphs(paragraph_count).join('\n\n')
163
- end
164
- alias_method :dm_paragraphs, :paragraphs
165
-
166
- #
167
- # return random characters - default is 255 characters
168
- #
169
- def characters(character_count = 255)
170
- Faker::Lorem.characters(character_count)
171
- end
172
- alias_method :dm_characters, :characters
173
-
174
- #
175
- # return a random email address
176
- #
177
- def email_address(name=nil)
178
- Faker::Internet.email(name)
179
- end
180
- alias_method :dm_email_address, :email_address
181
-
182
- #
183
- # return a random domain name
184
- #
185
- def domain_name
186
- Faker::Internet.domain_name
187
- end
188
- alias_method :dm_domain_name, :domain_name
189
-
190
- #
191
- # return a random url
192
- #
193
- def url
194
- Faker::Internet.url
195
- end
196
- alias_method :dm_url, :url
197
-
198
- #
199
- # return a random user name
200
- #
201
- def user_name
202
- Faker::Internet.user_name
203
- end
204
- alias_method :dm_user_name, :user_name
205
-
206
- #
207
- # return a random phone number
208
- #
209
- def phone_number
210
- value = Faker::PhoneNumber.phone_number
211
- remove_extension(value)
212
- end
213
- alias_method :dm_phone_number, :phone_number
214
-
215
- #
216
- # return a random cell number
217
- #
218
- def cell_phone
219
- value = Faker::PhoneNumber.cell_phone
220
- remove_extension(value)
221
- end
222
- alias_method :dm_cell_phone, :cell_phone
223
-
224
- #
225
- # return a random value from an array or range
226
- #
227
- def randomize(value)
228
- case value
229
- when Array then value[rand(value.size)]
230
- when Range then rand((value.last+1) - value.first) + value.first
231
- else value
232
- end
233
- end
234
- alias_method :dm_randomize, :randomize
235
-
236
- #
237
- # return an element from the array. The first request will return
238
- # the first element, the second request will return the second,
239
- # and so forth.
240
- #
241
- def sequential(value)
242
- index = index_variable_for(value)
243
- index = (index ? index + 1 : 0)
244
- index = 0 if index == value.length
245
- set_index_variable(value, index)
246
- value[index]
247
- end
248
-
249
- #
250
- # return a value based on a mast
251
- # The # character will be replaced with a number
252
- # The A character will be replaced with an upper case letter
253
- # The a character will be replaced with a lower case letter
254
- #
255
- def mask(value)
256
- result = ''
257
- value.each_char do |ch|
258
- case ch
259
- when '#' then result += randomize(0..9).to_s
260
- when 'A' then result += ('A'..'Z').to_a[rand(26)]
261
- when 'a' then result += ('a'..'z').to_a[rand(26)]
262
- else result += ch
263
- end
264
- end
265
- result
266
- end
267
- alias_method :dm_mask, :mask
268
-
269
-
270
-
271
- private
272
-
273
- def set_index_variable(ary, value)
274
- index_hash[index_name(ary)] = value
275
- end
276
-
277
- def index_variable_for(ary)
278
- value = index_hash[index_name(ary)]
279
- index_hash[index_name(ary)] = -1 unless value
280
- index_hash[index_name(ary)]
281
- end
282
-
283
- def index_name(ary)
284
- "#{ary[0]}#{ary[1]}_index".gsub(' ', '_').downcase
285
- end
286
-
287
- def index_hash
288
- dh = data_hash[parent]
289
- data_hash[parent] = {} unless dh
290
- data_hash[parent]
291
- end
292
-
293
- def data_hash
294
- $data_magic_data_hash ||= {}
295
- end
296
-
297
- def process(value)
298
- eval value
299
- end
300
-
301
- def remove_extension(phone)
302
- index = phone.index('x')
303
- phone = phone[0, (index-1)] if index
304
- phone
305
- end
306
13
  end
307
14
  end
@@ -1,3 +1,3 @@
1
1
  module DataMagic
2
- VERSION = "0.19"
2
+ VERSION = "0.20"
3
3
  end
@@ -11,19 +11,19 @@ describe DataMagic do
11
11
  end
12
12
 
13
13
  it "should default to a directory named config" do
14
- DataMagic.yml_directory.should == 'config/data'
14
+ expect(DataMagic.yml_directory).to eql 'config/data'
15
15
  end
16
16
 
17
17
  it "should store a yml directory" do
18
18
  DataMagic.yml_directory = 'test_dir'
19
- DataMagic.yml_directory.should == 'test_dir'
19
+ expect(DataMagic.yml_directory).to eql 'test_dir'
20
20
  end
21
21
  end
22
22
 
23
23
  context "when reading yml files" do
24
24
  it "should read files from the config directory" do
25
25
  DataMagic.yml_directory = 'test'
26
- File.should_receive(:read).with("test/fname").and_return('test')
26
+ expect(File).to receive(:read).with("test/fname").and_return('test')
27
27
  DataMagic.load("fname")
28
28
  end
29
29
 
@@ -9,251 +9,251 @@ describe "DataMagic translations" do
9
9
  let(:example) { TestSubject.new }
10
10
 
11
11
  def set_field_value(value)
12
- DataMagic.should_receive(:yml).twice.and_return({'key' => {'field' => value}})
12
+ expect(DataMagic).to receive(:yml).twice.and_return({'key' => {'field' => value}})
13
13
  end
14
14
 
15
15
  it "should deliver the hash from the yaml" do
16
16
  set_field_value 'value'
17
- example.data_for('key').should have_field_value 'value'
17
+ expect(example.data_for('key')).to have_field_value 'value'
18
18
  end
19
19
 
20
20
  it "should allow you to use a symbol for the key" do
21
21
  set_field_value 'value'
22
- example.data_for(:key).should have_field_value 'value'
22
+ expect(example.data_for(:key)).to have_field_value 'value'
23
23
  end
24
24
 
25
25
  it "should default to use a file named 'default.yml'" do
26
26
  DataMagic.yml_directory = 'test'
27
- File.should_receive(:read).with("test/default.yml").and_return('test')
28
- DataMagic.should_receive(:yml).and_return(nil)
29
- DataMagic.should_receive(:yml).and_return({'key' => {'field' => 'value'}})
30
- example.data_for('key').should have_field_value 'value'
27
+ expect(File).to receive(:read).with("test/default.yml").and_return('test')
28
+ expect(DataMagic).to receive(:yml).and_return(nil)
29
+ expect(DataMagic).to receive(:yml).and_return({'key' => {'field' => 'value'}})
30
+ expect(example.data_for('key')).to have_field_value 'value'
31
31
  end
32
32
 
33
33
  it "should clone the data returned so it can be resued" do
34
34
  yaml = double('yaml')
35
- yaml.stub(:merge).and_return(yaml)
36
- DataMagic.should_receive(:yml).twice.and_return(yaml)
37
- yaml.should_receive(:[]).and_return(yaml)
38
- yaml.should_receive(:clone).and_return({'field' => 'value'})
39
- example.data_for('key').should have_field_value 'value'
35
+ expect(yaml).to receive(:merge).and_return(yaml)
36
+ expect(DataMagic).to receive(:yml).twice.and_return(yaml)
37
+ expect(yaml).to receive(:[]).and_return(yaml)
38
+ expect(yaml).to receive(:clone).and_return({'field' => 'value'})
39
+ expect(example.data_for('key')).to have_field_value 'value'
40
40
  end
41
41
 
42
42
  it "should merge the provided data with the yaml data" do
43
43
  yaml = double('yaml')
44
- DataMagic.should_receive(:yml).twice.and_return(yaml)
45
- yaml.should_receive(:[]).and_return(yaml)
46
- yaml.should_receive(:merge).and_return(yaml)
47
- yaml.should_receive(:clone).and_return({'field' => 'value'})
48
- example.data_for('key').should have_field_value 'value'
44
+ expect(DataMagic).to receive(:yml).twice.and_return(yaml)
45
+ expect(yaml).to receive(:[]).and_return(yaml)
46
+ expect(yaml).to receive(:merge).and_return(yaml)
47
+ expect(yaml).to receive(:clone).and_return({'field' => 'value'})
48
+ expect(example.data_for('key')).to have_field_value 'value'
49
49
  end
50
50
 
51
51
  context "translating random names" do
52
52
  it "should add a name" do
53
- Faker::Name.should_receive(:name).and_return('Joseph')
53
+ expect(Faker::Name).to receive(:name).and_return('Joseph')
54
54
  set_field_value '~full_name'
55
- example.data_for('key').should have_field_value 'Joseph'
55
+ expect(example.data_for('key')).to have_field_value 'Joseph'
56
56
  end
57
57
 
58
58
  it "should add first name" do
59
- Faker::Name.should_receive(:first_name).and_return('Sam')
59
+ expect(Faker::Name).to receive(:first_name).and_return('Sam')
60
60
  set_field_value '~first_name'
61
- example.data_for('key').should have_field_value 'Sam'
61
+ expect(example.data_for('key')).to have_field_value 'Sam'
62
62
  end
63
63
 
64
64
  it "should add last name" do
65
- Faker::Name.should_receive(:last_name).and_return('Smith')
65
+ expect(Faker::Name).to receive(:last_name).and_return('Smith')
66
66
  set_field_value '~last_name'
67
- example.data_for('key').should have_field_value 'Smith'
67
+ expect(example.data_for('key')).to have_field_value 'Smith'
68
68
  end
69
69
 
70
70
  it "should add name prefix" do
71
- Faker::Name.should_receive(:prefix).and_return("Mr")
71
+ expect(Faker::Name).to receive(:prefix).and_return("Mr")
72
72
  set_field_value '~name_prefix'
73
- example.data_for('key').should have_field_value 'Mr'
73
+ expect(example.data_for('key')).to have_field_value 'Mr'
74
74
  end
75
75
 
76
76
  it "should add name suffix" do
77
- Faker::Name.should_receive(:suffix).and_return('Jr')
77
+ expect(Faker::Name).to receive(:suffix).and_return('Jr')
78
78
  set_field_value '~name_suffix'
79
- example.data_for('key').should have_field_value 'Jr'
79
+ expect(example.data_for('key')).to have_field_value 'Jr'
80
80
  end
81
81
  end
82
82
 
83
83
  context "translating random addresses" do
84
84
  it "should add a street address" do
85
- Faker::Address.should_receive(:street_address).and_return("123 Main")
85
+ expect(Faker::Address).to receive(:street_address).and_return("123 Main")
86
86
  set_field_value '~street_address'
87
- example.data_for('key').should have_field_value '123 Main'
87
+ expect(example.data_for('key')).to have_field_value '123 Main'
88
88
  end
89
89
 
90
90
  it "should add a city" do
91
- Faker::Address.should_receive(:city).and_return('Cleveland')
91
+ expect(Faker::Address).to receive(:city).and_return('Cleveland')
92
92
  set_field_value '~city'
93
- example.data_for('key').should have_field_value 'Cleveland'
93
+ expect(example.data_for('key')).to have_field_value 'Cleveland'
94
94
  end
95
95
 
96
96
  it "should add a state" do
97
- Faker::Address.should_receive(:state).and_return('Ohio')
97
+ expect(Faker::Address).to receive(:state).and_return('Ohio')
98
98
  set_field_value '~state'
99
- example.data_for('key').should have_field_value 'Ohio'
99
+ expect(example.data_for('key')).to have_field_value 'Ohio'
100
100
  end
101
101
 
102
102
  it "should add a state abbreviation" do
103
- Faker::Address.should_receive(:state_abbr).and_return('OH')
103
+ expect(Faker::Address).to receive(:state_abbr).and_return('OH')
104
104
  set_field_value '~state_abbr'
105
- example.data_for('key').should have_field_value 'OH'
105
+ expect(example.data_for('key')).to have_field_value 'OH'
106
106
  end
107
107
 
108
108
  it "should add a zip code" do
109
- Faker::Address.should_receive(:zip).and_return('11111')
109
+ expect(Faker::Address).to receive(:zip).and_return('11111')
110
110
  set_field_value '~zip_code'
111
- example.data_for('key').should have_field_value '11111'
111
+ expect(example.data_for('key')).to have_field_value '11111'
112
112
  end
113
113
 
114
114
  it "should add a country" do
115
- Faker::Address.should_receive(:country).and_return("United States")
115
+ expect(Faker::Address).to receive(:country).and_return("United States")
116
116
  set_field_value '~country'
117
- example.data_for('key').should have_field_value 'United States'
117
+ expect(example.data_for('key')).to have_field_value 'United States'
118
118
  end
119
119
 
120
120
  it "should add a secondary address" do
121
- Faker::Address.should_receive(:secondary_address).and_return('2nd floor')
121
+ expect(Faker::Address).to receive(:secondary_address).and_return('2nd floor')
122
122
  set_field_value '~secondary_address'
123
- example.data_for('key').should have_field_value '2nd floor'
123
+ expect(example.data_for('key')).to have_field_value '2nd floor'
124
124
  end
125
125
  end
126
126
 
127
127
  context "translating company names" do
128
128
  it "should add a company name" do
129
- Faker::Company.should_receive(:name).and_return('LeanDog')
129
+ expect(Faker::Company).to receive(:name).and_return('LeanDog')
130
130
  set_field_value '~company_name'
131
- example.data_for('key').should have_field_value 'LeanDog'
131
+ expect(example.data_for('key')).to have_field_value 'LeanDog'
132
132
  end
133
133
  end
134
134
 
135
135
  context "translating internet names" do
136
136
  it "should add an email address" do
137
- Faker::Internet.should_receive(:email).and_return('buddy@example.com')
137
+ expect(Faker::Internet).to receive(:email).and_return('buddy@example.com')
138
138
  set_field_value '~email_address'
139
- example.data_for('key').should have_field_value 'buddy@example.com'
139
+ expect(example.data_for('key')).to have_field_value 'buddy@example.com'
140
140
  end
141
141
 
142
142
  it "should add a domain name" do
143
- Faker::Internet.should_receive(:domain_name).and_return("google.com")
143
+ expect(Faker::Internet).to receive(:domain_name).and_return("google.com")
144
144
  set_field_value '~domain_name'
145
- example.data_for('key').should have_field_value 'google.com'
145
+ expect(example.data_for('key')).to have_field_value 'google.com'
146
146
  end
147
147
 
148
148
  it "should add a user name" do
149
- Faker::Internet.should_receive(:user_name).and_return('very_cheezy')
149
+ expect(Faker::Internet).to receive(:user_name).and_return('very_cheezy')
150
150
  set_field_value '~user_name'
151
- example.data_for('key').should have_field_value 'very_cheezy'
151
+ expect(example.data_for('key')).to have_field_value 'very_cheezy'
152
152
  end
153
153
  end
154
154
 
155
155
  context "translating phone numbers" do
156
156
  it "shold add a phone number" do
157
- Faker::PhoneNumber.should_receive(:phone_number).and_return('555-555-5555')
157
+ expect(Faker::PhoneNumber).to receive(:phone_number).and_return('555-555-5555')
158
158
  set_field_value '~phone_number'
159
- example.data_for('key').should have_field_value '555-555-5555'
159
+ expect(example.data_for('key')).to have_field_value '555-555-5555'
160
160
  end
161
161
  end
162
162
 
163
163
  context "translating random phrases" do
164
164
  it "should add a catch phrase" do
165
- Faker::Company.should_receive(:catch_phrase).and_return('Ruby is cool')
165
+ expect(Faker::Company).to receive(:catch_phrase).and_return('Ruby is cool')
166
166
  set_field_value '~catch_phrase'
167
- example.data_for('key').should have_field_value 'Ruby is cool'
167
+ expect(example.data_for('key')).to have_field_value 'Ruby is cool'
168
168
  end
169
169
 
170
170
  it "should add random words" do
171
- Faker::Lorem.should_receive(:words).and_return(['random', 'words'])
171
+ expect(Faker::Lorem).to receive(:words).and_return(['random', 'words'])
172
172
  set_field_value '~words'
173
- example.data_for('key').should have_field_value 'random words'
173
+ expect(example.data_for('key')).to have_field_value 'random words'
174
174
  end
175
175
 
176
176
  it "should default to returning 3 words" do
177
177
  set_field_value '~words'
178
- example.data_for('key')['field'].split.size.should == 3
178
+ expect(example.data_for('key')['field'].split.size).to eql 3
179
179
  end
180
180
 
181
181
  it "should allow you to specify the number of words" do
182
182
  set_field_value '~words(4)'
183
- example.data_for('key')['field'].split.size.should == 4
183
+ expect(example.data_for('key')['field'].split.size).to eql 4
184
184
  end
185
185
 
186
186
  it "should add a random sentence" do
187
- Faker::Lorem.should_receive(:sentence).and_return('a sentence')
187
+ expect(Faker::Lorem).to receive(:sentence).and_return('a sentence')
188
188
  set_field_value '~sentence'
189
- example.data_for('key').should have_field_value 'a sentence'
189
+ expect(example.data_for('key')).to have_field_value 'a sentence'
190
190
  end
191
191
 
192
192
  it "should default to returning a minimum of 4 words" do
193
193
  set_field_value '~sentence'
194
- example.data_for('key')['field'].split.size.should >= 4
194
+ expect(example.data_for('key')['field'].split.size).to be >= 4
195
195
  end
196
196
 
197
197
  it "should allow you to specify a minimum word count" do
198
198
  set_field_value '~sentence(20)'
199
- example.data_for('key')['field'].split.size.should >= 20
199
+ expect(example.data_for('key')['field'].split.size).to be >= 20
200
200
  end
201
201
 
202
202
  it "should add sentences" do
203
- Faker::Lorem.should_receive(:sentences).and_return(['this is sentences'])
203
+ expect(Faker::Lorem).to receive(:sentences).and_return(['this is sentences'])
204
204
  set_field_value '~sentences'
205
- example.data_for('key').should have_field_value 'this is sentences'
205
+ expect(example.data_for('key')).to have_field_value 'this is sentences'
206
206
  end
207
207
 
208
208
  it "should default to returning a default of 3 sentences" do
209
209
  set_field_value '~sentences'
210
- example.data_for('key')['field'].split('.').size.should >= 3
210
+ expect(example.data_for('key')['field'].split('.').size).to be >= 3
211
211
  end
212
212
 
213
213
  it "should allow you to specify the number of sentences" do
214
214
  set_field_value '~sentences(10)'
215
- example.data_for('key')['field'].split('.').size.should >= 10
215
+ expect(example.data_for('key')['field'].split('.').size).to be >= 10
216
216
  end
217
217
 
218
218
  it "should add a paragraphs" do
219
- Faker::Lorem.should_receive(:paragraphs).and_return(['this is a paragraph'])
219
+ expect(Faker::Lorem).to receive(:paragraphs).and_return(['this is a paragraph'])
220
220
  set_field_value '~paragraphs'
221
- example.data_for('key').should have_field_value 'this is a paragraph'
221
+ expect(example.data_for('key')).to have_field_value 'this is a paragraph'
222
222
  end
223
223
 
224
224
  it "should return 3 paragraphs by default" do
225
225
  set_field_value '~paragraphs'
226
- example.data_for('key')['field'].split('\n\n').size.should == 3
226
+ expect(example.data_for('key')['field'].split('\n\n').size).to eql 3
227
227
  end
228
228
 
229
229
  it "should allow you to specify the number of paragraphs" do
230
230
  set_field_value '~paragraphs(10)'
231
- example.data_for('key')['field'].split('\n\n').size.should == 10
231
+ expect(example.data_for('key')['field'].split('\n\n').size).to eql 10
232
232
  end
233
233
 
234
234
  it "should add characters" do
235
- Faker::Lorem.should_receive(:characters).and_return('abcdefg')
235
+ expect(Faker::Lorem).to receive(:characters).and_return('abcdefg')
236
236
  set_field_value '~characters'
237
- example.data_for('key').should have_field_value 'abcdefg'
237
+ expect(example.data_for('key')).to have_field_value 'abcdefg'
238
238
  end
239
239
  end
240
240
 
241
241
  context "translating boolean values" do
242
242
  it "should resolve true" do
243
243
  set_field_value true
244
- example.data_for('key').should have_field_value true
244
+ expect(example.data_for('key')).to have_field_value true
245
245
  end
246
246
 
247
247
  it "should resolve false" do
248
248
  set_field_value false
249
- example.data_for('key').should have_field_value false
249
+ expect(example.data_for('key')).to have_field_value false
250
250
  end
251
251
  end
252
252
 
253
253
  context "with numeric values" do
254
254
  it "doesn't translate values" do
255
255
  set_field_value(1)
256
- example.data_for("key").should have_field_value 1
256
+ expect(example.data_for("key")).to have_field_value 1
257
257
  end
258
258
  end
259
259
 
@@ -266,31 +266,31 @@ describe "DataMagic translations" do
266
266
  context "providing date values" do
267
267
  it "should provide today's date" do
268
268
  set_field_value '~today'
269
- example.data_for('key').should have_field_value Date.today.strftime('%D')
269
+ expect(example.data_for('key')).to have_field_value Date.today.strftime('%D')
270
270
  end
271
271
 
272
272
  it "should provide tomorrow's date" do
273
273
  set_field_value '~tomorrow'
274
274
  tomorrow = Date.today + 1
275
- example.data_for('key').should have_field_value tomorrow.strftime('%D')
275
+ expect(example.data_for('key')).to have_field_value tomorrow.strftime('%D')
276
276
  end
277
277
 
278
278
  it "should provide yesterday's date" do
279
279
  set_field_value '~yesterday'
280
280
  yesterday = Date.today - 1
281
- example.data_for('key').should have_field_value yesterday.strftime('%D')
281
+ expect(example.data_for('key')).to have_field_value yesterday.strftime('%D')
282
282
  end
283
283
 
284
284
  it "should provide a date that is some number of days from now" do
285
285
  set_field_value '~5.days_from_today'
286
286
  the_date = Date.today + 5
287
- example.data_for('key').should have_field_value the_date.strftime('%D')
287
+ expect(example.data_for('key')).to have_field_value the_date.strftime('%D')
288
288
  end
289
289
 
290
290
  it "should provide a date that is some number of days ago" do
291
291
  set_field_value '~5.days_ago'
292
292
  the_date = Date.today - 5
293
- example.data_for('key').should have_field_value the_date.strftime('%D')
293
+ expect(example.data_for('key')).to have_field_value the_date.strftime('%D')
294
294
  end
295
295
  end
296
296
  end