appsent 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -5
- data/Rakefile +11 -1
- data/features/README.md +5 -5
- data/features/array_with_nested_params.feature +5 -5
- data/features/full_example.feature +13 -13
- data/features/simple_usage.feature +2 -2
- data/features/with_nested_params.feature +3 -3
- data/lib/appsent.rb +2 -2
- data/lib/appsent/config_file.rb +6 -5
- data/lib/appsent/config_value.rb +28 -6
- data/lib/appsent/version.rb +1 -1
- data/spec/{internal_api → appsent}/config_file_spec.rb +71 -1
- data/spec/appsent/config_value_spec.rb +234 -0
- data/spec/appsent_spec.rb +140 -0
- data/spec/old_api/dsl_spec.rb +135 -0
- data/spec/old_api/internal_api/config_file_spec.rb +222 -0
- data/spec/{internal_api → old_api/internal_api}/config_value_spec.rb +65 -17
- metadata +22 -19
- data/spec/dsl_spec.rb +0 -72
@@ -17,10 +17,12 @@ describe AppSent::ConfigValue do
|
|
17
17
|
let(:params) do
|
18
18
|
[
|
19
19
|
@params['name'],
|
20
|
-
@params['type'],
|
21
20
|
@params['value'],
|
22
|
-
|
23
|
-
@params['
|
21
|
+
{
|
22
|
+
:type => @params['type'],
|
23
|
+
:desc => @params['desc'],
|
24
|
+
:example => @params['example']
|
25
|
+
}
|
24
26
|
]
|
25
27
|
end
|
26
28
|
|
@@ -31,7 +33,8 @@ describe AppSent::ConfigValue do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should raise exception if unsupported type passed" do
|
34
|
-
|
36
|
+
@params['type'] = 'asd'
|
37
|
+
expect { subject.new(*params) }.to raise_exception(/data type should be ruby class!/)
|
35
38
|
end
|
36
39
|
|
37
40
|
context "with &block given" do
|
@@ -64,11 +67,14 @@ describe AppSent::ConfigValue do
|
|
64
67
|
context "should return false" do
|
65
68
|
|
66
69
|
it "if entry does not presence in config file" do
|
67
|
-
|
70
|
+
@params['value']=nil
|
71
|
+
subject.new(*params).should_not be_valid
|
68
72
|
end
|
69
73
|
|
70
74
|
it "if data in config file has wrong type" do
|
71
|
-
|
75
|
+
@params['type']=Array
|
76
|
+
@params['value']='string'
|
77
|
+
subject.new(*params).should_not be_valid
|
72
78
|
end
|
73
79
|
|
74
80
|
it "if child value is not valid" do
|
@@ -80,7 +86,7 @@ describe AppSent::ConfigValue do
|
|
80
86
|
subject.new(*params,&values_block).should_not be_valid
|
81
87
|
end
|
82
88
|
|
83
|
-
context "with type => Array" do
|
89
|
+
context "with type => Array", :wip => true do
|
84
90
|
|
85
91
|
it "if actual data is not array" do
|
86
92
|
@params['type']=Array
|
@@ -117,7 +123,7 @@ describe AppSent::ConfigValue do
|
|
117
123
|
subject.new(*params,&values_block).should be_valid
|
118
124
|
end
|
119
125
|
|
120
|
-
context "with type => Array" do
|
126
|
+
context "with type => Array", :wip => true do
|
121
127
|
|
122
128
|
it "if actual data is an array of right hashes" do
|
123
129
|
@params['type']=Array
|
@@ -140,42 +146,84 @@ describe AppSent::ConfigValue do
|
|
140
146
|
|
141
147
|
context "#error_message" do
|
142
148
|
|
149
|
+
subject { described_class.new(*params) }
|
150
|
+
|
143
151
|
context "should generate correct error message when no data" do
|
144
152
|
|
145
153
|
it "with full description" do
|
146
|
-
|
154
|
+
@params['name'] = 'database'
|
155
|
+
@params['value'] = nil
|
156
|
+
@params['type'] = String
|
157
|
+
@params['desc'] = 'Database name'
|
158
|
+
@params['example'] = 'localhost'
|
159
|
+
subject.error_message.should eq(" database: localhost # does not exists(Database name), String")
|
147
160
|
end
|
148
161
|
|
149
162
|
it "without example value" do
|
150
|
-
|
163
|
+
@params['name'] = 'database'
|
164
|
+
@params['value'] = nil
|
165
|
+
@params['type'] = String
|
166
|
+
@params['desc'] = 'Database name'
|
167
|
+
@params.delete('example')
|
168
|
+
subject.error_message.should eq(" database: # does not exists(Database name), String")
|
151
169
|
end
|
152
170
|
|
153
171
|
it "without description" do
|
154
|
-
|
172
|
+
@params['name'] = 'database'
|
173
|
+
@params['value'] = nil
|
174
|
+
@params['type'] = String
|
175
|
+
@params.delete('desc')
|
176
|
+
@params['example'] = 'localhost'
|
177
|
+
subject.error_message.should eq(" database: localhost # does not exists, String")
|
155
178
|
end
|
156
179
|
|
157
180
|
it "without example and description" do
|
158
|
-
|
181
|
+
@params['name'] = 'database'
|
182
|
+
@params['value'] = nil
|
183
|
+
@params['type'] = String
|
184
|
+
@params.delete('desc')
|
185
|
+
@params.delete('example')
|
186
|
+
subject.error_message.should eq(" database: # does not exists, String")
|
159
187
|
end
|
160
188
|
|
161
189
|
end
|
162
190
|
|
163
|
-
context "should generate correct error message when
|
191
|
+
context "should generate correct error message when data is of wrong type" do
|
164
192
|
|
165
193
|
it "with full description" do
|
166
|
-
|
194
|
+
@params['name'] = 'database'
|
195
|
+
@params['value'] = 20
|
196
|
+
@params['type'] = String
|
197
|
+
@params['desc'] = 'Database name'
|
198
|
+
@params['example'] = 'localhost'
|
199
|
+
subject.error_message.should eq(" database: 20 # wrong type,should be String(Database name)")
|
167
200
|
end
|
168
201
|
|
169
202
|
it "without example value" do
|
170
|
-
|
203
|
+
@params['name'] = 'database'
|
204
|
+
@params['value'] = 20
|
205
|
+
@params['type'] = String
|
206
|
+
@params['desc'] = 'Database name'
|
207
|
+
@params.delete('example')
|
208
|
+
subject.error_message.should eq(" database: 20 # wrong type,should be String(Database name)")
|
171
209
|
end
|
172
210
|
|
173
211
|
it "without description" do
|
174
|
-
|
212
|
+
@params['name'] = 'database'
|
213
|
+
@params['value'] = 20
|
214
|
+
@params['type'] = String
|
215
|
+
@params.delete('desc')
|
216
|
+
@params['example'] = 'localhost'
|
217
|
+
subject.error_message.should eq(" database: 20 # wrong type,should be String")
|
175
218
|
end
|
176
219
|
|
177
220
|
it "without example and description" do
|
178
|
-
|
221
|
+
@params['name'] = 'database'
|
222
|
+
@params['value'] = 20
|
223
|
+
@params['type'] = String
|
224
|
+
@params.delete('desc')
|
225
|
+
@params.delete('example')
|
226
|
+
subject.error_message.should eq(" database: 20 # wrong type,should be String")
|
179
227
|
end
|
180
228
|
|
181
229
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-05 00:00:00.000000000 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yard
|
17
|
-
requirement: &
|
17
|
+
requirement: &77859100 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *77859100
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: BlueCloth
|
28
|
-
requirement: &
|
28
|
+
requirement: &77858080 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *77858080
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: RedCloth
|
39
|
-
requirement: &
|
39
|
+
requirement: &77857690 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *77857690
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &77857220 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.0.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *77857220
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: aruba
|
61
|
-
requirement: &
|
61
|
+
requirement: &77856890 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *77856890
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
|
-
requirement: &
|
72
|
+
requirement: &77856560 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *77856560
|
81
81
|
description: config management solution
|
82
82
|
email:
|
83
83
|
- kucaahbe@ukr.net
|
@@ -108,12 +108,15 @@ files:
|
|
108
108
|
- lib/appsent/config_value.rb
|
109
109
|
- lib/appsent/tools.rb
|
110
110
|
- lib/appsent/version.rb
|
111
|
-
- spec/
|
111
|
+
- spec/appsent/config_file_spec.rb
|
112
|
+
- spec/appsent/config_value_spec.rb
|
113
|
+
- spec/appsent_spec.rb
|
112
114
|
- spec/fixtures/database.yml
|
113
115
|
- spec/fixtures/simple_config.yml
|
114
116
|
- spec/fixtures/simple_config_with_just_type.yml
|
115
|
-
- spec/
|
116
|
-
- spec/internal_api/
|
117
|
+
- spec/old_api/dsl_spec.rb
|
118
|
+
- spec/old_api/internal_api/config_file_spec.rb
|
119
|
+
- spec/old_api/internal_api/config_value_spec.rb
|
117
120
|
- spec/spec_helper.rb
|
118
121
|
- spec/tools_spec.rb
|
119
122
|
has_rdoc: true
|
@@ -131,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
134
|
version: '0'
|
132
135
|
segments:
|
133
136
|
- 0
|
134
|
-
hash:
|
137
|
+
hash: -225741935
|
135
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
139
|
none: false
|
137
140
|
requirements:
|
@@ -140,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
143
|
version: '0'
|
141
144
|
segments:
|
142
145
|
- 0
|
143
|
-
hash:
|
146
|
+
hash: -225741935
|
144
147
|
requirements: []
|
145
148
|
rubyforge_project: appsent
|
146
149
|
rubygems_version: 1.6.2
|
data/spec/dsl_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "AppSent.init" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@right_params = { :path => 'fixtures', :env => 'test' }
|
7
|
-
@fixtures_path = File.expand_path(File.join(File.dirname(__FILE__),'fixtures'))
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should require config path" do
|
11
|
-
@right_params.delete(:path)
|
12
|
-
expect { AppSent.init(@right_params) do; end }.to raise_exception(AppSent::ConfigPathNotSet)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should require environment variable" do
|
16
|
-
@right_params.delete(:env)
|
17
|
-
expect { AppSent.init(@right_params) do; end }.to raise_exception(AppSent::EnvironmentNotSet)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should require block" do
|
21
|
-
expect { AppSent.init(@right_params) }.to raise_exception(AppSent::BlockRequired)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should save config path to @@config_path" do
|
25
|
-
AppSent.init(@right_params) do; end
|
26
|
-
AppSent.config_path.should eq(@fixtures_path)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should save environment to @@environment" do
|
30
|
-
AppSent.init(@right_params) do; end
|
31
|
-
AppSent.send(:class_variable_get,:@@environment).should eq('test')
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should save array of configs to @@configs" do
|
35
|
-
expect {
|
36
|
-
AppSent.init(@right_params) do
|
37
|
-
config1
|
38
|
-
config2
|
39
|
-
config3
|
40
|
-
end
|
41
|
-
}.to raise_exception(AppSent::Error)
|
42
|
-
AppSent.config_files.should eq(%w(config1 config2 config3))
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should create corresponding constants with values" do
|
46
|
-
AppSent.init(@right_params) do
|
47
|
-
simple_config
|
48
|
-
database do
|
49
|
-
username :type => String
|
50
|
-
password :type => String
|
51
|
-
port :type => Fixnum
|
52
|
-
end
|
53
|
-
|
54
|
-
simple_config_with_just_type :type => Array
|
55
|
-
end
|
56
|
-
|
57
|
-
AppSent::SIMPLE_CONFIG.should eq({:a=>1, :b=>'2'})
|
58
|
-
AppSent::DATABASE.should eq({:username => 'user', :password => 'pass', :port => 100500})
|
59
|
-
AppSent::SIMPLE_CONFIG_WITH_JUST_TYPE.should eq([1,2,3])
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'AppSent.new' do
|
65
|
-
|
66
|
-
subject { AppSent.new }
|
67
|
-
|
68
|
-
%w(all_valid? load! full_error_message).each do |method|
|
69
|
-
it { should respond_to(method) }
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|