init 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.
data/spec/init_spec.rb ADDED
@@ -0,0 +1,129 @@
1
+ # Copyright 2009 Alexander E. Fischer <aef@raxys.net>
2
+ #
3
+ # This file is part of Init.
4
+ #
5
+ # Init is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require 'lib/init'
19
+
20
+ require 'fileutils'
21
+ require 'tmpdir'
22
+
23
+ require 'rubygems'
24
+ require 'facets/timer'
25
+
26
+ module InitSpecHelper
27
+ RUBY_PATH = 'ruby'
28
+
29
+ def init_executable
30
+ "#{RUBY_PATH} spec/bin/simple_init.rb"
31
+ end
32
+ end
33
+
34
+ describe Aef::Init do
35
+ before(:each) do
36
+ # Before ruby 1.8.7, the tmpdir standard library had no method to create
37
+ # a temporary directory (mktmpdir).
38
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.8.7')
39
+ @folder_path = File.join(Dir.tmpdir, 'init_spec')
40
+ Dir.mkdir(@folder_path)
41
+ else
42
+ @folder_path = Dir.mktmpdir('init_spec')
43
+ end
44
+ end
45
+
46
+ after(:each) do
47
+ FileUtils.rm_rf(@folder_path)
48
+ end
49
+
50
+ include InitSpecHelper
51
+
52
+ it "should correctly execute the start command" do
53
+ start_output = File.join(@folder_path, 'start_output')
54
+
55
+ lambda {
56
+ `#{init_executable} start #{start_output}`.should be_true
57
+ }.should change{File.exist?(start_output)}.from(false).to(true)
58
+
59
+ File.read(start_output).should eql("#{start_output} --start --example -y\n")
60
+
61
+ end
62
+
63
+ it "should correctly execute the stop command" do
64
+ stop_output = File.join(@folder_path, 'stop_output')
65
+
66
+ lambda {
67
+ `#{init_executable} stop #{stop_output}`.should be_true
68
+ }.should change{File.exist?(stop_output)}.from(false).to(true)
69
+
70
+ File.read(stop_output).should eql("#{stop_output} --stop --example -y\n")
71
+ end
72
+
73
+ it "should correctly execute the restart command" do
74
+ restart_output = File.join(@folder_path, 'restart_output')
75
+
76
+ lambda {
77
+ `#{init_executable} restart #{restart_output}`.should be_true
78
+ }.should change{File.exist?(restart_output)}.from(false).to(true)
79
+
80
+ File.read(restart_output).should eql(
81
+ "#{restart_output} --stop --example -y\n#{restart_output} --start --example -y\n")
82
+ end
83
+
84
+ it "should correctly execute the middle command" do
85
+ middle_output = File.join(@folder_path, 'middle_output')
86
+
87
+ lambda {
88
+ `#{init_executable} middle #{middle_output}`.should be_true
89
+ }.should change{File.exist?(middle_output)}.from(false).to(true)
90
+
91
+ File.read(middle_output).should eql(
92
+ "#{middle_output} --middle -e --abc\n")
93
+ end
94
+
95
+ it "should wait 3 seconds between stop and start through the restart command" do
96
+ restart_output = File.join(@folder_path, 'restart_output')
97
+
98
+ timer = Timer.new
99
+ timer.start
100
+
101
+ `#{init_executable} restart #{restart_output}`.should be_true
102
+
103
+ timer.stop
104
+ (timer.total_time.should > 1.5).should be_true
105
+ end
106
+
107
+ it "should display a usage example if a wrong command is specified" do
108
+ usage_information = "Usage: spec/bin/simple_init.rb {middle|restart|start|stop}\n"
109
+
110
+ `#{init_executable} invalid`.should eql(usage_information)
111
+ end
112
+
113
+ it "should only offer methods which are defined in Init or it's child classes" do
114
+ usage_information = "Usage: spec/bin/simple_init.rb {middle|restart|start|stop}\n"
115
+
116
+ `#{init_executable} methods`.should eql(usage_information)
117
+ `#{init_executable} frozen?`.should eql(usage_information)
118
+ `#{init_executable} to_a`.should eql(usage_information)
119
+ end
120
+
121
+ it "should only offer methods which are defined as public in Init or it's child classes" do
122
+ usage_information = "Usage: spec/bin/simple_init.rb {middle|restart|start|stop}\n"
123
+
124
+ `#{init_executable} middle_protected`.should eql(usage_information)
125
+ `#{init_executable} middle_private`.should eql(usage_information)
126
+ `#{init_executable} end_protected`.should eql(usage_information)
127
+ `#{init_executable} end_private`.should eql(usage_information)
128
+ end
129
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: init
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander E. Fischer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDKDCCAhCgAwIBAgIBADANBgkqhkiG9w0BAQUFADA6MQwwCgYDVQQDDANhZWYx
14
+ FTATBgoJkiaJk/IsZAEZFgVyYXh5czETMBEGCgmSJomT8ixkARkWA25ldDAeFw0w
15
+ OTAyMjUyMDM5MDhaFw0xMDAyMjUyMDM5MDhaMDoxDDAKBgNVBAMMA2FlZjEVMBMG
16
+ CgmSJomT8ixkARkWBXJheHlzMRMwEQYKCZImiZPyLGQBGRYDbmV0MIIBIjANBgkq
17
+ hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoYtj0qad5/MpbdttITzBH0h1SNe6eO7R
18
+ 7qVeqNYu6qDQAQ0rYc0JhubJCWYrZEJorHEBhUFU6cdQgQOs78wiJaDgkeU7YfXB
19
+ q2l125kJ8aHkA1ukrK2/DRzp2AHEmzxHIYpXV5/63h+NWjCP+uKvTELYsotS2MKt
20
+ 3d43E0QajsPZu2ZuNFwkroqeue872gMHUldGOVy5WtSd9ajw2xI/CociY6746dL+
21
+ pYriV3QaYtR/ezeaLpKBLsc5T1UQ07t7Xs7mI281tdmRvpLdP5dQhjzInfio0CJv
22
+ 1Pf5bZUjGG0K9RW2Gb/tGPSYEETiLMubjH61OwBooXKiWR5cs4/1BQIDAQABozkw
23
+ NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUSYvjhG2EWnR5kx5l
24
+ DAewXCkJOVEwDQYJKoZIhvcNAQEFBQADggEBAB2ryDbU4bQtnunKv/AXq4CuO3LS
25
+ kik9Xhye8E/5dTcsgitCZJXAqx0rHcK0u2EHnjA5CDcdF5JB7XgSvRrQkFWoW/9K
26
+ lCB4ih+sB2AI2IUiYBeoCGctXdBQ020prqop/oTQEudzFk/gyQ686lp06HdLRt+O
27
+ HoQjTIab8vmfgIubjPdIRzokMfHbelvhLi+mQfWVghRhs2jpEfdXbL0w5nNw+trp
28
+ rO70Dw59hduDUOpgpxew+PLbs4vP1tb1QKPG+39C+PZtosbbf1fai0hqYV1txMCx
29
+ 55akF+N8NbO6tpVDy6TMagqa10LfEpiQH6dvDHe/xdAqYOCrXKpmqzwu2PI=
30
+ -----END CERTIFICATE-----
31
+
32
+ date: 2009-04-05 00:00:00 +02:00
33
+ default_executable:
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: facets
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.11.0
64
+ version:
65
+ description: Clean and simple *nix init scripts with Ruby
66
+ email:
67
+ - aef@raxys.net
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files:
73
+ - History.txt
74
+ - Manifest.txt
75
+ - COPYING.txt
76
+ - README.rdoc
77
+ files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.rdoc
81
+ - COPYING.txt
82
+ - Rakefile
83
+ - lib/init.rb
84
+ - lib/init/init.rb
85
+ - examples/murmur.rb
86
+ - spec/init_spec.rb
87
+ - spec/bin/mock_daemon.rb
88
+ - spec/bin/simple_init.rb
89
+ has_rdoc: true
90
+ homepage: https://rubyforge.org/projects/aef/
91
+ post_install_message:
92
+ rdoc_options:
93
+ - --main
94
+ - README.rdoc
95
+ - --inline-source
96
+ - --line-numbers
97
+ - --title
98
+ - Init
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ version:
113
+ requirements: []
114
+
115
+ rubyforge_project: aef
116
+ rubygems_version: 1.3.1
117
+ signing_key:
118
+ specification_version: 2
119
+ summary: Clean and simple *nix init scripts with Ruby
120
+ test_files: []
121
+
metadata.gz.sig ADDED
Binary file