data_magic 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ === Version 0.3 / 2012-2-5
2
+ * Added additional data merge to #data_for
3
+
1
4
  === Version 0.2 / 2012-1-26
2
5
  * Defaulted yaml file to 'default.yaml'
3
6
  * Cloned hash so data can be reused
data/lib/data_magic.rb CHANGED
@@ -8,10 +8,10 @@ require 'faker'
8
8
  module DataMagic
9
9
  include Translation
10
10
 
11
- def data_for(key)
11
+ def data_for(key, additional={})
12
12
  DataMagic.load('default.yml') unless DataMagic.yml
13
13
  data = DataMagic.yml[key]
14
- prep_data data.clone
14
+ prep_data data.merge(additional).clone
15
15
  end
16
16
 
17
17
  private
@@ -1,3 +1,3 @@
1
1
  module DataMagic
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
@@ -17,7 +17,6 @@ describe "DataMagic translations" do
17
17
  example.data_for('key').should have_field_value 'value'
18
18
  end
19
19
 
20
-
21
20
  it "should default to use a file named 'default.yml'" do
22
21
  DataMagic::Config.yml_directory = 'test'
23
22
  YAML.should_receive(:load_file).with("test/default.yml").and_return({})
@@ -27,9 +26,19 @@ describe "DataMagic translations" do
27
26
  end
28
27
 
29
28
  it "should clone the data returned so it can be resued" do
29
+ yaml = double('yaml')
30
+ yaml.stub(:merge).and_return(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
+
37
+ it "should merge the provided data with the yaml data" do
30
38
  yaml = double('yaml')
31
39
  DataMagic.should_receive(:yml).twice.and_return(yaml)
32
40
  yaml.should_receive(:[]).and_return(yaml)
41
+ yaml.should_receive(:merge).and_return(yaml)
33
42
  yaml.should_receive(:clone).and_return({'field' => 'value'})
34
43
  example.data_for('key').should have_field_value 'value'
35
44
  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.2'
4
+ version: '0.3'
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-26 00:00:00.000000000 Z
12
+ date: 2012-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faker
16
- requirement: &70313484608100 !ruby/object:Gem::Requirement
16
+ requirement: &70184023220840 !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: *70313484608100
24
+ version_requirements: *70184023220840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70313484607300 !ruby/object:Gem::Requirement
27
+ requirement: &70184023220040 !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: *70313484607300
35
+ version_requirements: *70184023220040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &70313484606540 !ruby/object:Gem::Requirement
38
+ requirement: &70184023219280 !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: *70313484606540
46
+ version_requirements: *70184023219280
47
47
  description: Provides datasets to application stored in YAML files
48
48
  email:
49
49
  - jeff.morgan@leandog.com