rconf 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +56 -0
- data/Rakefile +63 -0
- data/bin/rconf +102 -0
- data/examples/sample.rc +9 -0
- data/lib/rconf.rb +24 -0
- data/lib/rconf/command.rb +112 -0
- data/lib/rconf/configurator.rb +179 -0
- data/lib/rconf/configurator_registry.rb +63 -0
- data/lib/rconf/configurators/bundler_configurator.rb +85 -0
- data/lib/rconf/configurators/ruby_configurator.rb +151 -0
- data/lib/rconf/language.rb +91 -0
- data/lib/rconf/platform.rb +114 -0
- data/lib/rconf/platforms/darwin.rb +27 -0
- data/lib/rconf/platforms/linux.rb +40 -0
- data/lib/rconf/platforms/windows.rb +40 -0
- data/lib/rconf/progress_reporter.rb +72 -0
- data/lib/rconf/progress_reporters/base_reporter.rb +156 -0
- data/lib/rconf/progress_reporters/file_reporter.rb +58 -0
- data/lib/rconf/progress_reporters/stdout_reporter.rb +83 -0
- data/lib/rconf/ruby_extensions.rb +56 -0
- data/lib/rconf/trollop.rb +782 -0
- data/lib/rconf/version.rb +30 -0
- data/rconf.gemspec +24 -0
- data/spec/command_spec.rb +38 -0
- data/spec/configurator_spec.rb +64 -0
- data/spec/configurators/bundler_configurator_spec.rb +51 -0
- data/spec/configurators/ruby_configurator_spec.rb +60 -0
- data/spec/language_spec.rb +60 -0
- data/spec/platform_spec.rb +37 -0
- data/spec/progress_reporters/base_reporter_spec.rb +84 -0
- data/spec/progress_reporters/file_reporter_spec.rb +31 -0
- data/spec/progress_reporters/stdout_reporter_spec.rb +23 -0
- data/spec/ruby_extensions_spec.rb +35 -0
- data/spec/spec_helper.rb +21 -0
- metadata +129 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
module RightConf
|
13
|
+
|
14
|
+
MAJOR = 0
|
15
|
+
MINOR = 5
|
16
|
+
BUILD = 0
|
17
|
+
|
18
|
+
VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
|
19
|
+
|
20
|
+
DESCRIPTION = <<-EOS
|
21
|
+
rconf configures the environment for a given application. rconf reads
|
22
|
+
the content of an application configuration file (.rc) and installs and/or
|
23
|
+
configures the required tools for running or developing the corresponding
|
24
|
+
application. rconf can easily be extended to configure new tools and makes
|
25
|
+
it easy to support multiple platforms.
|
26
|
+
Consult the README.rdoc file for information on how to write rconf
|
27
|
+
configuration files (.rc).
|
28
|
+
EOS
|
29
|
+
|
30
|
+
end
|
data/rconf.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'rconf/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'rconf'
|
6
|
+
s.version = RightConf::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Raphael Simon']
|
9
|
+
s.email = ['raphael@rightscale.com']
|
10
|
+
s.homepage = 'http://rubygems.org/gems/rconf'
|
11
|
+
s.summary = %q{Cross platform environment configuration}
|
12
|
+
s.description = RightConf::DESCRIPTION
|
13
|
+
|
14
|
+
s.rubyforge_project = 'rconf'
|
15
|
+
|
16
|
+
s.add_development_dependency('rspec', "~> 2.5")
|
17
|
+
s.add_development_dependency('flexmock', "~> 0.9")
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ['lib']
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
13
|
+
|
14
|
+
describe RightConf::Command do
|
15
|
+
|
16
|
+
def success_result
|
17
|
+
RightConf::CommandResult.new(0, '')
|
18
|
+
end
|
19
|
+
|
20
|
+
def failed_result
|
21
|
+
RightConf::CommandResult.new(1, '')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should execute' do
|
25
|
+
flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', '42', Proc).once.and_return(success_result)
|
26
|
+
RightConf::Command.execute('test', '42')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should report fatal errors when required to' do
|
30
|
+
flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', '42',
|
31
|
+
Proc).once.and_return(failed_result)
|
32
|
+
flexmock(RightConf::Command.instance).should_receive(:report_fatal).once.with("FAILED: 'test 42' returned\n1")
|
33
|
+
RightConf::Command.execute('test', '42', :abort_on_failure => 'FAILED')
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
13
|
+
|
14
|
+
describe RightConf::Configurator do
|
15
|
+
|
16
|
+
class TestConfigurator
|
17
|
+
include RightConf::Configurator
|
18
|
+
register :test
|
19
|
+
validate_has_settings :required
|
20
|
+
attr_reader :custom_setting
|
21
|
+
def test_setter(value)
|
22
|
+
@custom_setting = value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class AnotherConfigurator
|
27
|
+
include RightConf::Configurator
|
28
|
+
register :another
|
29
|
+
end
|
30
|
+
|
31
|
+
before(:each) do
|
32
|
+
@configurator = TestConfigurator.new
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should register configurators' do
|
36
|
+
RightConf::ConfiguratorRegistry[:test].should == TestConfigurator
|
37
|
+
RightConf::ConfiguratorRegistry[:another].should == AnotherConfigurator
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have associated key' do
|
41
|
+
TestConfigurator.key.should == :test
|
42
|
+
AnotherConfigurator.key.should == :another
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should initialize configuration using meta-programming' do
|
46
|
+
@configurator.instance_eval { test_setting 42 }
|
47
|
+
@configurator[:test_setting].should == 42
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should use configurator setter if it exists' do
|
51
|
+
@configurator.instance_eval { test_setter 43 }
|
52
|
+
@configurator.custom_setting.should == 43
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should validate' do
|
56
|
+
@configurator.validate.should =~ /^Required setting.*missing for configuration/
|
57
|
+
@configurator.instance_eval { required 42 }
|
58
|
+
@configurator.validate.should be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
13
|
+
|
14
|
+
describe RightConf::BundlerConfigurator do
|
15
|
+
|
16
|
+
def success_result(output=nil)
|
17
|
+
flexmock('res', :success? => true, :output => output)
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
lang = RightConf::Language.parse('bundler { bundler_version "0" }')
|
22
|
+
@configurator = lang.configurators.first
|
23
|
+
[:report_check, :report_result, :report_fatal, :report_success].each do |meth|
|
24
|
+
flexmock(@configurator).should_receive(meth)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should succeed when bundler succeeds' do
|
29
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
30
|
+
'bundle', '--version').and_return(success_result('0'))
|
31
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
32
|
+
'bundle', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result)
|
33
|
+
@configurator.run_linux
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should install bunlder if needed' do
|
37
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
38
|
+
'bundle', '--version').and_return(success_result('1'))
|
39
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
40
|
+
'bundle', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result)
|
41
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
42
|
+
'gem', 'uninstall', 'bundler', '-a', '-x', {:abort_on_failure=>"Failed to uninstall bundler"}).and_return(success_result)
|
43
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
44
|
+
'gem', 'install',
|
45
|
+
File.join(RightConf::BundlerConfigurator::DEFAULT_GEM_PATH, 'bundler-0.gem'),
|
46
|
+
'--no-ri', '--no-rdoc', {:abort_on_failure=>"Failed to install bundler"}).once.and_return(success_result)
|
47
|
+
@configurator.run_linux
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
13
|
+
|
14
|
+
describe RightConf::RubyConfigurator do
|
15
|
+
|
16
|
+
def success_result(output=nil)
|
17
|
+
flexmock('res', :success? => true, :output => output)
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
lang = RightConf::Language.parse('ruby { ruby_version "0"; rubygems_version "1" }')
|
22
|
+
@configurator = lang.configurators.first
|
23
|
+
[:report_check, :report_result, :report_fatal, :report_success, :report].each do |meth|
|
24
|
+
flexmock(@configurator).should_receive(meth)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should succeed on linux when rvm succeeds' do
|
29
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
30
|
+
'rvm', '--version').and_return(success_result("rvm #{RightConf::RubyConfigurator::RVM_VERSION}"))
|
31
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
32
|
+
'rvm', 'list').and_return(success_result("=> rvm #{RightConf::RubyConfigurator::RVM_VERSION}"))
|
33
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
34
|
+
'rvm', 'use', '0').and_return(success_result('Using'))
|
35
|
+
@configurator.run_linux
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should install rvm if needed' do
|
39
|
+
rvm_tar = "rvm-#{RightConf::RubyConfigurator::RVM_VERSION}.tar.gz"
|
40
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
41
|
+
'rvm', '--version').and_return(success_result("rvm"))
|
42
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
43
|
+
'rvm', 'list').and_return(success_result("=> rvm #{RightConf::RubyConfigurator::RVM_VERSION}"))
|
44
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
45
|
+
'curl', '-O', '-f',
|
46
|
+
"http://rvm.beginrescueend.com/releases/#{rvm_tar}",
|
47
|
+
{:abort_on_failure=>"Failed to download rvm #{RightConf::RubyConfigurator::RVM_VERSION}"}).and_return(success_result)
|
48
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
49
|
+
'tar', 'zxf', rvm_tar).and_return(success_result)
|
50
|
+
flexmock(Dir).should_receive(:chdir).and_yield
|
51
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
52
|
+
'./install', {:abort_on_failure=>"Failed to install rvm #{RightConf::RubyConfigurator::RVM_VERSION}"}).and_return(success_result)
|
53
|
+
flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
|
54
|
+
'rvm', 'use', '0').and_return(success_result('Using'))
|
55
|
+
@configurator.run_linux
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
13
|
+
|
14
|
+
describe RightConf::Language do
|
15
|
+
|
16
|
+
it 'should invalidate missing blocks' do
|
17
|
+
lang = RightConf::Language.parse('toto')
|
18
|
+
lang.validation_errors.size.should == 1
|
19
|
+
lang.validation_errors.first.should == "Invalid syntax, expecting block after 'toto'"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should invalidate non-existent configurator' do
|
23
|
+
lang = RightConf::Language.parse('toto { 42 }')
|
24
|
+
lang.validation_errors.size.should == 1
|
25
|
+
lang.validation_errors.first.should == "Unknown configurator 'toto'"
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should parse correctly' do
|
29
|
+
lang = RightConf::Language.parse('ruby { ruby_version "1"; rubygems_version "2" }')
|
30
|
+
lang.validation_errors.size.should == 0
|
31
|
+
lang.configurators.size.should == 1
|
32
|
+
lang.configurators.first.class.should == RightConf::RubyConfigurator
|
33
|
+
lang.configurators.first.instance_variable_get(:@settings_values).should ==
|
34
|
+
{ :ruby_version => '1', :rubygems_version => '2' }
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should parse multiple configurations' do
|
38
|
+
lang = RightConf::Language.parse(<<-EOS
|
39
|
+
ruby do
|
40
|
+
ruby_version "1"
|
41
|
+
rubygems_version "2"
|
42
|
+
end
|
43
|
+
bundler do
|
44
|
+
bundler_version "3"
|
45
|
+
end
|
46
|
+
EOS
|
47
|
+
)
|
48
|
+
lang.validation_errors.size.should == 0
|
49
|
+
lang.configurators.size.should == 2
|
50
|
+
lang.configurators[0].class.should == RightConf::RubyConfigurator
|
51
|
+
lang.configurators[0].instance_variable_get(:@settings_values).should ==
|
52
|
+
{ :ruby_version => '1', :rubygems_version => '2' }
|
53
|
+
lang.configurators[1].class.should == RightConf::BundlerConfigurator
|
54
|
+
lang.configurators[1].instance_variable_get(:@settings_values).should ==
|
55
|
+
{ :bundler_version => '3' }
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
13
|
+
|
14
|
+
describe RightConf::Platform do
|
15
|
+
|
16
|
+
it 'should try to dispatch using platform family' do
|
17
|
+
def test_amiga(val); val; end
|
18
|
+
flexmock(RightConf::Platform.instance).should_receive(:family).and_return('amiga')
|
19
|
+
RightConf::Platform.dispatch(44) { :test }.should == 44
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should try to dispatch using platform family and flavor' do
|
23
|
+
def test_atari_st(val); val; end
|
24
|
+
flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('st')
|
25
|
+
flexmock(RightConf::Platform.instance).should_receive(:family).and_return('atari')
|
26
|
+
RightConf::Platform.dispatch(43) { :test }.should == 43
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should try to dispatch using platform family, flavor and release' do
|
30
|
+
def test_commodore_c_64(val); val; end
|
31
|
+
flexmock(RightConf::Platform.instance).should_receive(:release).and_return('64')
|
32
|
+
flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('c')
|
33
|
+
flexmock(RightConf::Platform.instance).should_receive(:family).and_return('commodore')
|
34
|
+
RightConf::Platform.dispatch(42) { :test }.should == 42
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
|
2
|
+
#
|
3
|
+
# THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
|
4
|
+
# AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
|
5
|
+
# reproduction, modification, or disclosure of this program is
|
6
|
+
# strictly prohibited. Any use of this program by an authorized
|
7
|
+
# licensee is strictly subject to the terms and conditions,
|
8
|
+
# including confidentiality obligations, set forth in the applicable
|
9
|
+
# License Agreement between RightScale.com, Inc. and
|
10
|
+
# the licensee
|
11
|
+
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
13
|
+
|
14
|
+
describe RightConf::BaseReporter do
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
@written = nil
|
18
|
+
@reporter = RightConf::BaseReporter.new
|
19
|
+
flexmock(@reporter).should_receive(:write).and_return { |t| @written = t }
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should report standard messages' do
|
23
|
+
@reporter.report('42')
|
24
|
+
@written.should == @reporter.send(:format_message, '42')
|
25
|
+
@reporter.report_message('43')
|
26
|
+
@written.should == @reporter.send(:format_message, '43')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should report new sections' do
|
30
|
+
@reporter.report_section('42')
|
31
|
+
@written.should == @reporter.send(:format_section, '42')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should report errors' do
|
35
|
+
@reporter.report_error('42')
|
36
|
+
@written.should == @reporter.send(:format_error, '42')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should report checks' do
|
40
|
+
@reporter.report_check('42')
|
41
|
+
@written.should == @reporter.send(:format_check, '42')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should report success' do
|
45
|
+
@reporter.report_success
|
46
|
+
@written.should == @reporter.send(:format_success)
|
47
|
+
@written = nil
|
48
|
+
@reporter.report_result(true)
|
49
|
+
@written.should == @reporter.send(:format_success)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should report failures' do
|
53
|
+
@reporter.report_failure
|
54
|
+
@written.should == @reporter.send(:format_failure)
|
55
|
+
@written = nil
|
56
|
+
@reporter.report_result(false)
|
57
|
+
@written.should == @reporter.send(:format_failure)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should report fatal' do
|
61
|
+
exception = nil
|
62
|
+
begin
|
63
|
+
@reporter.report_fatal('42')
|
64
|
+
rescue Exception => e
|
65
|
+
exception = e
|
66
|
+
end
|
67
|
+
@written.should == @reporter.send(:format_fatal, '42')
|
68
|
+
exception.should_not be_nil
|
69
|
+
exception.class.should == SystemExit
|
70
|
+
exception.message.should == 'exit'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should raise NoMethodError when using a wrong report method' do
|
74
|
+
exception = nil
|
75
|
+
begin
|
76
|
+
@reporter.report_something_that_does_no_exist
|
77
|
+
rescue Exception => e
|
78
|
+
exception = e
|
79
|
+
end
|
80
|
+
exception.should_not be_nil
|
81
|
+
exception.class.should == NoMethodError
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|