factory_group 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ade35bf5d62708994c84ed0b08bd6ce23e380554
4
- data.tar.gz: 810cc15e90a6c77c4fb13554a910ad8bd4c808f7
3
+ metadata.gz: 2f64df4359b221faf757b473d72d27900d9e66b1
4
+ data.tar.gz: ac5031d01f744261c4a331350cfa329081d8a0c9
5
5
  SHA512:
6
- metadata.gz: 0ae1022d9acc84a023e65630939cedd2b7c534a343359bf0e5930de6638feed72f56960320fe07f7c00a63e37674b721ba70b80f4c3f6cce7f9f4ed81d6c169b
7
- data.tar.gz: 9bacedaabb09f71e175da29df245e948552bc4efc23a94bd8c4295adb878f3326d66bd32b9ad39622cb6f0176e63250443d3bf90ae281c2558201beddde5967b
6
+ metadata.gz: c0ab513aa6b810faa7d13c3f3d9b1bd74f9c20bb2cb60c9d715ec9e12348daaa67b594ca108df4d46e6e3edd830945610fb9e290b32cc6ea7b511dfac0b857de
7
+ data.tar.gz: 9fe960d02264bdec4f3ec5ce545556de073fb7732b1122c83cd8258e0c53bf4c1133aff99fe214ff2953c20031fc0e6d694fa4bcd373b49808f37579f8e5b073
@@ -13,7 +13,10 @@ module FactoryGroup
13
13
  # Sets an instance variable with the name as the called method and
14
14
  # assigns the args[0] passed to it.
15
15
  def method_missing(name, *args, &block)
16
- @factories.send("#{name.to_s}=", args[0])
16
+ # If the args is empty, it means a variable is reused inside the group itself
17
+ evaluvated_result = args.empty? ? @factories.instance_eval(name.to_s) : args[0]
18
+
19
+ @factories.send("#{name.to_s}=", evaluvated_result)
17
20
  end
18
21
  end
19
22
  end
@@ -1,3 +1,3 @@
1
1
  module FactoryGroup
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,21 +1,38 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe FactoryGroup do
4
- before(:all) do
5
- described_class.define(:user_group) do
6
- user FactoryGirl.create(:user)
7
- end
8
- end
9
4
 
10
5
  context "#create" do
11
- before do
12
- @user_group = FactoryGroup.create(:user_group)
6
+ describe "with a single basic factory" do
7
+ before do
8
+ described_class.define(:user_group) do
9
+ user FactoryGirl.create(:user)
10
+ end
11
+
12
+ @user_group = FactoryGroup.create(:user_group)
13
+ end
14
+
15
+ it "should create a factory_group with the factories" do
16
+ expect(@user_group).to be_a OpenStruct
17
+ expect(@user_group.user).to be_a User
18
+ expect(@user_group.user.name).to eq "sample"
19
+ expect(@user_group.user.age).to eq 20
20
+ end
13
21
  end
14
- it "should create a factory_group with the factories" do
15
- expect(@user_group).to be_a OpenStruct
16
- expect(@user_group.user).to be_a User
17
- expect(@user_group.user.name).to eq "sample"
18
- expect(@user_group.user.age).to eq 20
22
+
23
+ describe "with a variable inside a group being reused inside the group itself" do
24
+ before do
25
+ described_class.define(:user_group) do
26
+ user FactoryGirl.create(:user)
27
+ name user.name
28
+ end
29
+
30
+ @user_group = FactoryGroup.create(:user_group)
31
+ end
32
+
33
+ it "should be able to access name attribute" do
34
+ expect(@user_group.name).to eq "sample"
35
+ end
19
36
  end
20
37
  end
21
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_group
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuvaraja Balamurugan