remote_factory_girl 0.0.1 → 1.0.0
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 +4 -4
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/lib/remote_factory_girl/config.rb +27 -25
- data/lib/remote_factory_girl/http.rb +13 -8
- data/lib/remote_factory_girl/version.rb +1 -1
- data/lib/remote_factory_girl.rb +19 -20
- data/remote_factory_girl.gemspec +0 -1
- data/spec/integration/remote_factory_girl_spec.rb +31 -15
- data/spec/models/remote_factory_girl/config_spec.rb +56 -28
- data/spec/models/remote_factory_girl/http_spec.rb +2 -2
- data/spec/models/remote_factory_girl_spec.rb +2 -20
- metadata +2 -19
- data/lib/remote_factory_girl/config_struct.rb +0 -19
- data/spec/models/remote_factory_girl/config_struct_spec.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc49d97c232bfdba862ab52c9eabe313d7a3012f
|
4
|
+
data.tar.gz: 644c676dc15e1da5935d545e5341e48a11773a56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e964470880d4c8fd4d091ccd92922deddd53bd0e0a21b65c2065fb25fa60c07ae3344806fe880d882586d71abb53d1bbf6f6b5e4707c2e9a082ef989ea4c13d
|
7
|
+
data.tar.gz: d3dfbb436a42441ede4fe8b745c8b3f29a27eb34a2914c91bf89ee16253d62778f906b5a161b70523cd7b2e43cfa31b0c582313b9e040226d0e2005287939c7a
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RemoteFactoryGirl
|
2
2
|
|
3
|
-
[factory_girl](https://github.com/thoughtbot/factory_girl) for [
|
3
|
+
[factory_girl](https://github.com/thoughtbot/factory_girl) for [Service Oriented Architecture](http://en.wikipedia.org/wiki/Service-oriented_architecture) (SOA). Create [factory_girl](https://github.com/thoughtbot/factory_girl) test data remotely when used in conjunction with [remote_factory_girl_home_rails](https://github.com/tdouce/remote_factory_girl_home_rails).
|
4
4
|
|
5
5
|
## Getting Started
|
6
6
|
|
@@ -1,45 +1,41 @@
|
|
1
1
|
require 'remote_factory_girl/exceptions'
|
2
|
-
require 'virtus'
|
3
2
|
|
4
3
|
module RemoteFactoryGirl
|
5
4
|
class Config
|
6
|
-
include Virtus.model
|
7
5
|
|
8
|
-
|
9
|
-
:port => nil,
|
10
|
-
:end_point => '/remote_factory_girl/home' }
|
6
|
+
attr_accessor :home, :return_response_as, :return_with_root, :return_as_active_resource, :https
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
new(configs)
|
8
|
+
def initialize
|
9
|
+
@return_response_as = :as_hash
|
10
|
+
@return_with_root = true
|
11
|
+
@return_as_active_resource = false
|
12
|
+
@home = default_home_config
|
13
|
+
@https = false
|
19
14
|
end
|
20
15
|
|
21
|
-
def
|
22
|
-
|
23
|
-
super(attrs)
|
16
|
+
def home=(home_config)
|
17
|
+
@home = home.merge(home_config)
|
24
18
|
end
|
25
19
|
|
26
20
|
def home_url
|
27
|
-
|
28
|
-
http = 'http://'
|
21
|
+
raise_if_host_not_set
|
29
22
|
if home[:port]
|
30
|
-
"#{
|
23
|
+
"#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }"
|
31
24
|
else
|
32
|
-
"#{
|
25
|
+
"#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }#{ home.fetch(:end_point) }"
|
33
26
|
end
|
34
27
|
end
|
35
28
|
|
36
29
|
def to_hash
|
37
|
-
|
38
|
-
|
30
|
+
{ home: home,
|
31
|
+
home_url: home_url,
|
32
|
+
return_response_as: return_response_as,
|
33
|
+
return_with_root: return_with_root,
|
34
|
+
return_as_active_resource: return_as_active_resource }
|
39
35
|
end
|
40
36
|
|
41
|
-
def
|
42
|
-
raise RemoteFactoryGirlConfigError.new(
|
37
|
+
def raise_if_host_not_set
|
38
|
+
raise RemoteFactoryGirlConfigError.new('RemoteFactoryGirl.config.home[:host] and RemoteFactoryGirl.config.home[:end_point] can not be nil') unless has_home?
|
43
39
|
end
|
44
40
|
|
45
41
|
def has_home?
|
@@ -48,8 +44,14 @@ module RemoteFactoryGirl
|
|
48
44
|
|
49
45
|
private
|
50
46
|
|
51
|
-
def
|
52
|
-
|
47
|
+
def hyper_text_transfer_protocal
|
48
|
+
https == true ? 'https' : 'http'
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_home_config
|
52
|
+
{ :host => nil,
|
53
|
+
:port => nil,
|
54
|
+
:end_point => '/remote_factory_girl/home' }
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -3,29 +3,34 @@ require 'rest-client'
|
|
3
3
|
module RemoteFactoryGirl
|
4
4
|
class Http
|
5
5
|
def self.post(config, params, http_lib = RestClient)
|
6
|
-
new(config, params, http_lib).
|
6
|
+
new(config, params, http_lib).post
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def self.get(config, params, http_lib = RestClient)
|
10
|
+
new(config, params, http_lib).get
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :config, :params, :http_lib, :response_json
|
10
14
|
|
11
15
|
def initialize(config, params, http_lib = RestClient)
|
16
|
+
config.raise_if_host_not_set
|
12
17
|
@config = config
|
13
18
|
@params = params
|
14
19
|
@http_lib = http_lib
|
15
20
|
end
|
16
21
|
|
17
|
-
def
|
18
|
-
|
22
|
+
def get
|
23
|
+
@response_json = http_lib.get config.home_url, params.merge!(content_type: :json, accept: :json)
|
19
24
|
self
|
20
25
|
end
|
21
26
|
|
22
27
|
def post
|
23
|
-
config.
|
24
|
-
|
28
|
+
@response_json = http_lib.post config.home_url, params, content_type: :json, accept: :json
|
29
|
+
self
|
25
30
|
end
|
26
31
|
|
27
|
-
def
|
28
|
-
|
32
|
+
def to_hash
|
33
|
+
JSON.parse(response_json)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/lib/remote_factory_girl.rb
CHANGED
@@ -2,43 +2,42 @@ require "remote_factory_girl/version"
|
|
2
2
|
require 'remote_factory_girl/config'
|
3
3
|
require 'remote_factory_girl/http'
|
4
4
|
require 'remote_factory_girl/config_applier'
|
5
|
-
require 'remote_factory_girl/config_struct'
|
6
5
|
require 'remote_factory_girl/hash_to_dot'
|
7
6
|
require 'remote_factory_girl/json_to_active_resource'
|
8
7
|
|
9
8
|
module RemoteFactoryGirl
|
10
9
|
class RemoteFactoryGirl
|
11
10
|
|
12
|
-
attr_reader :
|
11
|
+
attr_reader :config, :response
|
13
12
|
|
14
|
-
def initialize(
|
15
|
-
@
|
16
|
-
@attributes = attributes
|
17
|
-
@config = config
|
13
|
+
def initialize(config)
|
14
|
+
@config = config
|
18
15
|
end
|
19
16
|
|
20
|
-
def
|
21
|
-
|
17
|
+
def create(factory, attributes = {}, http = Http)
|
18
|
+
@response ||= http.post(config, { factory: factory, attributes: attributes })
|
22
19
|
end
|
23
20
|
|
24
|
-
def
|
25
|
-
@
|
21
|
+
def factories(attributes = {}, http = Http)
|
22
|
+
@response ||= http.get(config, attributes)
|
26
23
|
end
|
24
|
+
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def self.configure(config = Config, &block)
|
27
|
+
configuration = Config.new
|
28
|
+
yield(configuration)
|
29
|
+
self.config = configuration
|
31
30
|
end
|
32
31
|
|
33
|
-
def self.
|
34
|
-
|
35
|
-
|
32
|
+
def self.factories(params = {}, http = Http)
|
33
|
+
factory = RemoteFactoryGirl.new(config)
|
34
|
+
factory.factories(params, http).to_hash
|
36
35
|
end
|
37
36
|
|
38
|
-
def self.create(
|
39
|
-
factory = RemoteFactoryGirl.new(
|
40
|
-
factory.
|
41
|
-
|
37
|
+
def self.create(factory_name, attributes = {}, config_applier = ConfigApplier, http = Http)
|
38
|
+
factory = RemoteFactoryGirl.new(config)
|
39
|
+
factory.create(factory_name, attributes, http)
|
40
|
+
config_applier.apply_config(factory.response.to_hash, config.to_hash)
|
42
41
|
end
|
43
42
|
|
44
43
|
def self.config
|
data/remote_factory_girl.gemspec
CHANGED
@@ -6,12 +6,13 @@ describe RemoteFactoryGirl do
|
|
6
6
|
|
7
7
|
describe 'configuration' do
|
8
8
|
it 'should be configured with correct defaults' do
|
9
|
-
expect(RemoteFactoryGirl.config.home).to eq({ :host => nil,
|
10
|
-
:port => nil,
|
9
|
+
expect(RemoteFactoryGirl.config.home).to eq({ :host => nil,
|
10
|
+
:port => nil,
|
11
11
|
:end_point => '/remote_factory_girl/home'})
|
12
|
-
expect(RemoteFactoryGirl.config.return_response_as).to eq(:as_hash)
|
13
|
-
expect(RemoteFactoryGirl.config.return_with_root).to be_true
|
12
|
+
expect(RemoteFactoryGirl.config.return_response_as).to eq(:as_hash)
|
13
|
+
expect(RemoteFactoryGirl.config.return_with_root).to be_true
|
14
14
|
expect(RemoteFactoryGirl.config.return_as_active_resource).to be_false
|
15
|
+
expect(RemoteFactoryGirl.config.https).to be_false
|
15
16
|
end
|
16
17
|
|
17
18
|
it 'should be able to configure with a block' do
|
@@ -23,8 +24,8 @@ describe RemoteFactoryGirl do
|
|
23
24
|
|
24
25
|
it 'should be able to configure .home' do
|
25
26
|
RemoteFactoryGirl.config.home[:host] = 'fun_guy'
|
26
|
-
RemoteFactoryGirl.config.home[:port] = 3333
|
27
|
-
RemoteFactoryGirl.config.home[:end_point] = '/down_home'
|
27
|
+
RemoteFactoryGirl.config.home[:port] = 3333
|
28
|
+
RemoteFactoryGirl.config.home[:end_point] = '/down_home'
|
28
29
|
expect(RemoteFactoryGirl.config.home[:host]).to eq('fun_guy')
|
29
30
|
expect(RemoteFactoryGirl.config.home[:port]).to eq(3333)
|
30
31
|
expect(RemoteFactoryGirl.config.home[:end_point]).to eq('/down_home')
|
@@ -36,12 +37,17 @@ describe RemoteFactoryGirl do
|
|
36
37
|
|
37
38
|
it 'should be able to configure .return_with_root' do
|
38
39
|
RemoteFactoryGirl.config.return_with_root = false
|
39
|
-
expect(RemoteFactoryGirl.config.return_with_root).to be_false
|
40
|
+
expect(RemoteFactoryGirl.config.return_with_root).to be_false
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should be able to configure .return_as_active_resource' do
|
43
|
-
RemoteFactoryGirl.config.
|
44
|
-
expect(RemoteFactoryGirl.config.
|
44
|
+
RemoteFactoryGirl.config.return_as_active_resource = true
|
45
|
+
expect(RemoteFactoryGirl.config.return_as_active_resource).to be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should be able to configure https' do
|
49
|
+
RemoteFactoryGirl.config.https = true
|
50
|
+
expect(RemoteFactoryGirl.config.https).to be_true
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
@@ -61,6 +67,16 @@ describe RemoteFactoryGirl do
|
|
61
67
|
|
62
68
|
before do
|
63
69
|
RestClient.stub(:post).and_return('{"user": {"id": "1", "first_name": "Sam", "last_name": "Iam"}}')
|
70
|
+
RestClient.stub(:get).and_return('["user", "user_admin"]')
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.factories' do
|
74
|
+
|
75
|
+
before { RemoteFactoryGirl.config.home[:host] = 'localhost' }
|
76
|
+
|
77
|
+
it 'should return all factories available' do
|
78
|
+
expect(RemoteFactoryGirl.factories).to match_array(['user', 'user_admin'])
|
79
|
+
end
|
64
80
|
end
|
65
81
|
|
66
82
|
describe '.create' do
|
@@ -71,19 +87,19 @@ describe RemoteFactoryGirl do
|
|
71
87
|
|
72
88
|
it 'should be able to create a factory' do
|
73
89
|
user = RemoteFactoryGirl.create(:site)
|
74
|
-
expect(user).to have_key('user')
|
90
|
+
expect(user).to have_key('user')
|
75
91
|
end
|
76
92
|
|
77
93
|
it 'should not return root hash key when .return_with_root is false' do
|
78
94
|
RemoteFactoryGirl.config.return_with_root = false
|
79
95
|
user = RemoteFactoryGirl.create(:user)
|
80
|
-
expect(user).to_not have_key('user')
|
96
|
+
expect(user).to_not have_key('user')
|
81
97
|
end
|
82
98
|
|
83
99
|
it 'should not return an object that responds to dot notation' do
|
84
100
|
RemoteFactoryGirl.config.return_response_as = :dot_notation
|
85
101
|
user = RemoteFactoryGirl.create(:user)
|
86
|
-
expect(user.first_name).to_not eq('Sam')
|
102
|
+
expect(user.first_name).to_not eq('Sam')
|
87
103
|
end
|
88
104
|
|
89
105
|
it 'should send a post request to home' do
|
@@ -99,7 +115,7 @@ describe RemoteFactoryGirl do
|
|
99
115
|
config.return_with_root = false
|
100
116
|
end
|
101
117
|
user = RemoteFactoryGirl.create(:user)
|
102
|
-
expect(user.first_name).to eq('Sam')
|
118
|
+
expect(user.first_name).to eq('Sam')
|
103
119
|
end
|
104
120
|
|
105
121
|
describe 'when configured to return active_resource object' do
|
@@ -110,10 +126,10 @@ describe RemoteFactoryGirl do
|
|
110
126
|
|
111
127
|
class User < ActiveResource; end
|
112
128
|
|
113
|
-
before do
|
129
|
+
before do
|
114
130
|
RemoteFactoryGirl.configure do |config|
|
115
131
|
config.home = { :host => 'localhost' }
|
116
|
-
config.return_as_active_resource = true
|
132
|
+
config.return_as_active_resource = true
|
117
133
|
end
|
118
134
|
end
|
119
135
|
|
@@ -1,53 +1,81 @@
|
|
1
|
-
require 'virtus'
|
2
1
|
require 'remote_factory_girl/config.rb'
|
3
2
|
require 'remote_factory_girl/http.rb'
|
4
3
|
require 'remote_factory_girl/config_applier'
|
5
|
-
require 'remote_factory_girl/config_struct'
|
6
4
|
require 'remote_factory_girl/hash_to_dot'
|
7
5
|
|
8
6
|
describe RemoteFactoryGirl::Config do
|
9
7
|
|
10
|
-
|
8
|
+
let(:config) { RemoteFactoryGirl::Config.new }
|
11
9
|
|
12
|
-
|
13
|
-
it 'should be able to set configurations' do
|
14
|
-
config = RemoteFactoryGirl::Config.configure({ :home => { :host => 'tifton', :port => 9999, :end_point => '/somewhere' },
|
15
|
-
:return_response_as => :as_dot_notation,
|
16
|
-
:return_with_root => false })
|
17
|
-
expect(config.home).to eq({ :host => 'tifton',
|
18
|
-
:port => 9999,
|
19
|
-
:end_point => '/somewhere'})
|
20
|
-
expect(config.return_response_as).to eq(:as_dot_notation)
|
21
|
-
expect(config.return_with_root).to be_false
|
22
|
-
end
|
23
|
-
end
|
10
|
+
describe 'initialize' do
|
24
11
|
|
25
12
|
describe 'default configuration' do
|
26
13
|
it 'should be configured with correct defaults' do
|
27
|
-
config = RemoteFactoryGirl::Config.new
|
28
14
|
expect(config.home).to eq({ :host => nil,
|
29
15
|
:port => nil,
|
30
16
|
:end_point => '/remote_factory_girl/home'})
|
31
17
|
expect(config.return_response_as).to eq(:as_hash)
|
32
18
|
expect(config.return_with_root).to be_true
|
19
|
+
expect(config.return_as_active_resource).to be_false
|
20
|
+
expect(config.https).to be_false
|
33
21
|
end
|
34
22
|
end
|
23
|
+
end
|
35
24
|
|
36
|
-
|
25
|
+
describe '#home_url' do
|
37
26
|
|
38
|
-
|
27
|
+
it 'should return a url with port if port is configured' do
|
28
|
+
config.home[:host] = 'localhost'
|
29
|
+
config.home[:port] = 5555
|
30
|
+
expect(config.home_url).to eq('http://localhost:5555/remote_factory_girl/home')
|
31
|
+
end
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
it 'should return a url without a port if port is not configured' do
|
34
|
+
config.home[:host] = 'localhost_no_port'
|
35
|
+
config.home[:port] = nil
|
36
|
+
expect(config.home_url).to eq('http://localhost_no_port/remote_factory_girl/home')
|
37
|
+
end
|
45
38
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
it 'should return a url that is configured with https' do
|
40
|
+
config.https = true
|
41
|
+
config.home[:host] = 'localhost'
|
42
|
+
config.home[:port] = 5555
|
43
|
+
|
44
|
+
expect(config.home_url).to eq('https://localhost:5555/remote_factory_girl/home')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#has_home?' do
|
49
|
+
it 'should return false when host and end_point are not set' do
|
50
|
+
config.home[:host] = nil
|
51
|
+
config.home[:end_point] = nil
|
52
|
+
expect(config.has_home?).to be_false
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return false when host is not set and end_point is set' do
|
56
|
+
expect(config.has_home?).to be_false
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return true when host and end_point is set' do
|
60
|
+
config.home[:host] = 'localhost'
|
61
|
+
config.home[:end_point] = 'some_where'
|
62
|
+
expect(config.has_home?).to be_true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#to_hash' do
|
67
|
+
it 'should return a properly formatted hash' do
|
68
|
+
config.home[:port] = '3000'
|
69
|
+
config.home[:host] = 'localhost'
|
70
|
+
config.home[:end_point] = '/some_where'
|
71
|
+
|
72
|
+
expect(config.to_hash).to eq( { :home => { :host => 'localhost',
|
73
|
+
:port => '3000',
|
74
|
+
:end_point => '/some_where' },
|
75
|
+
:home_url => 'http://localhost:3000/some_where',
|
76
|
+
:return_response_as => :as_hash,
|
77
|
+
:return_with_root => true,
|
78
|
+
:return_as_active_resource => false })
|
51
79
|
end
|
52
80
|
end
|
53
81
|
end
|
@@ -10,12 +10,12 @@ describe RemoteFactoryGirl::Http do
|
|
10
10
|
|
11
11
|
it 'should raise no host config errors' do
|
12
12
|
rest_client.stub(:post).with(config.home_url, params, content_type: :json, accept: :json).and_return(true)
|
13
|
-
expect(config).to receive(:
|
13
|
+
expect(config).to receive(:raise_if_host_not_set)
|
14
14
|
RemoteFactoryGirl::Http.post(config, params, rest_client)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should send http request to home_url with params' do
|
18
|
-
config.stub(:
|
18
|
+
config.stub(:raise_if_host_not_set)
|
19
19
|
expect(rest_client).to receive(:post).with(config.home_url, params, content_type: :json, accept: :json)
|
20
20
|
RemoteFactoryGirl::Http.post(config, params, rest_client)
|
21
21
|
end
|
@@ -4,30 +4,12 @@ describe RemoteFactoryGirl do
|
|
4
4
|
|
5
5
|
let(:config) { double('config', :to_hash => {}) }
|
6
6
|
|
7
|
-
|
8
|
-
rfg = RemoteFactoryGirl::RemoteFactoryGirl.new('user', { :first_name => 'Sam' }, config)
|
9
|
-
expect(rfg.params).to eq(
|
10
|
-
{ :factory => 'user', :attributes => { :first_name => 'Sam'}}
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#post' do
|
7
|
+
describe '#create' do
|
15
8
|
it 'should send a post request' do
|
16
9
|
http = double('RemoteFactoryGirl::Http')
|
17
10
|
attributes = { :first_name => 'Sam' }
|
18
11
|
expect(http).to receive(:post).with(config, {:factory => 'user', :attributes => { :first_name => 'Sam'}})
|
19
|
-
RemoteFactoryGirl::RemoteFactoryGirl.new('user', attributes,
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#apply_config' do
|
24
|
-
it 'should apply config options to json with supplied configuration' do
|
25
|
-
attributes = { :first_name => 'Sam' }
|
26
|
-
config_applier = double('RemoteFactoryGirl::ConfigApplier')
|
27
|
-
post = double('RemoteFactoryGirl::Http', :json => {})
|
28
|
-
RemoteFactoryGirl::Http.stub(:post).and_return(post)
|
29
|
-
expect(config_applier).to receive(:apply_config).with(post.json, config.to_hash)
|
30
|
-
RemoteFactoryGirl::RemoteFactoryGirl.new('user', attributes, config).apply_config(config_applier)
|
12
|
+
RemoteFactoryGirl::RemoteFactoryGirl.new(config).create('user', attributes, http)
|
31
13
|
end
|
32
14
|
end
|
33
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_factory_girl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tdouce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: virtus
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: dish
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +82,6 @@ files:
|
|
96
82
|
- lib/remote_factory_girl.rb
|
97
83
|
- lib/remote_factory_girl/config.rb
|
98
84
|
- lib/remote_factory_girl/config_applier.rb
|
99
|
-
- lib/remote_factory_girl/config_struct.rb
|
100
85
|
- lib/remote_factory_girl/exceptions.rb
|
101
86
|
- lib/remote_factory_girl/hash_to_dot.rb
|
102
87
|
- lib/remote_factory_girl/http.rb
|
@@ -106,7 +91,6 @@ files:
|
|
106
91
|
- spec/integration/remote_factory_girl_spec.rb
|
107
92
|
- spec/models/remote_factory_girl/config_applier_spec.rb
|
108
93
|
- spec/models/remote_factory_girl/config_spec.rb
|
109
|
-
- spec/models/remote_factory_girl/config_struct_spec.rb
|
110
94
|
- spec/models/remote_factory_girl/http_spec.rb
|
111
95
|
- spec/models/remote_factory_girl/json_to_active_resource_spec.rb
|
112
96
|
- spec/models/remote_factory_girl_spec.rb
|
@@ -140,7 +124,6 @@ test_files:
|
|
140
124
|
- spec/integration/remote_factory_girl_spec.rb
|
141
125
|
- spec/models/remote_factory_girl/config_applier_spec.rb
|
142
126
|
- spec/models/remote_factory_girl/config_spec.rb
|
143
|
-
- spec/models/remote_factory_girl/config_struct_spec.rb
|
144
127
|
- spec/models/remote_factory_girl/http_spec.rb
|
145
128
|
- spec/models/remote_factory_girl/json_to_active_resource_spec.rb
|
146
129
|
- spec/models/remote_factory_girl_spec.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
module RemoteFactoryGirl
|
4
|
-
class ConfigStruct < OpenStruct
|
5
|
-
def self.block_to_hash(block = nil)
|
6
|
-
config = self.new
|
7
|
-
if block
|
8
|
-
block.call(config)
|
9
|
-
config.to_hash
|
10
|
-
else
|
11
|
-
{}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_hash
|
16
|
-
@table
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'remote_factory_girl/config_struct.rb'
|
2
|
-
|
3
|
-
describe RemoteFactoryGirl::ConfigStruct do
|
4
|
-
|
5
|
-
describe '.block_to_hash' do
|
6
|
-
it 'should be able to configure with a block' do
|
7
|
-
class Thing
|
8
|
-
def self.configure(&block)
|
9
|
-
RemoteFactoryGirl::ConfigStruct.block_to_hash(block)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
thing = Thing.configure do |config|
|
14
|
-
config.first_name = 'Sam'
|
15
|
-
config.last_name = 'Iam'
|
16
|
-
end
|
17
|
-
|
18
|
-
expect(thing.to_hash).to eq({:first_name => 'Sam', :last_name => 'Iam'})
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|