hibachi 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +18 -0
- data/README.md +197 -0
- data/Rakefile +10 -0
- data/hibachi.gemspec +31 -0
- data/lib/generators/hibachi/install_generator.rb +14 -0
- data/lib/generators/hibachi/model_generator.rb +41 -0
- data/lib/generators/templates/hibachi.rb +11 -0
- data/lib/generators/templates/model.rb.erb +4 -0
- data/lib/hibachi/chef_runner.rb +54 -0
- data/lib/hibachi/configuration.rb +18 -0
- data/lib/hibachi/install_active_job_error.rb +13 -0
- data/lib/hibachi/job.rb +7 -0
- data/lib/hibachi/model.rb +42 -0
- data/lib/hibachi/node.rb +112 -0
- data/lib/hibachi/persistence.rb +76 -0
- data/lib/hibachi/provisioning.rb +28 -0
- data/lib/hibachi/querying.rb +48 -0
- data/lib/hibachi/railtie.rb +24 -0
- data/lib/hibachi/recipe.rb +48 -0
- data/lib/hibachi/version.rb +3 -0
- data/lib/hibachi.rb +9 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +24 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +13 -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 +83 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/hibachi.rb +6 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fixtures/chef.json +7 -0
- data/spec/hibachi/chef_runner_spec.rb +25 -0
- data/spec/hibachi/configuration_spec.rb +29 -0
- data/spec/hibachi/model_spec.rb +24 -0
- data/spec/hibachi/node_spec.rb +52 -0
- data/spec/hibachi/recipe_spec.rb +32 -0
- data/spec/hibachi/store_spec.rb +37 -0
- data/spec/hibachi_spec.rb +13 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/mock_setting.rb +18 -0
- data/spec/support/mock_singleton.rb +5 -0
- metadata +299 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
# See how all your routes lay out with "rake routes".
|
4
|
+
|
5
|
+
# You can have the root of your site routed with "root"
|
6
|
+
# root 'welcome#index'
|
7
|
+
|
8
|
+
# Example of regular route:
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
10
|
+
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
+
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Example resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Example resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Example resource route with more complex sub-resources:
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', on: :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with concerns:
|
44
|
+
# concern :toggleable do
|
45
|
+
# post 'toggle'
|
46
|
+
# end
|
47
|
+
# resources :posts, concerns: :toggleable
|
48
|
+
# resources :photos, concerns: :toggleable
|
49
|
+
|
50
|
+
# Example resource route within a namespace:
|
51
|
+
# namespace :admin do
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
54
|
+
# resources :products
|
55
|
+
# end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: c64a2d4723ee10a40a770a4da62884e7fe956c7682d3e8ea26b6911b8080efa88086533f8324475e3be6b4f3873d86a4065e740e1e67dd31a8228b84c2b64e8e
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: ebb54cbcf5f1832f020e6c38b67491f697fd9fb6c43f36a3075557e77b0404416b25315d225811c88a7f6eafba280e59c8f05577e54eaac06b5fdfab05708ed3
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/chef_runner'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe ChefRunner do
|
6
|
+
subject do
|
7
|
+
double 'Hibachi', \
|
8
|
+
config: Hibachi.config,
|
9
|
+
recipe_name: 'recipe[pro::default]'
|
10
|
+
end
|
11
|
+
before do
|
12
|
+
subject.class_eval { include Hibachi::ChefRunner }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "runs chef" do
|
16
|
+
subject.stub(:run) { true }
|
17
|
+
expect(subject.run_chef(:pro)).to eq(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "runs chef in the background" do
|
21
|
+
subject.stub(:run_chef_in_bg) { true }
|
22
|
+
expect(subject.run_chef(:pro, background: true)).to eq(true)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/configuration'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe Configuration do
|
6
|
+
subject { double 'Hibachi' }
|
7
|
+
|
8
|
+
before do
|
9
|
+
subject.class_eval { include Configuration }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets configuration" do
|
13
|
+
subject.configure { |c| c.run_in_background = true }
|
14
|
+
expect(subject.config.run_in_background).to eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns configuration" do
|
18
|
+
expect(subject.config.chef_json_path).to match(/chef\.json\Z/)
|
19
|
+
expect(subject.config.chef_dir).to_not be_nil
|
20
|
+
expect(subject.config.log_path).to match(/hibachi\.log\Z/)
|
21
|
+
expect(subject.config.run_in_background).to eq(false)
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
subject.configure { |c| c.run_in_background = false }
|
26
|
+
expect(subject.config.run_in_background).to eq(false)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/model'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe Model do
|
6
|
+
subject do
|
7
|
+
MockSetting.new name: 'example', is_active: false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "sets attributes" do
|
11
|
+
expect(subject.attributes).to_not be_empty
|
12
|
+
expect(subject.attributes[:name]).to eq(subject.name)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds full node json" do
|
16
|
+
expect(MockSetting.node).to be_a Node
|
17
|
+
end
|
18
|
+
|
19
|
+
it "converts to json" do
|
20
|
+
expect(subject.to_json).to_not be_empty
|
21
|
+
expect(subject.to_json).to eq(subject.attributes.to_json)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/node'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe Node do
|
6
|
+
subject do
|
7
|
+
fixture_path = File.expand_path "../../fixtures", __FILE__
|
8
|
+
Node.find "#{fixture_path}/chef.json"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "finds the file at path" do
|
12
|
+
expect(subject).to be_present
|
13
|
+
end
|
14
|
+
|
15
|
+
it "finds attributes in the file" do
|
16
|
+
expect(subject.send(:parsed_json_attributes)).to be_present
|
17
|
+
expect(subject.send(:parsed_json_attributes)).to_not be_empty
|
18
|
+
expect(subject.send(:parsed_json_attributes).keys).to include(Hibachi.config.cookbook.to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "scopes attributes by cookbook" do
|
22
|
+
expect(subject.attributes).to be_present
|
23
|
+
expect(subject.attributes).to_not be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it "enumerates over json attributes" do
|
27
|
+
expect(subject).to respond_to :each
|
28
|
+
end
|
29
|
+
|
30
|
+
it "finds a given recipe's json" do
|
31
|
+
expect(subject[:mock_settings]).to_not be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it "exposes attributes as a hash" do
|
35
|
+
expect(subject.attributes[:mock_settings]).to eq(subject[:mock_settings])
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when writing to json" do
|
39
|
+
before { subject[:from_node_spec] = { test: true } }
|
40
|
+
|
41
|
+
it "sets recipe json" do
|
42
|
+
expect(subject[:from_node_spec]).to_not be_nil
|
43
|
+
expect(subject[:from_node_spec][:test]).to eq(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "deletes recipe json" do
|
47
|
+
expect(subject.delete(:from_node_spec)).to eq(true)
|
48
|
+
expect(subject[:from_node_spec]).to be_nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/recipe'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe Recipe do
|
6
|
+
class MockForRecipe < Hibachi::Model
|
7
|
+
recipe :name_of_recipe, :type => :singleton
|
8
|
+
|
9
|
+
attr_accessor :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "sets the recipe in the class definition" do
|
13
|
+
expect(MockForRecipe.recipe_name).to eq(:name_of_recipe)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets the type of recipe in the class definition" do
|
17
|
+
expect(MockForRecipe.recipe_type).to eq('singleton')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "is a singleton" do
|
21
|
+
expect(MockForRecipe).to be_singleton
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with an instantiated singleton" do
|
25
|
+
subject { MockForRecipe.new name: 'test' }
|
26
|
+
|
27
|
+
it "is a singleton" do
|
28
|
+
expect(subject).to be_singleton
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi/store'
|
3
|
+
|
4
|
+
module Hibachi
|
5
|
+
describe Store do
|
6
|
+
it "creates a new model from scratch" do
|
7
|
+
setting = MockSetting.create(name: 'from-scratch')
|
8
|
+
expect(setting).to be_persisted
|
9
|
+
expect(setting.destroy).to eq(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "finds all of this type in the json" do
|
13
|
+
setting = MockSetting.find 'test'
|
14
|
+
expect(setting).to be_present
|
15
|
+
end
|
16
|
+
|
17
|
+
it "searches for a given model in the json" do
|
18
|
+
settings = MockSetting.where(name: 'test')
|
19
|
+
expect(settings).to_not be_empty
|
20
|
+
expect(settings.first.name).to eq('test')
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with an instance" do
|
24
|
+
subject { MockSetting.new name: 'store' }
|
25
|
+
|
26
|
+
it "validates given attributes" do
|
27
|
+
expect(subject).to be_valid, subject.errors.full_messages.join(', ')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "creates a new setting in the database" do
|
31
|
+
expect(subject.save).to eq(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
after { subject.destroy }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hibachi'
|
3
|
+
|
4
|
+
describe Hibachi do
|
5
|
+
it "includes config methods" do
|
6
|
+
expect(Hibachi).to respond_to(:configure)
|
7
|
+
expect(Hibachi).to respond_to(:config)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "includes chef run methods" do
|
11
|
+
expect(Hibachi).to respond_to(:run_chef)
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
require 'pry'
|
7
|
+
#require 'rails/test_help'
|
8
|
+
|
9
|
+
Rails.backtrace_cleaner.remove_silencers!
|
10
|
+
|
11
|
+
# Load support files
|
12
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
13
|
+
|
14
|
+
# Load fixtures from the engine
|
15
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
16
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
17
|
+
end
|
18
|
+
|
19
|
+
Hibachi.config.cookbook = :test
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'hibachi'
|
2
|
+
|
3
|
+
class MockSetting < Hibachi::Model
|
4
|
+
|
5
|
+
recipe :mock_settings
|
6
|
+
|
7
|
+
attr_accessor :attributes, :name, :is_active
|
8
|
+
|
9
|
+
validates :name, :presence => true
|
10
|
+
|
11
|
+
def active?
|
12
|
+
!!is_active
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
name
|
17
|
+
end
|
18
|
+
end
|