data_magic 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +8 -0
- data/features/yaml/example.yml +2 -2
- data/lib/data_magic.rb +2 -1
- data/lib/data_magic/translation.rb +2 -2
- data/lib/data_magic/version.rb +1 -1
- data/spec/lib/translation_spec.rb +19 -3
- metadata +9 -8
data/ChangeLog
ADDED
data/features/yaml/example.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
dm:
|
2
2
|
value1: this is value 1
|
3
3
|
value2: this is value 2
|
4
|
-
full_name: ~
|
4
|
+
full_name: ~full_name
|
5
5
|
first_name: ~first_name
|
6
6
|
last_name: ~last_name
|
7
7
|
street: ~street_address
|
@@ -12,7 +12,7 @@ dm:
|
|
12
12
|
country: ~country
|
13
13
|
second_address: ~secondary_address
|
14
14
|
company: ~company_name
|
15
|
-
email: ~
|
15
|
+
email: ~email_address
|
16
16
|
phone: ~phone_number
|
17
17
|
catch_phrase: ~catch_phrase
|
18
18
|
words: ~words
|
data/lib/data_magic.rb
CHANGED
@@ -3,7 +3,7 @@ module DataMagic
|
|
3
3
|
#
|
4
4
|
# return a random name (first and last)
|
5
5
|
#
|
6
|
-
def
|
6
|
+
def full_name
|
7
7
|
Faker::Name.name
|
8
8
|
end
|
9
9
|
|
@@ -116,7 +116,7 @@ module DataMagic
|
|
116
116
|
#
|
117
117
|
# return a random email address
|
118
118
|
#
|
119
|
-
def
|
119
|
+
def email_address
|
120
120
|
Faker::Internet.email
|
121
121
|
end
|
122
122
|
|
data/lib/data_magic/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe "DataMagic translations" do
|
|
9
9
|
let(:example) { TestSubject.new }
|
10
10
|
|
11
11
|
def set_field_value(value)
|
12
|
-
DataMagic.should_receive(:yml).and_return({'key' => {'field' => value}})
|
12
|
+
DataMagic.should_receive(:yml).twice.and_return({'key' => {'field' => value}})
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should deliver the hash from the yaml" do
|
@@ -18,10 +18,26 @@ describe "DataMagic translations" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
|
21
|
+
it "should default to use a file named 'default.yml'" do
|
22
|
+
DataMagic::Config.yml_directory = 'test'
|
23
|
+
YAML.should_receive(:load_file).with("test/default.yml").and_return({})
|
24
|
+
DataMagic.should_receive(:yml).and_return(nil)
|
25
|
+
DataMagic.should_receive(:yml).and_return({'key' => {'field' => 'value'}})
|
26
|
+
example.data_for('key').should have_field_value 'value'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should clone the data returned so it can be resued" do
|
30
|
+
yaml = double('yaml')
|
31
|
+
DataMagic.should_receive(:yml).twice.and_return(yaml)
|
32
|
+
yaml.should_receive(:[]).and_return(yaml)
|
33
|
+
yaml.should_receive(:clone).and_return({'field' => 'value'})
|
34
|
+
example.data_for('key').should have_field_value 'value'
|
35
|
+
end
|
36
|
+
|
21
37
|
context "translating random names" do
|
22
38
|
it "should add a name" do
|
23
39
|
Faker::Name.should_receive(:name).and_return('Joseph')
|
24
|
-
set_field_value '~
|
40
|
+
set_field_value '~full_name'
|
25
41
|
example.data_for('key').should have_field_value 'Joseph'
|
26
42
|
end
|
27
43
|
|
@@ -93,7 +109,7 @@ describe "DataMagic translations" do
|
|
93
109
|
context "translating email address" do
|
94
110
|
it "should add an email address" do
|
95
111
|
Faker::Internet.should_receive(:email).and_return('buddy@example.com')
|
96
|
-
set_field_value '~
|
112
|
+
set_field_value '~email_address'
|
97
113
|
example.data_for('key').should have_field_value 'buddy@example.com'
|
98
114
|
end
|
99
115
|
end
|
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.
|
4
|
+
version: '0.2'
|
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-01-
|
12
|
+
date: 2012-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faker
|
16
|
-
requirement: &
|
16
|
+
requirement: &70313484608100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70313484608100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70313484607300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70313484607300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cucumber
|
38
|
-
requirement: &
|
38
|
+
requirement: &70313484606540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70313484606540
|
47
47
|
description: Provides datasets to application stored in YAML files
|
48
48
|
email:
|
49
49
|
- jeff.morgan@leandog.com
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- .gitignore
|
55
55
|
- .rspec
|
56
56
|
- .rvmrc
|
57
|
+
- ChangeLog
|
57
58
|
- Gemfile
|
58
59
|
- Guardfile
|
59
60
|
- LICENSE
|