fig_magic 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/FigMagic.iml +33 -0
- data/.idea/atlassian-ide-plugin.xml +5 -0
- data/.idea/encodings.xml +6 -0
- data/.idea/misc.xml +14 -0
- data/.idea/modules.xml +8 -0
- data/.idea/workspace.xml +776 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/ChangeLog +2 -0
- data/Gemfile +12 -0
- data/Guardfile +16 -0
- data/LICENSE +22 -0
- data/README.md +145 -0
- data/Rakefile +25 -0
- data/config/data/default.yml +3 -0
- data/config/data/user.yml +3 -0
- data/config/environments/default.yml +1 -0
- data/config/yaml/sample.yml +1 -0
- data/config/yaml/test_config.yml +14 -0
- data/cucumber.yml +2 -0
- data/features/data_magic.feature +124 -0
- data/features/defaults.feature +8 -0
- data/features/fig_newton.feature +85 -0
- data/features/step_definitions/data_magic_steps.rb +164 -0
- data/features/step_definitions/fig_newton_steps.rb +95 -0
- data/features/support/env.rb +9 -0
- data/features/yaml/another.yml +9 -0
- data/features/yaml/example.yml +56 -0
- data/fig_magic.gemspec +25 -0
- data/lib/fig_magic/core_ext/fixnum.rb +11 -0
- data/lib/fig_magic/core_ext/string.rb +5 -0
- data/lib/fig_magic/date_translation.rb +73 -0
- data/lib/fig_magic/missing.rb +35 -0
- data/lib/fig_magic/node.rb +15 -0
- data/lib/fig_magic/standard_translation.rb +316 -0
- data/lib/fig_magic/translation.rb +14 -0
- data/lib/fig_magic/version.rb +3 -0
- data/lib/fig_magic.rb +93 -0
- data/spec/lib/data_magic_spec.rb +60 -0
- data/spec/lib/translation_spec.rb +312 -0
- data/spec/spec_helper.rb +30 -0
- metadata +158 -0
data/lib/fig_magic.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#DataMagic Requires
|
2
|
+
require 'fig_magic/core_ext/string'
|
3
|
+
require 'fig_magic/core_ext/fixnum'
|
4
|
+
require 'fig_magic/translation'
|
5
|
+
require 'fig_magic/date_translation'
|
6
|
+
require 'fig_magic/standard_translation'
|
7
|
+
require 'faker'
|
8
|
+
|
9
|
+
#FigNewton Requires
|
10
|
+
require 'fig_magic/node'
|
11
|
+
require 'fig_magic/missing'
|
12
|
+
|
13
|
+
#Shared Requires
|
14
|
+
require 'yml_reader'
|
15
|
+
require 'fig_magic/version'
|
16
|
+
|
17
|
+
|
18
|
+
module FigMagic
|
19
|
+
extend YmlReader
|
20
|
+
extend StandardTranslation
|
21
|
+
extend DateTranslation
|
22
|
+
extend FigMagic::Missing
|
23
|
+
|
24
|
+
attr_reader :parent
|
25
|
+
|
26
|
+
I18n.enforce_available_locales = false if I18n.respond_to? :enforce_available_locales
|
27
|
+
|
28
|
+
def self.locale=(value)
|
29
|
+
Faker::Config.locale = value
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.included(cls)
|
33
|
+
@parent = cls
|
34
|
+
translators.each do |translator|
|
35
|
+
Translation.send :include, translator
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def data_for(key, additional={})
|
40
|
+
if key.is_a?(String) && key.match(%r{/})
|
41
|
+
filename, record = key.split('/')
|
42
|
+
FigMagic.load("#{filename}.yml")
|
43
|
+
else
|
44
|
+
record = key.to_s
|
45
|
+
FigMagic.load(the_file) unless FigMagic.yml
|
46
|
+
end
|
47
|
+
data = FigMagic.yml[record]
|
48
|
+
raise ArgumentError, "Undefined key #{key}" unless data
|
49
|
+
prep_data data.merge(additional).clone
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def the_file
|
55
|
+
ENV['DATA_MAGIC_FILE'] ? ENV['DATA_MAGIC_FILE'] : 'default.yml'
|
56
|
+
end
|
57
|
+
|
58
|
+
def prep_data(data)
|
59
|
+
data.each do |key, value|
|
60
|
+
unless value.nil?
|
61
|
+
next if !value.respond_to?('[]') || value.is_a?(Numeric)
|
62
|
+
next if value.is_a?(Hash)
|
63
|
+
data[key] = translate(value[1..-1]) if value[0,1] == "~"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
data
|
67
|
+
end
|
68
|
+
|
69
|
+
def translate(value)
|
70
|
+
translation.send :process, value
|
71
|
+
end
|
72
|
+
|
73
|
+
def translation
|
74
|
+
@translation ||= Translation.new parent
|
75
|
+
end
|
76
|
+
|
77
|
+
class << self
|
78
|
+
attr_accessor :yml
|
79
|
+
|
80
|
+
def default_directory
|
81
|
+
'config/'
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_translator(translator)
|
85
|
+
translators << translator
|
86
|
+
end
|
87
|
+
|
88
|
+
def translators
|
89
|
+
@translators ||= []
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class UserPage
|
4
|
+
include FigMagic
|
5
|
+
end
|
6
|
+
|
7
|
+
describe FigMagic do
|
8
|
+
context "when configuring the yml directory" do
|
9
|
+
before(:each) do
|
10
|
+
FigMagic.yml_directory = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should default to a directory named config" do
|
14
|
+
expect(FigMagic.yml_directory).to eql 'config/data'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should store a yml directory" do
|
18
|
+
FigMagic.yml_directory = 'test_dir'
|
19
|
+
expect(FigMagic.yml_directory).to eql 'test_dir'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should accept and use locale" do
|
23
|
+
expect(Faker::Config).to receive(:locale=).with('blah')
|
24
|
+
FigMagic.locale = 'blah'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when reading yml files" do
|
30
|
+
it "should read files from the config directory" do
|
31
|
+
FigMagic.yml_directory = 'test'
|
32
|
+
expect(File).to receive(:read).with("test/fname").and_return('test')
|
33
|
+
FigMagic.load("fname")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should default to reading a file named default.yml" do
|
37
|
+
FigMagic.yml_directory = 'config/data'
|
38
|
+
FigMagic.yml = nil
|
39
|
+
data = UserPage.new.data_for :dm
|
40
|
+
expect(data.keys).to include('value1')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should use the value of DATA_MAGIC_FILE if it exists" do
|
44
|
+
FigMagic.yml_directory = 'config/data'
|
45
|
+
FigMagic.yml = nil
|
46
|
+
ENV['DATA_MAGIC_FILE'] = 'user.yml'
|
47
|
+
data = UserPage.new.data_for "valid"
|
48
|
+
expect(data.keys.sort).to eq(['job','name'])
|
49
|
+
ENV['DATA_MAGIC_FILE'] = nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "namespaced keys" do
|
54
|
+
it "loads correct file and retrieves data" do
|
55
|
+
FigMagic.yml_directory = 'config/data'
|
56
|
+
data = UserPage.new.data_for "user/valid"
|
57
|
+
expect(data.keys.sort).to eq(['job','name'])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,312 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestSubject
|
4
|
+
include FigMagic
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "FigMagic translations" do
|
8
|
+
context "when delivering data" do
|
9
|
+
let(:example) { TestSubject.new }
|
10
|
+
|
11
|
+
def set_field_value(value)
|
12
|
+
expect(FigMagic).to receive(:yml).twice.and_return({'key' => {'field' => value}})
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should deliver the hash from the yaml" do
|
16
|
+
set_field_value 'value'
|
17
|
+
expect(example.data_for('key')).to have_field_value 'value'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should allow you to use a symbol for the key" do
|
21
|
+
set_field_value 'value'
|
22
|
+
expect(example.data_for(:key)).to have_field_value 'value'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should default to use a file named 'default.yml'" do
|
26
|
+
FigMagic.yml_directory = 'test'
|
27
|
+
expect(File).to receive(:read).with("test/default.yml").and_return('test')
|
28
|
+
expect(FigMagic).to receive(:yml).and_return(nil)
|
29
|
+
expect(FigMagic).to receive(:yml).and_return({'key' => {'field' => 'value'}})
|
30
|
+
expect(example.data_for('key')).to have_field_value 'value'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should clone the data returned so it can be resued" do
|
34
|
+
yaml = double('yaml')
|
35
|
+
expect(yaml).to receive(:merge).and_return(yaml)
|
36
|
+
expect(FigMagic).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
|
+
end
|
41
|
+
|
42
|
+
it "should merge the provided data with the yaml data" do
|
43
|
+
yaml = double('yaml')
|
44
|
+
expect(FigMagic).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
|
+
end
|
50
|
+
|
51
|
+
context "translating random names" do
|
52
|
+
it "should add a name" do
|
53
|
+
expect(Faker::Name).to receive(:name).and_return('Joseph')
|
54
|
+
set_field_value '~full_name'
|
55
|
+
expect(example.data_for('key')).to have_field_value 'Joseph'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should add first name" do
|
59
|
+
expect(Faker::Name).to receive(:first_name).and_return('Sam')
|
60
|
+
set_field_value '~first_name'
|
61
|
+
expect(example.data_for('key')).to have_field_value 'Sam'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should add last name" do
|
65
|
+
expect(Faker::Name).to receive(:last_name).and_return('Smith')
|
66
|
+
set_field_value '~last_name'
|
67
|
+
expect(example.data_for('key')).to have_field_value 'Smith'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should add name prefix" do
|
71
|
+
expect(Faker::Name).to receive(:prefix).and_return("Mr")
|
72
|
+
set_field_value '~name_prefix'
|
73
|
+
expect(example.data_for('key')).to have_field_value 'Mr'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should add name suffix" do
|
77
|
+
expect(Faker::Name).to receive(:suffix).and_return('Jr')
|
78
|
+
set_field_value '~name_suffix'
|
79
|
+
expect(example.data_for('key')).to have_field_value 'Jr'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "translating random addresses" do
|
84
|
+
it "should add a street address" do
|
85
|
+
expect(Faker::Address).to receive(:street_address).and_return("123 Main")
|
86
|
+
set_field_value '~street_address'
|
87
|
+
expect(example.data_for('key')).to have_field_value '123 Main'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should add a city" do
|
91
|
+
expect(Faker::Address).to receive(:city).and_return('Cleveland')
|
92
|
+
set_field_value '~city'
|
93
|
+
expect(example.data_for('key')).to have_field_value 'Cleveland'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should add a state" do
|
97
|
+
expect(Faker::Address).to receive(:state).and_return('Ohio')
|
98
|
+
set_field_value '~state'
|
99
|
+
expect(example.data_for('key')).to have_field_value 'Ohio'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should add a state abbreviation" do
|
103
|
+
expect(Faker::Address).to receive(:state_abbr).and_return('OH')
|
104
|
+
set_field_value '~state_abbr'
|
105
|
+
expect(example.data_for('key')).to have_field_value 'OH'
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should add a zip code" do
|
109
|
+
expect(Faker::Address).to receive(:zip).and_return('11111')
|
110
|
+
set_field_value '~zip_code'
|
111
|
+
expect(example.data_for('key')).to have_field_value '11111'
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should add a country" do
|
115
|
+
expect(Faker::Address).to receive(:country).and_return("United States")
|
116
|
+
set_field_value '~country'
|
117
|
+
expect(example.data_for('key')).to have_field_value 'United States'
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should add a secondary address" do
|
121
|
+
expect(Faker::Address).to receive(:secondary_address).and_return('2nd floor')
|
122
|
+
set_field_value '~secondary_address'
|
123
|
+
expect(example.data_for('key')).to have_field_value '2nd floor'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "translating company names" do
|
128
|
+
it "should add a company name" do
|
129
|
+
expect(Faker::Company).to receive(:name).and_return('LeanDog')
|
130
|
+
set_field_value '~company_name'
|
131
|
+
expect(example.data_for('key')).to have_field_value 'LeanDog'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "translating business" do
|
136
|
+
it "should add a credit card number" do
|
137
|
+
expect(Faker::Business).to receive(:credit_card_number).and_return('123')
|
138
|
+
set_field_value '~credit_card_number'
|
139
|
+
expect(example.data_for('key')).to have_field_value '123'
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should add credit card type" do
|
143
|
+
expect(Faker::Business).to receive(:credit_card_type).
|
144
|
+
and_return('visa')
|
145
|
+
set_field_value '~credit_card_type'
|
146
|
+
expect(example.data_for('key')).to have_field_value 'visa'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "translating internet names" do
|
151
|
+
it "should add an email address" do
|
152
|
+
expect(Faker::Internet).to receive(:email).and_return('buddy@example.com')
|
153
|
+
set_field_value '~email_address'
|
154
|
+
expect(example.data_for('key')).to have_field_value 'buddy@example.com'
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should add a domain name" do
|
158
|
+
expect(Faker::Internet).to receive(:domain_name).and_return("google.com")
|
159
|
+
set_field_value '~domain_name'
|
160
|
+
expect(example.data_for('key')).to have_field_value 'google.com'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should add a user name" do
|
164
|
+
expect(Faker::Internet).to receive(:user_name).and_return('very_cheezy')
|
165
|
+
set_field_value '~user_name'
|
166
|
+
expect(example.data_for('key')).to have_field_value 'very_cheezy'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "translating phone numbers" do
|
171
|
+
it "shold add a phone number" do
|
172
|
+
expect(Faker::PhoneNumber).to receive(:phone_number).and_return('555-555-5555')
|
173
|
+
set_field_value '~phone_number'
|
174
|
+
expect(example.data_for('key')).to have_field_value '555-555-5555'
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "translating random phrases" do
|
179
|
+
it "should add a catch phrase" do
|
180
|
+
expect(Faker::Company).to receive(:catch_phrase).and_return('Ruby is cool')
|
181
|
+
set_field_value '~catch_phrase'
|
182
|
+
expect(example.data_for('key')).to have_field_value 'Ruby is cool'
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should add random words" do
|
186
|
+
expect(Faker::Lorem).to receive(:words).and_return(['random', 'words'])
|
187
|
+
set_field_value '~words'
|
188
|
+
expect(example.data_for('key')).to have_field_value 'random words'
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should default to returning 3 words" do
|
192
|
+
set_field_value '~words'
|
193
|
+
expect(example.data_for('key')['field'].split.size).to eql 3
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should allow you to specify the number of words" do
|
197
|
+
set_field_value '~words(4)'
|
198
|
+
expect(example.data_for('key')['field'].split.size).to eql 4
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should add a random sentence" do
|
202
|
+
expect(Faker::Lorem).to receive(:sentence).and_return('a sentence')
|
203
|
+
set_field_value '~sentence'
|
204
|
+
expect(example.data_for('key')).to have_field_value 'a sentence'
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should default to returning a minimum of 4 words" do
|
208
|
+
set_field_value '~sentence'
|
209
|
+
expect(example.data_for('key')['field'].split.size).to be >= 4
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should allow you to specify a minimum word count" do
|
213
|
+
set_field_value '~sentence(20)'
|
214
|
+
expect(example.data_for('key')['field'].split.size).to be >= 20
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should add sentences" do
|
218
|
+
expect(Faker::Lorem).to receive(:sentences).and_return(['this is sentences'])
|
219
|
+
set_field_value '~sentences'
|
220
|
+
expect(example.data_for('key')).to have_field_value 'this is sentences'
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should default to returning a default of 3 sentences" do
|
224
|
+
set_field_value '~sentences'
|
225
|
+
expect(example.data_for('key')['field'].split('.').size).to be >= 3
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should allow you to specify the number of sentences" do
|
229
|
+
set_field_value '~sentences(10)'
|
230
|
+
expect(example.data_for('key')['field'].split('.').size).to be >= 10
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should add a paragraphs" do
|
234
|
+
expect(Faker::Lorem).to receive(:paragraphs).and_return(['this is a paragraph'])
|
235
|
+
set_field_value '~paragraphs'
|
236
|
+
expect(example.data_for('key')).to have_field_value 'this is a paragraph'
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should return 3 paragraphs by default" do
|
240
|
+
set_field_value '~paragraphs'
|
241
|
+
expect(example.data_for('key')['field'].split('\n\n').size).to eql 3
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should allow you to specify the number of paragraphs" do
|
245
|
+
set_field_value '~paragraphs(10)'
|
246
|
+
expect(example.data_for('key')['field'].split('\n\n').size).to eql 10
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should add characters" do
|
250
|
+
expect(Faker::Lorem).to receive(:characters).and_return('abcdefg')
|
251
|
+
set_field_value '~characters'
|
252
|
+
expect(example.data_for('key')).to have_field_value 'abcdefg'
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "translating boolean values" do
|
257
|
+
it "should resolve true" do
|
258
|
+
set_field_value true
|
259
|
+
expect(example.data_for('key')).to have_field_value true
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should resolve false" do
|
263
|
+
set_field_value false
|
264
|
+
expect(example.data_for('key')).to have_field_value false
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context "with numeric values" do
|
269
|
+
it "doesn't translate values" do
|
270
|
+
set_field_value(1)
|
271
|
+
expect(example.data_for("key")).to have_field_value 1
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context "with values not in the yaml" do
|
276
|
+
it "throws a ArgumentError" do
|
277
|
+
expect { example.data_for("inexistant_key") }.to raise_error ArgumentError
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
context "providing date values" do
|
282
|
+
it "should provide today's date" do
|
283
|
+
set_field_value '~today'
|
284
|
+
expect(example.data_for('key')).to have_field_value Date.today.strftime('%D')
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should provide tomorrow's date" do
|
288
|
+
set_field_value '~tomorrow'
|
289
|
+
tomorrow = Date.today + 1
|
290
|
+
expect(example.data_for('key')).to have_field_value tomorrow.strftime('%D')
|
291
|
+
end
|
292
|
+
|
293
|
+
it "should provide yesterday's date" do
|
294
|
+
set_field_value '~yesterday'
|
295
|
+
yesterday = Date.today - 1
|
296
|
+
expect(example.data_for('key')).to have_field_value yesterday.strftime('%D')
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should provide a date that is some number of days from now" do
|
300
|
+
set_field_value '~5.days_from_today'
|
301
|
+
the_date = Date.today + 5
|
302
|
+
expect(example.data_for('key')).to have_field_value the_date.strftime('%D')
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should provide a date that is some number of days ago" do
|
306
|
+
set_field_value '~5.days_ago'
|
307
|
+
the_date = Date.today - 5
|
308
|
+
expect(example.data_for('key')).to have_field_value the_date.strftime('%D')
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
if ENV['coverage']
|
6
|
+
raise "simplecov only works on Ruby 1.9" unless RUBY_VERSION =~ /^1\.9/
|
7
|
+
|
8
|
+
require 'simplecov'
|
9
|
+
SimpleCov.start { add_filter "spec/" }
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rspec'
|
13
|
+
|
14
|
+
require 'fig_magic'
|
15
|
+
|
16
|
+
RSpec::Matchers.define :have_field_value do |expected|
|
17
|
+
match do |actual|
|
18
|
+
actual['field'] == expected
|
19
|
+
end
|
20
|
+
|
21
|
+
failure_message do |actual|
|
22
|
+
"expected '#{expected}' to equal the field value '#{actual['field']}'"
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message_when_negated do |actual|
|
26
|
+
"expected '#{expected}' to not equal to field value '#{actual['field']}'"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fig_magic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Commu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faker
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yml_reader
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.12.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.12.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.0
|
69
|
+
description: Provides datasets to application stored in YAML files
|
70
|
+
email:
|
71
|
+
- jcommu@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".DS_Store"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".idea/.name"
|
79
|
+
- ".idea/.rakeTasks"
|
80
|
+
- ".idea/FigMagic.iml"
|
81
|
+
- ".idea/atlassian-ide-plugin.xml"
|
82
|
+
- ".idea/encodings.xml"
|
83
|
+
- ".idea/misc.xml"
|
84
|
+
- ".idea/modules.xml"
|
85
|
+
- ".idea/workspace.xml"
|
86
|
+
- ".rspec"
|
87
|
+
- ".ruby-gemset"
|
88
|
+
- ".ruby-version"
|
89
|
+
- ChangeLog
|
90
|
+
- Gemfile
|
91
|
+
- Guardfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- config/data/default.yml
|
96
|
+
- config/data/user.yml
|
97
|
+
- config/environments/default.yml
|
98
|
+
- config/yaml/sample.yml
|
99
|
+
- config/yaml/test_config.yml
|
100
|
+
- cucumber.yml
|
101
|
+
- features/data_magic.feature
|
102
|
+
- features/defaults.feature
|
103
|
+
- features/fig_newton.feature
|
104
|
+
- features/step_definitions/data_magic_steps.rb
|
105
|
+
- features/step_definitions/fig_newton_steps.rb
|
106
|
+
- features/support/env.rb
|
107
|
+
- features/yaml/another.yml
|
108
|
+
- features/yaml/example.yml
|
109
|
+
- fig_magic.gemspec
|
110
|
+
- lib/fig_magic.rb
|
111
|
+
- lib/fig_magic/core_ext/fixnum.rb
|
112
|
+
- lib/fig_magic/core_ext/string.rb
|
113
|
+
- lib/fig_magic/date_translation.rb
|
114
|
+
- lib/fig_magic/missing.rb
|
115
|
+
- lib/fig_magic/node.rb
|
116
|
+
- lib/fig_magic/standard_translation.rb
|
117
|
+
- lib/fig_magic/translation.rb
|
118
|
+
- lib/fig_magic/version.rb
|
119
|
+
- spec/lib/data_magic_spec.rb
|
120
|
+
- spec/lib/translation_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
homepage: http://github.com/dingokiller/fig_magic
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.2.5
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Combines FigNewton & DataMagic into a single gem & namespace
|
146
|
+
test_files:
|
147
|
+
- features/data_magic.feature
|
148
|
+
- features/defaults.feature
|
149
|
+
- features/fig_newton.feature
|
150
|
+
- features/step_definitions/data_magic_steps.rb
|
151
|
+
- features/step_definitions/fig_newton_steps.rb
|
152
|
+
- features/support/env.rb
|
153
|
+
- features/yaml/another.yml
|
154
|
+
- features/yaml/example.yml
|
155
|
+
- spec/lib/data_magic_spec.rb
|
156
|
+
- spec/lib/translation_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
has_rdoc:
|