rs_yettings 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +186 -0
- data/Rakefile +38 -0
- data/lib/tasks/yettings.rake +17 -0
- data/lib/yettings.rb +79 -0
- data/lib/yettings/base.rb +41 -0
- data/lib/yettings/encryption.rb +124 -0
- data/lib/yettings/railtie.rb +15 -0
- data/lib/yettings/version.rb +3 -0
- data/spec/dummy/Guardfile +228 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/ignored.yml +17 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config/yetting.yml +17 -0
- data/spec/dummy/config/yetting.yml.pub +0 -0
- data/spec/dummy/config/yettings/blank.yml +0 -0
- data/spec/dummy/config/yettings/defaults.yml +6 -0
- data/spec/dummy/config/yettings/hendrix.yml +11 -0
- data/spec/dummy/config/yettings/jimi.yml +11 -0
- data/spec/dummy/config/yettings/secret.yml.pub +1 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1 -0
- data/spec/dummy/log/test.log +141 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/yettings/base_spec.rb +66 -0
- data/spec/yettings/encryption_spec.rb +104 -0
- data/spec/yettings_spec.rb +90 -0
- metadata +320 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
yetting1: what
|
3
|
+
yetting2: 999
|
4
|
+
yetting3: <%= "this is erb " %>
|
5
|
+
yetting4:
|
6
|
+
- element1
|
7
|
+
- element2
|
8
|
+
|
9
|
+
development:
|
10
|
+
<<: *defaults
|
11
|
+
yetting1: override for dev
|
12
|
+
|
13
|
+
test:
|
14
|
+
<<: *defaults
|
15
|
+
|
16
|
+
production:
|
17
|
+
<<: *defaults
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
HOoHbzGX6mUJA7TNJsxTum2yrLDzyFJRkqE24/G7zdMYEQWrJ3jKS4PYoJodWwM1yqPLvgq7IzgNnXVq5AJPoSagWUWZwgS2Xpw1CgiwY+LU1BNXMfa1iSy3UVAzQ1UQeoDlw9WgjH8QL/ZA/GiqFrx1bzxD/xgFGEj5Y4AqqYkoSNqTNTLR0JRYvYNLYmbEFSt0Lj7hTZXVLVkF0i4ivBxUkDceeO+iSoEn8fPkMfS2SDL+uNMJE5SKu7RC3Zj+zroKQTpGfFPX9vqzSxasrznf9fKGqZUAsCk3G7BvgYU/TA8l9EtA2HxM7GquXtEWP5wlLut1jDCb5ZfqaFiGYiUmz0dG2HjEzl7znprgbqlrY/MyYw6eDnRuCaErAVWyaOHbuRsWd151YlqXXsNEdQCO5u0np+ynztcpLDOanzyUaOnHucVizjTkuFlddmko//VdB3G3YSRgFNjuDZzlxtZEpHq1yrRooCo8yIyMhRW+ZdEO5ANDWYszpjqJtnMRJAi8j6QtttxQoirw+chbCjG7hflzqUhqS6w79ax/luB9oGM0zQKJD4LYqxfw4P1Uut6Af3SfNh5JDBE3k0MP1r47pj0g2mZL5dlGVQwD8Ww=
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,141 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
2
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
3
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
4
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
5
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
6
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
7
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
8
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
9
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
10
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
12
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
13
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
14
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
15
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
16
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
17
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
18
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
19
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
20
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
21
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
22
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
23
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
24
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
25
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
26
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
27
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
28
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
29
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
30
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
31
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
32
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
33
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
34
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
35
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
36
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
37
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
38
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
39
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
40
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
41
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
42
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
43
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
44
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
45
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
46
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
47
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
48
|
+
Connecting to database specified by database.yml
|
49
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
50
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
51
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
52
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
53
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
54
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
55
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
56
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
57
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
58
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
59
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
60
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
61
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
62
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
63
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
64
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
65
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
66
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
67
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
68
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
69
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
70
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
71
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
72
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
73
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
74
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
75
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
76
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
77
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
78
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
79
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
80
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
81
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
82
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
83
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
84
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
85
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
86
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
87
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
88
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
89
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
90
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
91
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
92
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
93
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
94
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
95
|
+
Connecting to database specified by database.yml
|
96
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
97
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
98
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
99
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
100
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
101
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
102
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
103
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
104
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
105
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
106
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
107
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
108
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
109
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
110
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
111
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
112
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
113
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
114
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
115
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
116
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
117
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
118
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
119
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
120
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
121
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
122
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
123
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
124
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
125
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
126
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
127
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
128
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
129
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
130
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
131
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
132
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
133
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
134
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
135
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
136
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
137
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
138
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
139
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
140
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
141
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spork'
|
2
|
+
|
3
|
+
Spork.prefork do
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter "/spec/"
|
7
|
+
end
|
8
|
+
|
9
|
+
ENV["RAILS_ENV"] ||= 'test'
|
10
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
11
|
+
require 'rspec/rails'
|
12
|
+
require 'rspec/autorun'
|
13
|
+
require 'factory_girl'
|
14
|
+
require "shoulda-matchers"
|
15
|
+
|
16
|
+
Dir[Rails.root.join("../spec/support/**/*.rb")].each {|f| require f }
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.mock_with :rspec
|
20
|
+
config.use_transactional_fixtures = true
|
21
|
+
config.filter_run_excluding :external => true
|
22
|
+
config.infer_base_class_for_anonymous_controllers = false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Spork.each_run do
|
27
|
+
FactoryGirl.reload
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Yettings::Base do
|
4
|
+
YETTINGS_DIR = "#{Rails.root}/config/yettings"
|
5
|
+
YETTING_FILE = "#{Rails.root}/config/yetting.yml"
|
6
|
+
BLANK_YETTING_FILE = "#{Rails.root}/config/yettings/blank.yml"
|
7
|
+
|
8
|
+
subject { Class.new Yettings::Base }
|
9
|
+
|
10
|
+
describe ".load_yml_erb" do
|
11
|
+
|
12
|
+
it "should load the yml and return hash" do
|
13
|
+
yml_erb = File.read YETTING_FILE
|
14
|
+
expected = {"yetting1" => "what",
|
15
|
+
"yetting2" => 999,
|
16
|
+
"yetting3" => "this is erb",
|
17
|
+
"yetting4" => ["element1", "element2"]}
|
18
|
+
subject.load_yml_erb(yml_erb).should eq expected
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should apply default settings to all environments" do
|
22
|
+
yml_erb = File.read "#{YETTINGS_DIR}/defaults.yml"
|
23
|
+
subject.load_yml_erb(yml_erb)
|
24
|
+
subject.yetting1.should eq 'default value'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should override default settings specific to environment" do
|
28
|
+
yml_erb = File.read "#{YETTINGS_DIR}/defaults.yml"
|
29
|
+
subject.load_yml_erb(yml_erb)
|
30
|
+
subject.yetting2.should eq 'test value'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".method_missing" do
|
35
|
+
it "should issue a warning for method_missing" do
|
36
|
+
begin
|
37
|
+
subject.whatwhat
|
38
|
+
rescue => e
|
39
|
+
e.should be_kind_of Yettings::Base::UndefinedYettingError
|
40
|
+
e.message.should =~ /whatwhat is not defined in /
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".define_methods" do
|
46
|
+
it "defines methods for a hash" do
|
47
|
+
hash = {:method1 => "val1", :method2 => "val2"}
|
48
|
+
subject.define_methods(hash)
|
49
|
+
subject.method1.should eq "val1"
|
50
|
+
subject.method2.should eq "val2"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe ".build_hash" do
|
55
|
+
it "returns blank hash for empty yml file" do
|
56
|
+
expected = {}
|
57
|
+
subject.build_hash("").should eq expected
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns hash for non-blank yaml file" do
|
61
|
+
yml = File.read "#{YETTINGS_DIR}/defaults.yml"
|
62
|
+
expected = {"defaults"=>{"yetting1"=>"default value", "yetting2"=>"default value"}, "test"=>{"yetting2"=>"test value"}}
|
63
|
+
subject.build_hash(yml).should eq expected
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Yettings::Encryption do
|
4
|
+
YETTINGS_DIR = "#{Rails.root}/config/yettings"
|
5
|
+
YETTING_FILE = "#{Rails.root}/config/yetting.yml"
|
6
|
+
SECRET_YETTING_FILE = "#{Rails.root}/config/yettings/.private/secret2.yml"
|
7
|
+
SECRET_YETTING_PUB_FILE = "#{Rails.root}/config/yettings/secret2.yml.pub"
|
8
|
+
BLANK_YETTING_FILE = "#{Rails.root}/config/yettings/blank.yml"
|
9
|
+
|
10
|
+
let(:default_yml){ File.read "#{YETTINGS_DIR}/defaults.yml" }
|
11
|
+
let(:blank_yml){ "" }
|
12
|
+
|
13
|
+
describe ".decrypt_string" do
|
14
|
+
it "decrypts the string in binary" do
|
15
|
+
str = "This is a private string"
|
16
|
+
encrypted = Yettings.encrypt_string(str)
|
17
|
+
Yettings.decrypt_string(encrypted).should eq str
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".encrypt_string" do
|
22
|
+
it "encrypts the string in binary" do
|
23
|
+
str = "This is a private string"
|
24
|
+
Yettings.encrypt_string(str).equals_without_encryption(str).should be false
|
25
|
+
enc = Yettings.encrypt_string(str)
|
26
|
+
Yettings.decrypt_string(enc).should eq str
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".encrypt_file" do
|
31
|
+
before(:each) do
|
32
|
+
File.delete(SECRET_YETTING_PUB_FILE) if File.exists?(SECRET_YETTING_PUB_FILE)
|
33
|
+
end
|
34
|
+
|
35
|
+
after(:each) do
|
36
|
+
File.delete(SECRET_YETTING_PUB_FILE) if File.exists?(SECRET_YETTING_PUB_FILE)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns nil if the private key is nil" do
|
40
|
+
Yettings.stub(:private_key => nil)
|
41
|
+
Yettings.encrypt_file(YETTING_FILE).should eq nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns nil check_overwrite is false" do
|
45
|
+
Yettings.stub(:check_overwrite => false)
|
46
|
+
Yettings.encrypt_file(YETTING_FILE).should eq nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "writes to file if private key is available and check_overwrite passes" do
|
50
|
+
Yettings.stub(:check_overwrite => true)
|
51
|
+
Yettings.encrypt_file(SECRET_YETTING_FILE)
|
52
|
+
File.exists?(SECRET_YETTING_PUB_FILE)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".decrypt_file" do
|
57
|
+
pending
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ".encrypt_files!" do
|
61
|
+
pending
|
62
|
+
end
|
63
|
+
|
64
|
+
describe ".decrypt_files!" do
|
65
|
+
pending
|
66
|
+
end
|
67
|
+
|
68
|
+
describe ".encrypt_files!" do
|
69
|
+
pending
|
70
|
+
end
|
71
|
+
|
72
|
+
describe ".check_overwrite" do
|
73
|
+
pending
|
74
|
+
end
|
75
|
+
|
76
|
+
describe ".private_path" do
|
77
|
+
pending
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".public_path" do
|
81
|
+
pending
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ".public_key" do
|
85
|
+
pending
|
86
|
+
end
|
87
|
+
|
88
|
+
describe ".private_key" do
|
89
|
+
pending
|
90
|
+
end
|
91
|
+
|
92
|
+
describe ".load_key" do
|
93
|
+
pending
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".key_path" do
|
97
|
+
pending
|
98
|
+
end
|
99
|
+
|
100
|
+
describe ".gen_keys" do
|
101
|
+
pending
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|