warningshot 0.9.4 → 0.9.5

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.
Files changed (51) hide show
  1. data/CHANGELOG +8 -0
  2. data/CONTRIBUTORS +2 -1
  3. data/README +86 -6
  4. data/Rakefile +4 -3
  5. data/TODO +1 -147
  6. data/bin/warningshot +11 -7
  7. data/lib/resolvers/core_lib_resolver.rb +2 -3
  8. data/lib/resolvers/directory_resolver.rb +1 -1
  9. data/lib/resolvers/file_resolver.rb +35 -17
  10. data/lib/resolvers/gem_resolver.rb +81 -60
  11. data/lib/resolvers/integrity_resolver.rb +10 -11
  12. data/lib/resolvers/manual_resolver.rb +15 -3
  13. data/lib/resolvers/permission_resolver.rb +6 -8
  14. data/lib/resolvers/symlink_resolver.rb +13 -8
  15. data/lib/resolvers/url_resolver.rb +28 -41
  16. data/lib/warningshot.rb +10 -7
  17. data/lib/warningshot/config.rb +254 -0
  18. data/lib/{warning_shot → warningshot}/dependency_resolver.rb +38 -17
  19. data/lib/{warning_shot → warningshot}/growl.rb +2 -0
  20. data/lib/{warning_shot → warningshot}/logger.rb +2 -0
  21. data/lib/{warning_shot → warningshot}/resolver.rb +177 -89
  22. data/lib/warningshot/suite.rb +4 -0
  23. data/lib/{warning_shot → warningshot}/template_generator.rb +4 -1
  24. data/lib/{warning_shot → warningshot}/version.rb +3 -1
  25. data/lib/warningshot/warning_shot.rb +187 -0
  26. data/tasks/gemspec.rb +3 -16
  27. data/tasks/yard.rb +1 -1
  28. data/templates/gems.yml +1 -0
  29. data/test/data/faux_test.yml +5 -0
  30. data/test/data/faux_test_resolver.rb +21 -0
  31. data/test/data/mock_resolver.rb +11 -5
  32. data/test/log/warningshot.log +3051 -532
  33. data/test/spec/unit/resolvers/core_lib_resolver_spec.rb +1 -1
  34. data/test/spec/unit/resolvers/directory_resolver_spec.rb +1 -1
  35. data/test/spec/unit/resolvers/file_resolver_spec.rb +9 -13
  36. data/test/spec/unit/resolvers/gem_resolver_spec.rb +108 -32
  37. data/test/spec/unit/resolvers/integrity_resolver_spec.rb +6 -6
  38. data/test/spec/unit/resolvers/permission_resolver_spec.rb +2 -2
  39. data/test/spec/unit/resolvers/symlink_resolver_spec.rb +8 -1
  40. data/test/spec/unit/resolvers/url_resolver_spec.rb +10 -10
  41. data/test/spec/unit/warningshot/config_spec.rb +57 -0
  42. data/test/spec/unit/{warning_shot → warningshot}/dependency_resolver_spec.rb +18 -9
  43. data/test/spec/unit/{warning_shot → warningshot}/resolver_spec.rb +54 -79
  44. data/test/spec/unit/{warning_shot → warningshot}/template_generator_spec.rb +1 -1
  45. data/test/spec/unit/{warning_shot → warningshot}/version_spec.rb +0 -0
  46. data/test/spec/unit/{warning_shot → warningshot}/warning_shot_spec.rb +0 -0
  47. metadata +24 -26
  48. data/lib/warning_shot/config.rb +0 -132
  49. data/lib/warning_shot/warning_shot.rb +0 -130
  50. data/test/spec/spec.opts.zoiks +0 -0
  51. data/test/spec/unit/warning_shot/config_spec.rb +0 -35
@@ -15,7 +15,7 @@ describe WarningShot::CoreLibResolver do
15
15
  end
16
16
 
17
17
  it 'should increment #errors for unloadable core libs' do
18
- cld = WarningShot::CoreLibResolver.new 'bogus_core_lib_name'
18
+ cld = WarningShot::CoreLibResolver.new WarningShot::Config.create,'bogus_core_lib_name'
19
19
  cld.test!
20
20
 
21
21
  cld.failed.length.should be(1)
@@ -25,7 +25,7 @@ describe WarningShot::DirectoryResolver do
25
25
  control_dir = File.expand_path('.')
26
26
  test_dir1 = @@base_path / 'test1'
27
27
  test_dir2 = @@base_path / 'test2'
28
- resolver = WarningShot::DirectoryResolver.new control_dir,test_dir1, test_dir2
28
+ resolver = WarningShot::DirectoryResolver.new WarningShot::Config.create, control_dir,test_dir1, test_dir2
29
29
  resolver.test!
30
30
  resolver.passed.length.should be(1)
31
31
  resolver.failed.length.should be(2)
@@ -25,10 +25,6 @@ describe WarningShot::FileResolver do
25
25
  it 'should have resolutions regsitered' do
26
26
  WarningShot::FileResolver.resolutions.empty?.should be(false)
27
27
  end
28
-
29
- it 'should treate relative paths as from directory specified by WarningShot::Config[:application]' do
30
- pending
31
- end
32
28
 
33
29
  describe 'with healing enabled' do
34
30
  describe 'with heal instructions' do
@@ -37,7 +33,7 @@ describe WarningShot::FileResolver do
37
33
  that_file = @@source_path / 'that.txt'
38
34
  this_file = @@dest_path / 'this.txt'
39
35
 
40
- fd = WarningShot::FileResolver.new({:source => "file://#{that_file}",:target => this_file})
36
+ fd = WarningShot::FileResolver.new(WarningShot::Config.create,{:source => "file://#{that_file}",:target => this_file})
41
37
  fd.test!
42
38
 
43
39
  fd.failed.length.should be(1)
@@ -47,7 +43,7 @@ describe WarningShot::FileResolver do
47
43
  that_file = @@source_path / 'that.txt'
48
44
  this_file = @@dest_path / 'this.txt'
49
45
 
50
- fd = WarningShot::FileResolver.new({:source => "file://#{that_file}",:target => this_file})
46
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:source => "file://#{that_file}",:target => this_file})
51
47
  fd.test!
52
48
  fd.failed.length.should be(1)
53
49
  fd.resolve!
@@ -55,7 +51,7 @@ describe WarningShot::FileResolver do
55
51
  end
56
52
 
57
53
  it 'should heal a file from http://' do
58
- fd = WarningShot::FileResolver.new({:source => "http://www.example.com/",:target => (@@dest_path / 'internetz.html')})
54
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:source => "http://www.example.com/",:target => (@@dest_path / 'internetz.html')})
59
55
  fd.test!
60
56
  fd.failed.length.should be(1)
61
57
  fd.resolve!
@@ -67,7 +63,7 @@ describe WarningShot::FileResolver do
67
63
  end
68
64
 
69
65
  it 'should not increment #resolved if the resolution fails' do
70
- fd = WarningShot::FileResolver.new({:source => "http://www.example.com/DOESNT.EXIST",:target => (@@dest_path / 'doesnt_exist.html')})
66
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:source => "http://www.example.com/DOESNT.EXIST",:target => (@@dest_path / 'doesnt_exist.html')})
71
67
  fd.test!
72
68
  fd.failed.length.should be(1)
73
69
  fd.resolve!
@@ -80,12 +76,12 @@ describe WarningShot::FileResolver do
80
76
  it 'should be able to return unresolved dependencies' do
81
77
  this_file = @@dest_path / 'this.txt'
82
78
 
83
- fd = WarningShot::FileResolver.new({:target => this_file})
79
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:target => this_file})
84
80
  fd.test!
85
81
  fd.resolve!
86
82
  fd.unresolved.length.should be(1)
87
83
 
88
- fd = WarningShot::FileResolver.new this_file
84
+ fd = WarningShot::FileResolver.new WarningShot::Config.create, this_file
89
85
  fd.test!
90
86
  fd.resolve!
91
87
  fd.unresolved.length.should be(1)
@@ -95,7 +91,7 @@ describe WarningShot::FileResolver do
95
91
  it 'should add dependency to #failed' do
96
92
  this_file = @@dest_path / 'this.txt'
97
93
 
98
- fd = WarningShot::FileResolver.new({:target => this_file})
94
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:target => this_file})
99
95
  fd.test!
100
96
  fd.failed.length.should be(1)
101
97
  fd.resolve!
@@ -112,7 +108,7 @@ describe WarningShot::FileResolver do
112
108
  that_file = @@source_path / 'that.txt'
113
109
  this_file = @@dest_path / 'this.txt'
114
110
 
115
- fd = WarningShot::FileResolver.new({:target => this_file,:source => that_file})
111
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:target => this_file,:source => that_file})
116
112
  fd.test!
117
113
  fd.failed.length.should be(1)
118
114
  end
@@ -124,7 +120,7 @@ describe WarningShot::FileResolver do
124
120
  it 'should add dependency to #failed' do
125
121
  this_file = @@dest_path / 'this.txt'
126
122
 
127
- fd = WarningShot::FileResolver.new({:target => this_file})
123
+ fd = WarningShot::FileResolver.new( WarningShot::Config.create,{:target => this_file})
128
124
  fd.test!
129
125
  fd.failed.length.should be(1)
130
126
  end
@@ -1,5 +1,5 @@
1
- #Note, this fails if the gem yard is already installed, which sucks. Waiting on rubyforge to
2
- # approve ws-dummy gem
1
+ # NOTE: All tests that install/uninstall gems should use 'ws-dummy' gem.
2
+ # All tests for testing existance of gems should use 'warningshot' or 'ws-dummy'
3
3
 
4
4
  require "." / "lib" / "resolvers" / "gem_resolver"
5
5
  require 'fileutils'
@@ -8,10 +8,17 @@ describe WarningShot::GemResolver do
8
8
  WarningShot::GemResolver.logger = $logger
9
9
 
10
10
  FileUtils.rm_rf "./test/output/gems"
11
+ FileUtils.rm_rf "./test/output/gems2"
11
12
  end
12
13
 
13
- after :all do
14
+ before :each do
15
+ FileUtils.mkdir_p "./test/output/gems"
16
+ FileUtils.mkdir_p "./test/output/gems2"
17
+ end
18
+
19
+ after :each do
14
20
  FileUtils.rm_rf "./test/output/gems"
21
+ FileUtils.rm_rf "./test/output/gems2"
15
22
  end
16
23
 
17
24
  it 'should have tests registered' do
@@ -22,53 +29,122 @@ describe WarningShot::GemResolver do
22
29
  WarningShot::GemResolver.resolutions.empty?.should be(false)
23
30
  end
24
31
 
25
- it 'should provide the command line option gem_path' do
26
- WarningShot.parser.to_s.include?("Alternate gem path ':' separated to check. First in path is where gems will be installed").should be(true)
27
- WarningShot::Config.configuration.key?(:gem_path).should be(true)
32
+ it 'should provide the command line option --gempath' do
33
+ WarningShot::Config::PARSER.to_s.include?("Alternate gem path ':' separated to check. First in path is where gems will be installed").should be(true)
34
+ WarningShot::Config.parse_args(['--gempath',"./test/output/gems"]).key?(:gem_path).should be(true)
28
35
  end
29
-
30
- it 'should provide the command line option minigems' do
31
- WarningShot.parser.to_s.include?("Not supported yet.").should be(true)
32
- WarningShot::Config.configuration.key?(:minigems).should be(true)
36
+
37
+ it 'should override Gem.path if gempath is given' do
38
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
39
+ WarningShot::GemResolver.new config
40
+
41
+ Gem.path[0].should == File.expand_path("./test/output/gems")
42
+ Gem.path[1].should == File.expand_path("./test/outputs/gems2")
43
+ Gem.path.shift
44
+ Gem.path.shift
33
45
  end
34
-
35
- it 'should override Gem.path if gem_path is given' do
36
- WarningShot::Config.configuration[:gem_path] = "./test/output/gems:./test/outputs/gems2"
37
- WarningShot::GemResolver.load_paths
38
46
 
39
- Gem.path[0].should == "./test/output/gems"
40
- Gem.path[1].should == "./test/outputs/gems2"
47
+ it 'should provide the command line option --update-sources' do
48
+ WarningShot::Config::PARSER.to_s.include?("Update gem sources before installing").should be(true)
49
+ WarningShot::Config.parse_args(['--update-sources']).key?(:update_sources).should be(true)
41
50
  end
42
-
43
- it 'should be able to determine if a gem is installed' do
44
- resolver = WarningShot::GemResolver.new({:name => "rake"},{:name => "rspec",:version => ">=1.1.4"})
51
+
52
+ # The gem name is the healing instructions, so if its provide it is the instructions
53
+ it 'should install the gems when healing is enabled' do
54
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
55
+ resolver = WarningShot::GemResolver.new(config,{:name => "ws-dummy"})
45
56
  resolver.test!
46
57
 
47
- resolver.passed.size.should be(2)
58
+ resolver.failed.size.should be(1)
59
+
60
+ resolver.resolve!
61
+ resolver.resolved.size.should be(1)
48
62
  end
49
63
 
50
- # The gem name is the healing instructions, so if its provide, there
51
- # are instructions
52
- it 'should install the gems when healing is enabled' do
53
- resolver = WarningShot::GemResolver.new({:name => "yard"})
64
+ it 'should be able to determine if a gem is installed' do
65
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
66
+
67
+ resolver = WarningShot::GemResolver.new(config, {:name => "ws-dummy"})
54
68
  resolver.test!
69
+ resolver.failed.size.should be(1)
70
+ resolver.resolve!
71
+
72
+ resolver = WarningShot::GemResolver.new( config,{:name => "ws-dummy"})
73
+ resolver.test!
74
+ resolver.passed.size.should be(1)
75
+ end
76
+
77
+ it 'should be able to install a specific version' do
78
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
79
+ dummy_gem = {:name => "ws-dummy", :version=>"= 0.2.0"}
55
80
 
81
+ resolver = WarningShot::GemResolver.new(config,dummy_gem)
82
+ resolver.test!
56
83
  resolver.failed.size.should be(1)
84
+ resolver.resolve!
85
+
86
+ resolver.resolved.size.should be(1)
87
+ resolver.resolved.first.version.to_s.should == dummy_gem[:version]
88
+ end
89
+
90
+ it 'should be able to determine if a gem is installed in the default gem path' do
91
+ Gem.clear_paths
92
+ config = WarningShot::Config.create
93
+ dummy_gem = {:name => "ws-dummy", :version=>"= 0.2.0"}
57
94
 
95
+ resolver = WarningShot::GemResolver.new(config,dummy_gem)
96
+ resolver.test!
97
+ resolver.failed.size.should be(1)
58
98
  resolver.resolve!
59
99
  resolver.resolved.size.should be(1)
100
+ resolver.resolved.first.version.to_s.should == dummy_gem[:version]
101
+
102
+ WarningShot::GemResolver::GemResource.new(dummy_gem[:name],dummy_gem[:version]).uninstall!
60
103
  end
61
104
 
62
- it 'should check for gems in --gempath when specified' do
63
- pending
105
+ it 'should be able to determine if a gem is installed in a different path (--gempath)' do
106
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
107
+ resolver = WarningShot::GemResolver.new(config,{:name => "ws-dummy"})
108
+ resolver.test!
109
+
110
+ resolver.failed.size.should be(1)
111
+
112
+ resolver.resolve!
113
+ resolver.resolved.size.should be(1)
114
+
115
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
116
+ resolver = WarningShot::GemResolver.new(config,{:name => "ws-dummy"})
117
+ resolver.test!
118
+ resolver.passed.size.should be(1)
119
+
120
+ File.exist?("./test/output/gems/specifications/ws-dummy-1.5.0.gemspec").should be(true)
64
121
  end
65
-
66
- it 'should install gems in --gempath when specified and resolving' do
67
- pending
122
+
123
+ it 'should be able to determine if a specific version is installed' do
124
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
125
+ dummy_gem = {:name => "ws-dummy", :version=>"= 0.2.0"}
126
+
127
+ resolver = WarningShot::GemResolver.new(config,dummy_gem)
128
+ resolver.test!
129
+ resolver.failed.size.should be(1)
130
+ resolver.resolve!
131
+
132
+ resolver = WarningShot::GemResolver.new(config,dummy_gem)
133
+ resolver.test!
134
+ resolver.passed.size.should be(1)
68
135
  end
136
+
137
+ it 'should be able to install gems from an alternate source' do
138
+ config = WarningShot::Config.create({:gem_path => "./test/output/gems:./test/outputs/gems2"})
139
+ dummy_gem = {:name => "coryodaniel-ws-dummy", :version=>"= 1.5.0", :source => "http://gems.github.com"}
140
+
141
+ resolver = WarningShot::GemResolver.new(config,dummy_gem)
142
+ resolver.test!
143
+ resolver.failed.size.should be(1)
144
+ resolver.resolve!
69
145
 
70
- it 'should use warningshot_dummy instead of the gems listed above' do
71
- #it should also uninstall it before :all and after :all
72
- pending
146
+ resolver.resolved.size.should be(1)
147
+ resolver.resolved.first.version.to_s.should == dummy_gem[:version]
73
148
  end
149
+
74
150
  end
@@ -21,7 +21,7 @@ describe WarningShot::IntegrityResolver do
21
21
  that_file = @@source_path / 'that.txt'
22
22
  #These values are flipped from FileResolverRspec so that we dont
23
23
  # have to resolve the file dependency to check the integrity
24
- resolver = WarningShot::IntegrityResolver.new({
24
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
25
25
  :target => "file://#{that_file}",
26
26
  :source => "",
27
27
  :sha1 => "e87c9091b6f6d30d1a05d66de1acbac6e1998121"
@@ -35,7 +35,7 @@ describe WarningShot::IntegrityResolver do
35
35
  that_file = @@source_path / 'that.txt'
36
36
  #These values are flipped from FileResolverRspec so that we dont
37
37
  # have to resolve the file dependency to check the integrity
38
- resolver = WarningShot::IntegrityResolver.new({
38
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
39
39
  :target => "file://#{that_file}",
40
40
  :source => "",
41
41
  :sha1 => "WRONG"
@@ -49,7 +49,7 @@ describe WarningShot::IntegrityResolver do
49
49
  that_file = @@source_path / 'that.txt'
50
50
  #These values are flipped from FileResolverRspec so that we dont
51
51
  # have to resolve the file dependency to check the integrity
52
- resolver = WarningShot::IntegrityResolver.new({
52
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
53
53
  :target => "file://#{that_file}",
54
54
  :source => "",
55
55
  :md5 => "WRONG"
@@ -63,7 +63,7 @@ describe WarningShot::IntegrityResolver do
63
63
  that_file = @@source_path / 'that.txt'
64
64
  #These values are flipped from FileResolverRspec so that we dont
65
65
  # have to resolve the file dependency to check the integrity
66
- resolver = WarningShot::IntegrityResolver.new({
66
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
67
67
  :target => "file://#{that_file}",
68
68
  :source => "",
69
69
  :md5 => "db59da6066bab8885569c012b1f6b173"
@@ -77,7 +77,7 @@ describe WarningShot::IntegrityResolver do
77
77
  that_file = @@source_path / 'that.txt'
78
78
  #These values are flipped from FileResolverRspec so that we dont
79
79
  # have to resolve the file dependency to check the integrity
80
- resolver = WarningShot::IntegrityResolver.new({
80
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
81
81
  :target => "file://#{that_file}",
82
82
  :source => "",
83
83
  :md5 => "WRONG",
@@ -92,7 +92,7 @@ describe WarningShot::IntegrityResolver do
92
92
  that_file = @@source_path / 'that.txt'
93
93
  #These values are flipped from FileResolverRspec so that we dont
94
94
  # have to resolve the file dependency to check the integrity
95
- resolver = WarningShot::IntegrityResolver.new({
95
+ resolver = WarningShot::IntegrityResolver.new(WarningShot::Config.create,{
96
96
  :target => "file://#{that_file}",
97
97
  :source => ""
98
98
  })
@@ -17,13 +17,13 @@ describe WarningShot::PermissionResolver do
17
17
  _file = $test_data / 'permission_test.txt'
18
18
  _file2 = $test_data / 'permission_test.fake'
19
19
 
20
- resolver = WarningShot::PermissionResolver.new({
20
+ resolver = WarningShot::PermissionResolver.new(WarningShot::Config.create,{
21
21
  :path => _file, :mode => '0755',
22
22
  :user => 'www-data', :group => 'www-data',
23
23
  :recursive => "none"
24
24
  })
25
25
 
26
- resolver2 = WarningShot::PermissionResolver.new({
26
+ resolver2 = WarningShot::PermissionResolver.new(WarningShot::Config.create,{
27
27
  :path => _file2, :mode => '0755',
28
28
  :user => 'www-data', :group => 'www-data',
29
29
  :recursive => "none"
@@ -1,4 +1,5 @@
1
1
  require "." / "lib" / "resolvers" / "symlink_resolver"
2
+ require 'digest/md5'
2
3
 
3
4
  describe WarningShot::SymlinkResolver do
4
5
  before :all do
@@ -31,7 +32,7 @@ describe WarningShot::SymlinkResolver do
31
32
  :source => @@data_path / 'mock_resolver.rb',
32
33
  :target => @@base_path / 'linked_mock_resolver.rb'
33
34
  }
34
- resolver = WarningShot::SymlinkResolver.new symlink_dep
35
+ resolver = WarningShot::SymlinkResolver.new WarningShot::Config.create,symlink_dep
35
36
 
36
37
  resolver.test!
37
38
  resolver.failed.length.should be(1)
@@ -41,4 +42,10 @@ describe WarningShot::SymlinkResolver do
41
42
  File.symlink?(symlink_dep[:target]).should be(true)
42
43
  end
43
44
  end # End healing enabled, instructions provided
45
+
46
+ describe 'it should expand the target and source paths' do
47
+ sym = WarningShot::SymlinkResolver.yaml_to_object({:source => "./test_src_expand",:target => "../test_target_expand",:force => true})
48
+ sym.source.should == File.expand_path("./test_src_expand")
49
+ sym.target.should == File.expand_path("../test_target_expand")
50
+ end
44
51
  end
@@ -14,44 +14,44 @@ describe WarningShot::UrlResolver do
14
14
  end
15
15
 
16
16
  it 'should extend the command line interface' do
17
- WarningShot.parser.to_s.include?("Success is only for 200 instead of 2xx").should be(true)
18
- WarningShot.parser.to_s.include?("SSL Verify Peer Depth").should be(true)
19
- WarningShot.parser.to_s.include?("Path to root ca certificate").should be(true)
17
+ WarningShot::Config::PARSER.to_s.include?("Success is only for 200 instead of 2xx").should be(true)
18
+ WarningShot::Config::PARSER.to_s.include?("SSL Verify Peer Depth").should be(true)
19
+ WarningShot::Config::PARSER.to_s.include?("Path to root ca certificate").should be(true)
20
20
  end
21
21
 
22
22
  it 'should be able to determine if an http address is reachable' do
23
- resolver = WarningShot::UrlResolver.new "http://example.com"
23
+ resolver = WarningShot::UrlResolver.new WarningShot::Config.create,"http://example.com"
24
24
  resolver.test!
25
25
  resolver.failed.length.should be(0)
26
26
  end
27
27
 
28
28
  it 'should be able to determine if an https address is reachable' do
29
29
  #Yeah, what https page to use, huh?
30
- resolver = WarningShot::UrlResolver.new "https://www.google.com/analytics/home/"
30
+ resolver = WarningShot::UrlResolver.new WarningShot::Config.create,"https://www.google.com/analytics/home/"
31
31
  resolver.test!
32
32
  resolver.failed.length.should be(0)
33
33
  end
34
34
 
35
35
  it 'should be able to determine if an http address is unreachable' do
36
- resolver = WarningShot::UrlResolver.new "http://example.com", "http://127.0.0.1:31337"
36
+ resolver = WarningShot::UrlResolver.new WarningShot::Config.create, "http://example.com", "http://127.0.0.1:31337"
37
37
  resolver.test!
38
38
  resolver.failed.length.should be(1)
39
39
  resolver.passed.length.should be(1)
40
40
  end
41
41
 
42
42
  it 'should be able to determine if an https address is unreachable' do
43
- resolver = WarningShot::UrlResolver.new "https://www.google.com/analytics/home/", "https://127.0.0.1:31337"
43
+ resolver = WarningShot::UrlResolver.new WarningShot::Config.create,"https://www.google.com/analytics/home/", "https://127.0.0.1:31337"
44
44
  resolver.test!
45
45
  resolver.failed.length.should be(1)
46
46
  resolver.passed.length.should be(1)
47
47
  end
48
48
 
49
49
  it 'should be able to receive --strict from the command line' do
50
- WarningShot::Config.configuration[:url_strict] = true
51
- WarningShot::Config.configuration[:url_strict].should be(true)
50
+ config = WarningShot::Config.create({:url_strict=>true})
51
+ config[:url_strict].should be(true)
52
52
 
53
53
  #google redirects, ever heard of no-www.org?
54
- resolver = WarningShot::UrlResolver.new "http://example.com","http://google.com"
54
+ resolver = WarningShot::UrlResolver.new config, "http://example.com","http://google.com"
55
55
 
56
56
  resolver.test!
57
57
  resolver.failed.length.should be(1)
@@ -0,0 +1,57 @@
1
+ describe WarningShot::Config do
2
+
3
+ it 'should be able to parse an ARGV string' do
4
+ args = ['--very-verbose','--resolve','--environment=rspec_test','-g','-aRspecTest']
5
+ config = WarningShot::Config.parse_args(args)
6
+ config[:verbose].should be(true)
7
+ config[:resolve].should be(true)
8
+ config[:environment].should == 'rspec_test'
9
+ config[:growl].should be(true)
10
+ config[:application].should == 'RspecTest'
11
+ end
12
+
13
+ it 'should provide defaults' do
14
+ defined?(WarningShot::Config::DEFAULTS).should == 'constant'
15
+ WarningShot::Config::DEFAULTS.class.should be(Hash)
16
+ end
17
+
18
+ it 'should set defaults if no configuration is passed in' do
19
+ config = WarningShot::Config.create
20
+ config.should == WarningShot::Config::DEFAULTS
21
+ end
22
+
23
+ it 'should allow configurations to be done with a hash and still set defaults' do
24
+ _config = {
25
+ :growl => true,
26
+ :environment => :rspec_test
27
+ }
28
+ config = WarningShot::Config.create _config
29
+ config[:growl].should be(true)
30
+ config[:environment].should == :rspec_test
31
+ config[:colorize].should be(true)
32
+ end
33
+
34
+ it 'should allow configurations to be changed with a block' do
35
+ config = WarningShot::Config.create do|c|
36
+ c[:growl] = true
37
+ c[:resolve]= true
38
+ end
39
+
40
+ config[:growl].should be(true)
41
+ config[:resolve].should be(true)
42
+ config[:colorize].should be(true)
43
+ end
44
+
45
+
46
+ it 'should allow a hash and block to be passed, block wins' do
47
+ conf = WarningShot::Config.create({:environment=>"hash",:something=>true}) do |c|
48
+ c[:environment] = "blk"
49
+ c[:else] = true
50
+ end
51
+
52
+ conf[:environment].should == "blk"
53
+ conf[:something].should be(true)
54
+ conf[:else].should be(true)
55
+ conf[:colorize].should be(true)
56
+ end
57
+ end