remote_database_cleaner 0.0.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc2ebd291c95cbc8073a0e9ecd2c258a77fc153
4
- data.tar.gz: f1c0cfe79c90fb2a7d0bec54f75b3d76bf6bc2f7
3
+ metadata.gz: de1f771cfcdd7098d50841e43189cb642ba8bb06
4
+ data.tar.gz: 1352128823b0cf802268747b7e2c73ccbc012963
5
5
  SHA512:
6
- metadata.gz: a3f00aeac6f67d0e26402285cb462fa7ad1cec55bdf497bf6459f78cda948844044fdbf15ba6762121ae46dce6e3dc612bcd41239db4ebcbe97d84453408e68e
7
- data.tar.gz: a87ece00e9ae1d237b3271ab5440aa0d6f12c16fc9bf26c418c86180c875269c3fe28ba3afc6919aeff4fd5f1cc20f5e369ddad0a3c9f3d854c46adf8e9a380d
6
+ metadata.gz: 2bd451b22867e08e94bf8b2b5494f6165d83575d61f4a9298b275aa6b32670994eb28e25ff4d8e87ede9263f54da1085ed76c38875094af9eb033351032c37ac
7
+ data.tar.gz: 7226194d185dfcd00890b54da40d390da63d6bf6d253d6c71dbeb95e4eb0af31c3c2adbaed846b55948fc43f6cb7204844f61687123c579eb0e002f1a2268e94
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 1.0.2 - Nov. 10, 2014
2
+
3
+ 1. Configure multiple "home"/"remote" applications
4
+ 2. Remove RemoteDatabaseCleaner.reset. Instead use, RemoteDatabaseCleaner.remotes_config.reset
5
+ 3. Adds option to configure remote_database_cleaner to use HTTPS
6
+ 4. Refactors how remote_database_cleaner implements configuration
7
+ 5. Removes trailing whitespaces
8
+ 6. Adds tests for RemoteDatabaseCleaner::Config#has_home?
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rest-client' # http
4
- gem 'virtus', '~> 1.0' # defining attributes on a model: strong typing like objects and defaults
5
4
 
6
5
  # Specify your gem's dependencies in remote_database_cleaner.gemspec
7
6
  gemspec
data/README.md CHANGED
@@ -12,8 +12,13 @@ See [GETTING STARTED](https://github.com/tdouce/remote_database_cleaner/wiki/Get
12
12
 
13
13
  ## Contributing
14
14
 
15
- 1. Fork it ( http://github.com/<my-github-username>/remote_database_cleaner/fork )
15
+ 1. Fork it ( http://github.com/tdouce/remote_database_cleaner/fork )
16
16
  2. Create your feature branch (`git checkout -b my-new-feature`)
17
17
  3. Commit your changes (`git commit -am 'Add some feature'`)
18
18
  4. Push to the branch (`git push origin my-new-feature`)
19
19
  5. Create new Pull Request
20
+
21
+ ## TODOS
22
+
23
+ 1. Allow remote_database_cleaner to configure multiple "homes" (external services) so that
24
+ remote_database_cleaner can clean test data in multiple "homes"s.
@@ -1,41 +1,32 @@
1
1
  require 'remote_database_cleaner/exceptions'
2
- require 'virtus'
3
2
 
4
3
  module RemoteDatabaseCleaner
5
4
  class Config
6
- include Virtus.model
7
5
 
8
- DEFAULT_HOME_CONFIG = { :host => nil,
9
- :port => nil,
10
- :end_point => '/remote_database_cleaner/home/clean' }
6
+ DEFAULT_END_POINT = '/remote_database_cleaner/home/clean'.freeze
11
7
 
12
- attribute :home, Hash, :default => DEFAULT_HOME_CONFIG
8
+ attr_accessor :home, :https
13
9
 
14
- def self.configure(configs)
15
- new(configs)
16
- end
17
-
18
- def initialize(attrs = {})
19
- attrs[:home] = update_home_config(attrs)
20
- super(attrs)
10
+ def initialize
11
+ @home = default_home_config
12
+ @https = false
21
13
  end
22
14
 
23
15
  def home_url
24
- raise_no_host_error
25
- http = 'http://'
16
+ raise_if_host_not_set
26
17
  if home[:port]
27
- "#{ http }#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }"
18
+ "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }:#{ home.fetch(:port) }#{ home.fetch(:end_point) }"
28
19
  else
29
- "#{ http }#{ home.fetch(:host) }#{ home.fetch(:end_point) }"
20
+ "#{ hyper_text_transfer_protocal }://#{ home.fetch(:host) }#{ home.fetch(:end_point) }"
30
21
  end
31
22
  end
32
23
 
33
24
  def to_hash
34
- raise_no_host_error
35
- super.merge(home_url: home_url)
25
+ { home: home,
26
+ home_url: home_url }
36
27
  end
37
28
 
38
- def raise_no_host_error
29
+ def raise_if_host_not_set
39
30
  raise RemoteDatabaseCleanerConfigError.new("RemoteDatabaseCleaner.config.home[:host] can not be nil") unless has_home?
40
31
  end
41
32
 
@@ -45,8 +36,14 @@ module RemoteDatabaseCleaner
45
36
 
46
37
  private
47
38
 
48
- def update_home_config(attrs)
49
- attrs[:home] = DEFAULT_HOME_CONFIG.merge(attrs.fetch(:home, {}))
39
+ def hyper_text_transfer_protocal
40
+ https == true ? 'https' : 'http'
41
+ end
42
+
43
+ def default_home_config
44
+ { :host => nil,
45
+ :port => nil,
46
+ :end_point => DEFAULT_END_POINT }
50
47
  end
51
48
  end
52
49
  end
@@ -7,7 +7,7 @@ module RemoteDatabaseCleaner
7
7
  end
8
8
 
9
9
  def post(config, params, rest_client)
10
- config.raise_no_host_error
10
+ config.raise_if_host_not_set
11
11
  rest_client.post config.home_url, params, content_type: :json, accept: :json
12
12
  end
13
13
  end
@@ -0,0 +1,30 @@
1
+ require 'remote_database_cleaner/config'
2
+
3
+ module RemoteDatabaseCleaner
4
+ class RemotesConfig
5
+
6
+ attr_writer :current_remote
7
+ attr_accessor :remotes
8
+
9
+ DEFAULT_REMOTE_NAME = :default
10
+
11
+ alias_method :to_hash, :remotes
12
+
13
+ def initialize
14
+ @remotes = {}
15
+ end
16
+
17
+ def current_remote
18
+ @current_remote || default_remote_name
19
+ end
20
+
21
+ def default_remote_name
22
+ DEFAULT_REMOTE_NAME
23
+ end
24
+
25
+ def reset(config = Config.new)
26
+ self.current_remote = default_remote_name
27
+ self.remotes = { default_remote_name => config}
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module RemoteDatabaseCleaner
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,34 +1,37 @@
1
1
  require "remote_database_cleaner/version"
2
2
  require 'remote_database_cleaner/config'
3
3
  require 'remote_database_cleaner/http'
4
- require 'remote_database_cleaner/config_struct'
4
+ require 'remote_database_cleaner/remotes_config'
5
5
 
6
6
  module RemoteDatabaseCleaner
7
7
  class RemoteDatabaseCleaner
8
- def params
8
+ def params
9
9
  { :database => :clean }
10
10
  end
11
11
  end
12
12
 
13
- def self.configure(opts = { :config_struct => ConfigStruct, :config => Config }, &block)
14
- config = opts.fetch(:config_struct).block_to_hash(block)
15
- self.config = opts.fetch(:config).configure(config)
13
+ def self.configure(remote_name = remotes_config.default_remote_name, opts = {:config => Config }, &block)
14
+ configuration = opts.fetch(:config).new
15
+ yield(configuration)
16
+ remotes_config.remotes[remote_name] = configuration
16
17
  end
17
18
 
18
19
  def self.clean(http = Http)
19
20
  database_cleaner = RemoteDatabaseCleaner.new
20
- http.post(config, database_cleaner.params)
21
+ config_for_remote = config(remotes_config.current_remote)
22
+ http.post(config_for_remote, database_cleaner.params)
21
23
  end
22
24
 
23
- def self.config
24
- @config
25
+ def self.with_remote(remote_name = remotes_config.default_remote_name)
26
+ remotes_config.current_remote = remote_name
27
+ self
25
28
  end
26
29
 
27
- def self.config=(config)
28
- @config = config
30
+ def self.remotes_config
31
+ @remotes_config ||= RemotesConfig.new
29
32
  end
30
33
 
31
- def self.reset(config = Config.new)
32
- self.config = config
34
+ def self.config(remote_name = remotes_config.default_remote_name)
35
+ remotes_config.remotes[remote_name]
33
36
  end
34
37
  end
@@ -1,14 +1,17 @@
1
1
  require 'remote_database_cleaner'
2
+ require 'spec_helper'
2
3
 
3
4
  describe RemoteDatabaseCleaner do
4
5
 
5
- before { RemoteDatabaseCleaner.reset }
6
+ before { RemoteDatabaseCleaner.remotes_config.reset }
6
7
 
7
8
  describe 'configuration' do
8
9
  it 'should be configured with correct defaults' do
9
- expect(RemoteDatabaseCleaner.config.home).to eq({:host => nil,
10
- :port => nil,
10
+ expect(RemoteDatabaseCleaner.config.home).to eq({:host => nil,
11
+ :port => nil,
11
12
  :end_point => '/remote_database_cleaner/home/clean'})
13
+
14
+ expect(RemoteDatabaseCleaner.config.https).to eq(false)
12
15
  end
13
16
 
14
17
  it 'should be able to configure with a block' do
@@ -20,12 +23,65 @@ describe RemoteDatabaseCleaner do
20
23
 
21
24
  it 'should be able to configure .home' do
22
25
  RemoteDatabaseCleaner.config.home[:host] = 'fun_guy'
23
- RemoteDatabaseCleaner.config.home[:port] = 3333
24
- RemoteDatabaseCleaner.config.home[:end_point] = '/down_home'
26
+ RemoteDatabaseCleaner.config.home[:port] = 3333
27
+ RemoteDatabaseCleaner.config.home[:end_point] = '/down_home'
25
28
  expect(RemoteDatabaseCleaner.config.home[:host]).to eq('fun_guy')
26
29
  expect(RemoteDatabaseCleaner.config.home[:port]).to eq(3333)
27
30
  expect(RemoteDatabaseCleaner.config.home[:end_point]).to eq('/down_home')
28
31
  end
32
+
33
+ describe '#home_url' do
34
+ context 'when configured to with http' do
35
+ before do
36
+ RemoteDatabaseCleaner.config.home[:host] = 'localhost'
37
+ end
38
+
39
+ it 'should use http' do
40
+ expect(
41
+ RemoteDatabaseCleaner.config.home_url
42
+ ).to eq('http://localhost/remote_database_cleaner/home/clean')
43
+ end
44
+ end
45
+
46
+ context 'when configured to with https' do
47
+ before do
48
+ RemoteDatabaseCleaner.config.https = true
49
+ end
50
+
51
+ it 'should use https' do
52
+ RemoteDatabaseCleaner.config.home[:host] = 'localhost'
53
+
54
+ expect(
55
+ RemoteDatabaseCleaner.config.home_url
56
+ ).to eq('https://localhost/remote_database_cleaner/home/clean')
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'when configuring multiple remotes' do
62
+ before do
63
+ configure_remote_database_cleaner(remote_name: :travis,
64
+ host: 'localhost',
65
+ port: 3000,
66
+ end_point: '/remote_factory_girl/travis/home')
67
+ configure_remote_database_cleaner(remote_name: :casey,
68
+ host: 'over_the_rainbow',
69
+ port: 6000,
70
+ end_point: '/remote_factory_girl/casey/home')
71
+ end
72
+
73
+ it 'should return configuration for remote "travis"' do
74
+ expect(RemoteDatabaseCleaner.config(:travis).home).to eq({:host => 'localhost',
75
+ :port => 3000,
76
+ :end_point => '/remote_factory_girl/travis/home'})
77
+ end
78
+
79
+ it 'should return configuration for remote "casey"' do
80
+ expect(RemoteDatabaseCleaner.config(:casey).home).to eq({:host => 'over_the_rainbow',
81
+ :port => 6000,
82
+ :end_point => '/remote_factory_girl/casey/home'})
83
+ end
84
+ end
29
85
  end
30
86
 
31
87
  describe 'errors' do
@@ -41,13 +97,64 @@ describe RemoteDatabaseCleaner do
41
97
  end
42
98
 
43
99
  describe '.clean' do
44
- it 'should send a post request to home' do
45
- RemoteDatabaseCleaner::Http.stub(:post).and_return(true)
46
- RemoteDatabaseCleaner.config.home[:host] = 'localhost'
47
- config = RemoteDatabaseCleaner.config
48
- params = { :database => :clean }
49
- expect(RemoteDatabaseCleaner::Http).to receive(:post).with(config, params)
50
- RemoteDatabaseCleaner.clean
100
+ context 'when remote is not configured by name' do
101
+ before do
102
+ configure_remote_database_cleaner(host: 'localhost')
103
+ end
104
+
105
+ it 'should be configured to send http requests to default home' do
106
+ config = RemoteDatabaseCleaner.config
107
+ params = { :database => :clean }
108
+ expect(RemoteDatabaseCleaner::Http).to receive(:post).with(config, params)
109
+ RemoteDatabaseCleaner.clean
110
+ end
111
+
112
+ it 'should be configured to send HTTP requests to default home' do
113
+ http = double('http')
114
+
115
+ expect(http).to receive(:post) do |config, params, rest_client|
116
+ expect(config.home_url).to eq('http://localhost/remote_database_cleaner/home/clean')
117
+ end
118
+
119
+ RemoteDatabaseCleaner.clean(http)
120
+ end
121
+ end
122
+
123
+ context 'when remote is configured by name' do
124
+ before do
125
+ configure_remote_database_cleaner(remote_name: :travis,
126
+ host: 'localhost',
127
+ port: 3000,
128
+ end_point: '/remote_database_cleaner/travis/home/clean')
129
+ configure_remote_database_cleaner(remote_name: :casey,
130
+ host: 'over_the_rainbow',
131
+ port: 6000,
132
+ end_point: '/remote_database_cleaner/casey/home/clean')
133
+ end
134
+
135
+ context 'remote "travis"' do
136
+ it 'should send HTTP requests to remote named travis' do
137
+ http = double('http')
138
+
139
+ expect(http).to receive(:post) do |config, _, _|
140
+ expect(config.home_url).to eq('http://localhost:3000/remote_database_cleaner/travis/home/clean')
141
+ end
142
+
143
+ RemoteDatabaseCleaner.with_remote(:travis).clean(http)
144
+ end
145
+ end
146
+
147
+ context 'remote "travis"' do
148
+ it 'should send HTTP requests to remote named travis' do
149
+ http = double('http')
150
+
151
+ expect(http).to receive(:post) do |config, _, _|
152
+ expect(config.home_url).to eq('http://over_the_rainbow:6000/remote_database_cleaner/casey/home/clean')
153
+ end
154
+
155
+ RemoteDatabaseCleaner.with_remote(:casey).clean(http)
156
+ end
157
+ end
51
158
  end
52
159
  end
53
160
  end
@@ -1,4 +1,3 @@
1
- require 'virtus'
2
1
  require 'remote_database_cleaner/config'
3
2
  require 'remote_database_cleaner/exceptions'
4
3
 
@@ -10,19 +9,10 @@ describe RemoteDatabaseCleaner::Config do
10
9
 
11
10
  describe 'default configuration' do
12
11
  it 'should be configured with correct defaults' do
13
- default_config = RemoteDatabaseCleaner::Config.new
14
- expect(default_config.home).to eq({ :host => nil,
15
- :port => nil,
12
+ expect(default_config.home).to eq({ :host => nil,
13
+ :port => nil,
16
14
  :end_point => '/remote_database_cleaner/home/clean'})
17
- end
18
- end
19
-
20
- describe '.configure' do
21
- it 'should be able to set configurations' do
22
- config = RemoteDatabaseCleaner::Config.configure({ :home => { :host => 'tifton', :port => 9999, :end_point => '/somewhere' }})
23
- expect(config.home).to eq({ :host => 'tifton',
24
- :port => 9999,
25
- :end_point => '/somewhere'})
15
+ expect(default_config.https).to eq(false)
26
16
  end
27
17
  end
28
18
 
@@ -35,9 +25,99 @@ describe RemoteDatabaseCleaner::Config do
35
25
 
36
26
  it 'should return a url without a port if port is not configured' do
37
27
  default_config.home[:host] = 'localhost_no_port'
38
- default_config.home[:port] = nil
28
+ default_config.home[:port] = nil
39
29
  expect(default_config.home_url).to eq('http://localhost_no_port/remote_database_cleaner/home/clean')
40
30
  end
31
+
32
+ context 'configure https' do
33
+ before do
34
+ default_config.home[:host] = 'localhost'
35
+ default_config.home[:port] = 5555
36
+ default_config.https = true
37
+ end
38
+
39
+ it 'should be able configure Hyper Text Transfer Protocal Secure' do
40
+ expect(default_config.https).to eq(true)
41
+ end
42
+ end
43
+ end
44
+
45
+ describe '#to_hash' do
46
+ before do
47
+ default_config.home[:host] = 'localhost'
48
+ end
49
+
50
+ it 'should return a hash representation' do
51
+ expect(default_config.to_hash).to eq( {:home => {:host => 'localhost',
52
+ :port => nil,
53
+ :end_point => '/remote_database_cleaner/home/clean'},
54
+ :home_url => 'http://localhost/remote_database_cleaner/home/clean' })
55
+ end
56
+ end
57
+
58
+ describe '#has_home?' do
59
+ context "when 'host' and 'end_point' are set" do
60
+ before do
61
+ default_config.home[:host] = 'localhost'
62
+ default_config.home[:end_point] = 'somewhere/over/the/rainbow'
63
+ end
64
+
65
+ it 'should return true' do
66
+ expect(default_config.has_home?).to eq(true)
67
+ end
68
+ end
69
+
70
+ context "when 'host' is not set" do
71
+ before do
72
+ default_config.home[:end_point] = 'somewhere/over/the/rainbow'
73
+ end
74
+
75
+ context "when 'host' is an empty string" do
76
+ before do
77
+ default_config.home[:host] = ''
78
+ end
79
+
80
+ it 'should return false' do
81
+ expect(default_config.has_home?).to eq(false)
82
+ end
83
+ end
84
+
85
+ context "when 'host' is nil" do
86
+ before do
87
+ default_config.home[:host] = nil
88
+ end
89
+
90
+ it 'should return false' do
91
+ expect(default_config.has_home?).to eq(false)
92
+ end
93
+ end
94
+ end
95
+
96
+ context "when 'end_point' is not set" do
97
+ before do
98
+ default_config.home[:host] = 'localhost'
99
+ end
100
+
101
+ context "when 'end_point' is an empty string" do
102
+ before do
103
+ default_config.home[:end_point] = ''
104
+ end
105
+
106
+ it 'should return false' do
107
+ expect(default_config.has_home?).to eq(false)
108
+ end
109
+ end
110
+
111
+ context "when 'end_point' is nil" do
112
+ before do
113
+ default_config.home[:end_point] = nil
114
+ end
115
+
116
+ it 'should return false' do
117
+ expect(default_config.has_home?).to eq(false)
118
+ end
119
+ end
120
+ end
41
121
  end
42
122
 
43
123
  describe 'errors' do
@@ -10,13 +10,13 @@ describe RemoteDatabaseCleaner::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(:raise_no_host_error)
13
+ expect(config).to receive(:raise_if_host_not_set)
14
14
  RemoteDatabaseCleaner::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(:raise_no_host_error)
19
- expect(rest_client).to receive(:post).with(config.home_url, params, content_type: :json, accept: :json)
18
+ config.stub(:raise_if_host_not_set)
19
+ expect(rest_client).to receive(:post).with(config.home_url, params, content_type: :json, accept: :json)
20
20
  RemoteDatabaseCleaner::Http.post(config, params, rest_client)
21
21
  end
22
22
  end
@@ -11,28 +11,12 @@ describe RemoteDatabaseCleaner do
11
11
  end
12
12
 
13
13
  describe '.config' do
14
- it 'should be able to set and get config' do
15
- config = double('config')
16
- RemoteDatabaseCleaner.config = config
17
- expect(RemoteDatabaseCleaner.config).to equal(config)
18
- end
19
- end
20
-
21
- describe '.reset' do
22
- it 'should be able to reset the configuration' do
23
- config = double('config')
24
- RemoteDatabaseCleaner.config = config
25
- RemoteDatabaseCleaner.reset(double('config'))
26
- expect(RemoteDatabaseCleaner.config).to_not equal(config)
27
- end
28
14
  end
29
15
 
30
16
  describe '.clean' do
31
17
  it 'should send http request and parse request' do
32
- config = double('config', :home_url => 'http://somewhere', :to_hash => {})
33
- http = double('RemoteDatabaseCleaner::Http', :post => {})
34
- RemoteDatabaseCleaner.config = config
35
- expect(http).to receive(:post).with(config, { :database => :clean })
18
+ http = double('RemoteDatabaseCleaner::Http')
19
+ expect(http).to receive(:post)
36
20
  RemoteDatabaseCleaner.clean(http)
37
21
  end
38
22
  end
@@ -0,0 +1,42 @@
1
+ require 'remote_database_cleaner/remotes_config.rb'
2
+
3
+ describe RemoteDatabaseCleaner::Config do
4
+
5
+ let(:remotes_config) { RemoteDatabaseCleaner::RemotesConfig.new }
6
+ let(:home_1_config) { double('config') }
7
+ let(:home_2_config) { double('config') }
8
+ let(:default_remote_name) { RemoteDatabaseCleaner::RemotesConfig::DEFAULT_REMOTE_NAME }
9
+
10
+ describe '#initialize' do
11
+ context 'default configuration' do
12
+ it 'should be configured with correct defaults' do
13
+ expect(remotes_config.remotes).to eq({})
14
+ end
15
+ end
16
+ end
17
+
18
+ context 'adding a remote' do
19
+ before do
20
+ remotes_config.remotes[:home_1] = home_1_config
21
+ end
22
+
23
+ it 'should return configuration for home_1' do
24
+ expect(remotes_config.remotes[:home_1]).to eq(home_1_config)
25
+ end
26
+ end
27
+
28
+ describe '#reset' do
29
+
30
+ let(:reset_config) { double('config') }
31
+
32
+ before do
33
+ remotes_config.remotes[:home_1] = home_1_config
34
+ remotes_config.remotes[:home_2] = home_2_config
35
+ remotes_config.reset(reset_config)
36
+ end
37
+
38
+ it 'should return an empty hash' do
39
+ expect(remotes_config.to_hash).to eq({:default => reset_config })
40
+ end
41
+ end
42
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,3 +6,26 @@ require 'remote_database_cleaner'
6
6
  RSpec.configure do |config|
7
7
 
8
8
  end
9
+
10
+ def configure_remote_database_cleaner(remote_name: nil,
11
+ host: nil,
12
+ port: nil,
13
+ end_point: RemoteDatabaseCleaner::Config::DEFAULT_END_POINT,
14
+ https: false)
15
+ if remote_name.nil?
16
+ RemoteDatabaseCleaner.configure do |config|
17
+ config.home = {:host => host,
18
+ :port => port,
19
+ :end_point => end_point }
20
+ config.https = https
21
+ end
22
+
23
+ else
24
+ RemoteDatabaseCleaner.configure(remote_name) do |config|
25
+ config.home = {:host => host,
26
+ :port => port,
27
+ :end_point => end_point }
28
+ config.https = https
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_database_cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.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-07-28 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,22 +75,23 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
+ - CHANGELOG.md
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md
81
82
  - Rakefile
82
83
  - lib/remote_database_cleaner.rb
83
84
  - lib/remote_database_cleaner/config.rb
84
- - lib/remote_database_cleaner/config_struct.rb
85
85
  - lib/remote_database_cleaner/exceptions.rb
86
86
  - lib/remote_database_cleaner/http.rb
87
+ - lib/remote_database_cleaner/remotes_config.rb
87
88
  - lib/remote_database_cleaner/version.rb
88
89
  - remote_database_cleaner.gemspec
89
90
  - spec/integration/remote_database_cleaner_spec.rb
90
91
  - spec/models/remote_database_cleaner/config_spec.rb
91
- - spec/models/remote_database_cleaner/config_struct_spec.rb
92
92
  - spec/models/remote_database_cleaner/http_spec.rb
93
93
  - spec/models/remote_database_cleaner_spec.rb
94
+ - spec/models/remotes_config_spec.rb
94
95
  - spec/spec_helper.rb
95
96
  homepage: https://github.com/tdouce/remote_database_cleaner
96
97
  licenses:
@@ -119,7 +120,7 @@ summary: Initiate cleaning of test database in server from client
119
120
  test_files:
120
121
  - spec/integration/remote_database_cleaner_spec.rb
121
122
  - spec/models/remote_database_cleaner/config_spec.rb
122
- - spec/models/remote_database_cleaner/config_struct_spec.rb
123
123
  - spec/models/remote_database_cleaner/http_spec.rb
124
124
  - spec/models/remote_database_cleaner_spec.rb
125
+ - spec/models/remotes_config_spec.rb
125
126
  - spec/spec_helper.rb
@@ -1,19 +0,0 @@
1
- require 'ostruct'
2
-
3
- module RemoteDatabaseCleaner
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_database_cleaner/config_struct.rb'
2
-
3
- describe RemoteDatabaseCleaner::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
- RemoteDatabaseCleaner::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