data_magic 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.3-p0@data_magic --create
1
+ rvm 1.9.3-p194@data_magic --create
@@ -5,4 +5,3 @@ rvm:
5
5
  - 1.9.3
6
6
  - rbx-19mode
7
7
  - ree
8
- - ruby-head
data/ChangeLog CHANGED
@@ -1,3 +1,11 @@
1
+ == Version 0.9 / 2012-8-18
2
+ * Enhancements
3
+ * Added name_prefix translator
4
+ * Added name_suffix translator
5
+ * Added domain_name translator
6
+ * Added user_name translator
7
+ * Added characters translator
8
+
1
9
  === Version 0.8 / 2012-6-9
2
10
  * Enhancements
3
11
  * Made yml writable
data/README.md CHANGED
@@ -13,7 +13,8 @@ In order to use _data_magic_ you will have to inform the gem where it can find t
13
13
  DataMagic.yml_directory = 'data/yml'
14
14
  ````
15
15
 
16
- If you do not specify a directory the gem will default to using a directory named _config/data_. You should only have to set the directory once.
16
+ If you do not specify a directory the gem will default to using a directory named _config/data_.
17
+
17
18
 
18
19
  After setting the directory you must load a file. This can be accomplished by calling the _load_ method.
19
20
 
@@ -1 +1 @@
1
- default: --no-source --color --format pretty
1
+ default: --no-source --color --format Cucumber::Formatter::Fuubar
@@ -12,6 +12,8 @@ Feature: Functionality of the data_magic gem
12
12
  Then the value for "full_name" should have a minimum of 2 words
13
13
  And the value for "first_name" should be 1 word long
14
14
  And the value for "last_name" should be 1 word long
15
+ And the value for "name_prefix" should be 1 word long
16
+ And the value for "name_suffix" should be 1 word long
15
17
 
16
18
  Scenario: Getting addresses from the yaml
17
19
  Then the value for "street" should have a minimum of 2 words
@@ -27,6 +29,8 @@ Feature: Functionality of the data_magic gem
27
29
 
28
30
  Scenario: Getting an email address from the yaml
29
31
  Then the value for "email" should be 1 word long
32
+ And the value for "domain_name" should be 1 word long
33
+ And the value for "user_name" should be 1 word long
30
34
 
31
35
  Scenario: Getting a phone number
32
36
  Then the value for "phone" should have a minimum of 1 word
@@ -37,6 +41,7 @@ Feature: Functionality of the data_magic gem
37
41
  And the value for "sentence" should exist
38
42
  And the value for "sentences" should exist
39
43
  And the value for "paragraphs" should exist
44
+ And the value for "characters" should be 255 characters long
40
45
 
41
46
  Scenario: Boolean values
42
47
  Then the value for "bool_true" should be true
@@ -33,6 +33,10 @@ Then /^the value for "(.+)" should have a minimum of (\d+) word|wordss$/ do |key
33
33
  @data[key].split(' ').size.should >= length.to_i
34
34
  end
35
35
 
36
+ Then /^the value for "(.*?)" should be (\d+) characters long$/ do |key, length|
37
+ @data[key].length.should == length.to_i
38
+ end
39
+
36
40
  Then /^the value for "(.+)" should exist$/ do |key|
37
41
  @data[key].should_not be_nil
38
42
  end
@@ -4,6 +4,8 @@ dm:
4
4
  full_name: ~full_name
5
5
  first_name: ~first_name
6
6
  last_name: ~last_name
7
+ name_prefix: ~name_prefix
8
+ name_suffix: ~name_suffix
7
9
  street: ~street_address
8
10
  city: ~city
9
11
  state: ~state
@@ -13,12 +15,15 @@ dm:
13
15
  second_address: ~secondary_address
14
16
  company: ~company_name
15
17
  email: ~email_address
18
+ domain_name: ~domain_name
19
+ user_name: ~user_name
16
20
  phone: ~phone_number
17
21
  catch_phrase: ~catch_phrase
18
22
  words: ~words
19
23
  sentence: ~sentence
20
24
  sentences: ~sentences
21
25
  paragraphs: ~paragraphs
26
+ characters: ~characters
22
27
  bool_true: true
23
28
  bool_false: false
24
29
 
@@ -21,6 +21,20 @@ module DataMagic
21
21
  Faker::Name.last_name
22
22
  end
23
23
 
24
+ #
25
+ # return a random name prefix
26
+ #
27
+ def name_prefix
28
+ Faker::Name.prefix
29
+ end
30
+
31
+ #
32
+ # return a random name suffix
33
+ #
34
+ def name_suffix
35
+ Faker::Name.suffix
36
+ end
37
+
24
38
  #
25
39
  # return a random street address
26
40
  #
@@ -57,10 +71,10 @@ module DataMagic
57
71
  end
58
72
 
59
73
  #
60
- # return a random zip code
74
+ # return a random 5 or 9 digit zip code
61
75
  #
62
76
  def zip_code
63
- Faker::Address.zip_code
77
+ Faker::Address.zip
64
78
  end
65
79
 
66
80
  #
@@ -113,6 +127,13 @@ module DataMagic
113
127
  Faker::Lorem.paragraphs(paragraph_count).join('\n\n')
114
128
  end
115
129
 
130
+ #
131
+ # return random characters - default is 255 characters
132
+ #
133
+ def characters(character_count = 255)
134
+ Faker::Lorem.characters(character_count)
135
+ end
136
+
116
137
  #
117
138
  # return a random email address
118
139
  #
@@ -120,6 +141,20 @@ module DataMagic
120
141
  Faker::Internet.email
121
142
  end
122
143
 
144
+ #
145
+ # return a random domain name
146
+ #
147
+ def domain_name
148
+ Faker::Internet.domain_name
149
+ end
150
+
151
+ #
152
+ # return a random user name
153
+ #
154
+ def user_name
155
+ Faker::Internet.user_name
156
+ end
157
+
123
158
  #
124
159
  # return a random phone number
125
160
  #
@@ -1,3 +1,3 @@
1
1
  module DataMagic
2
- VERSION = "0.8"
2
+ VERSION = "0.9"
3
3
  end
@@ -66,6 +66,18 @@ describe "DataMagic translations" do
66
66
  set_field_value '~last_name'
67
67
  example.data_for('key').should have_field_value 'Smith'
68
68
  end
69
+
70
+ it "should add name prefix" do
71
+ Faker::Name.should_receive(:prefix).and_return("Mr")
72
+ set_field_value '~name_prefix'
73
+ example.data_for('key').should have_field_value 'Mr'
74
+ end
75
+
76
+ it "should add name suffix" do
77
+ Faker::Name.should_receive(:suffix).and_return('Jr')
78
+ set_field_value '~name_suffix'
79
+ example.data_for('key').should have_field_value 'Jr'
80
+ end
69
81
  end
70
82
 
71
83
  context "translating random addresses" do
@@ -94,7 +106,7 @@ describe "DataMagic translations" do
94
106
  end
95
107
 
96
108
  it "should add a zip code" do
97
- Faker::Address.should_receive(:zip_code).and_return('11111')
109
+ Faker::Address.should_receive(:zip).and_return('11111')
98
110
  set_field_value '~zip_code'
99
111
  example.data_for('key').should have_field_value '11111'
100
112
  end
@@ -120,12 +132,24 @@ describe "DataMagic translations" do
120
132
  end
121
133
  end
122
134
 
123
- context "translating email address" do
135
+ context "translating internet names" do
124
136
  it "should add an email address" do
125
137
  Faker::Internet.should_receive(:email).and_return('buddy@example.com')
126
138
  set_field_value '~email_address'
127
139
  example.data_for('key').should have_field_value 'buddy@example.com'
128
140
  end
141
+
142
+ it "should add a domain name" do
143
+ Faker::Internet.should_receive(:domain_name).and_return("google.com")
144
+ set_field_value '~domain_name'
145
+ example.data_for('key').should have_field_value 'google.com'
146
+ end
147
+
148
+ it "should add a user name" do
149
+ Faker::Internet.should_receive(:user_name).and_return('very_cheezy')
150
+ set_field_value '~user_name'
151
+ example.data_for('key').should have_field_value 'very_cheezy'
152
+ end
129
153
  end
130
154
 
131
155
  context "translating phone numbers" do
@@ -206,6 +230,12 @@ describe "DataMagic translations" do
206
230
  set_field_value '~paragraphs(10)'
207
231
  example.data_for('key')['field'].split('\n\n').size.should == 10
208
232
  end
233
+
234
+ it "should add characters" do
235
+ Faker::Lorem.should_receive(:characters).and_return('abcdefg')
236
+ set_field_value '~characters'
237
+ example.data_for('key').should have_field_value 'abcdefg'
238
+ end
209
239
  end
210
240
 
211
241
  context "translating boolean values" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-09 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faker
16
- requirement: &70281851755420 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70281851755420
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.1
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: yml_reader
27
- requirement: &70281851754920 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0.2'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70281851754920
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0.2'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &70281851754460 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.6.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70281851754460
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: cucumber
49
- requirement: &70281851754000 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: 1.1.0
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70281851754000
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.0
58
78
  description: Provides datasets to application stored in YAML files
59
79
  email:
60
80
  - jeff.morgan@leandog.com
@@ -99,15 +119,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
119
  - - ! '>='
100
120
  - !ruby/object:Gem::Version
101
121
  version: '0'
122
+ segments:
123
+ - 0
124
+ hash: -555664646600566693
102
125
  required_rubygems_version: !ruby/object:Gem::Requirement
103
126
  none: false
104
127
  requirements:
105
128
  - - ! '>='
106
129
  - !ruby/object:Gem::Version
107
130
  version: '0'
131
+ segments:
132
+ - 0
133
+ hash: -555664646600566693
108
134
  requirements: []
109
135
  rubyforge_project:
110
- rubygems_version: 1.8.10
136
+ rubygems_version: 1.8.24
111
137
  signing_key:
112
138
  specification_version: 3
113
139
  summary: Provides datasets to application via YAML files