faultinjection 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
File without changes
File without changes
File without changes
File without changes
data/History.txt CHANGED
@@ -1,4 +1,11 @@
1
1
  == 0.0.1 2008-01-10
2
2
 
3
- * 1 major enhancement:
4
- * Initial release
3
+ * Initial release
4
+
5
+ == 0.0.2 2008-01-11
6
+
7
+ * Changed method name
8
+ 'FaultInjection::inject_fault' --> 'FaultInjection::inject'
9
+
10
+ * Changed FaultInjection::inject to return true/false.
11
+
data/Manifest.txt CHANGED
@@ -1,4 +1,8 @@
1
1
  #*scratch*#18552Tu2#
2
+ #*scratch*#20064OwE#
3
+ #*scratch*#20109z1E#
4
+ #*scratch*#20389vPF#
5
+ #*scratch*#20789Z7F#
2
6
  History.txt
3
7
  License.txt
4
8
  Manifest.txt
data/README.txt CHANGED
@@ -13,6 +13,15 @@ fault_injection.rb
13
13
  to improve the coverage of your tests.
14
14
  See http://en.wikipedia.org/wiki/Fault_injection for more details.
15
15
 
16
+ * What can I do with fault_injection.rb ?
17
+
18
+ - You can raise error at any line of code or particular method call
19
+ without changing the target code.
20
+ * Cat it be used with Ruby on Rails testing?
21
+
22
+ - It should, but it's not yet tested well with big applications.
23
+ Please try and feel free to send me a bug report.
24
+
16
25
  * Can I use it in my application code?
17
26
 
18
27
  - No. It is for your testing code.
@@ -22,6 +31,9 @@ fault_injection.rb
22
31
  - You should not. It is for some limited situation that rarely
23
32
  happen or difficult to set up (ex. IOError).
24
33
  If you can make 'evil situation' easily, that's better ;)
34
+
35
+ In addition, fault_injection.rb uses set_trace_func API of ruby and
36
+ it makes a script much slower.
25
37
 
26
38
  ** Installing
27
39
 
@@ -42,15 +54,15 @@ $ sudo gem install faultinjection
42
54
  __END__
43
55
 
44
56
  # test.rb
57
+ require 'rubygems'
45
58
  require 'fault_injection'
46
- include FaultInjection
47
59
 
48
- inject "Foo#foo > Kernel#puts", IOError, "IO error"
60
+ FaultInjection.inject "Foo#foo > Kernel#puts", IOError, "IO error"
49
61
 
50
62
  f = Foo.new
51
63
  f.foo #=> IOError
52
64
 
53
- inject "sample.rb:7",ZeroDivisionError
65
+ FaultInjection.inject "sample.rb:7",ZeroDivisionError
54
66
 
55
67
  f.bar #=> ZeroDivisionError
56
68
  __END__
@@ -2,7 +2,7 @@ module FaultInjection #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -7,11 +7,11 @@ module FaultInjection
7
7
  @@injected_faults = nil
8
8
  @@method_stack = Array.new
9
9
 
10
- def inject_fault(*args)
11
- FaultInjection.inject_fault *args
10
+ def inject(*args)
11
+ FaultInjection.inject *args
12
12
  end
13
13
 
14
- def self.inject_fault(command,error_class=RuntimeError,msg="injected fault")
14
+ def self.inject(command,error_class=RuntimeError,msg="injected fault")
15
15
  unless error_class <= Exception
16
16
  raise ArgumentError, "Error class must be a subclass of Exception"
17
17
  end
@@ -41,6 +41,8 @@ module FaultInjection
41
41
  raise "[BUG] Internal Error. Please report this to the author :)" if cond.nil?
42
42
 
43
43
  @@injected_faults << cond
44
+
45
+ true
44
46
  end
45
47
 
46
48
  # delete all injected faults.
@@ -1,19 +1,18 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
  require 'fault_injection.rb'
3
3
 
4
- include FaultInjection
5
4
  $LOAD_PATH << File.dirname(__FILE__)
6
5
 
7
6
  describe "Argument Checking" do
8
7
  it "raises if a line number is less than 0" do
9
8
  Proc.new{
10
- inject_fault({:file => 'target_00.rb',:line => -5})
9
+ FaultInjection.inject({:file => 'target_00.rb',:line => -5}).should be_true
11
10
  }.should raise_error(ArgumentError)
12
11
  end
13
12
 
14
13
  it "raises if a err_class is not a subclass of Exception" do
15
14
  Proc.new {
16
- inject_fault({:file => 'target_00.rb',:line => 1}, 3)
15
+ FaultInjection.inject({:file => 'target_00.rb',:line => 1}, 3).should be_true
17
16
  }.should raise_error(ArgumentError)
18
17
  end
19
18
  end
@@ -27,7 +26,7 @@ describe "'File & line' fault-injection." do
27
26
 
28
27
  it "works on Hash format for file & line specification" do
29
28
  Proc.new{ target_func_00 }.should_not raise_error
30
- inject_fault({:file => 'target_00.rb', :line => 9})
29
+ FaultInjection.inject({:file => 'target_00.rb', :line => 9}).should be_true
31
30
 
32
31
  begin
33
32
  target_func_00
@@ -44,7 +43,9 @@ describe "'File & line' fault-injection." do
44
43
  it "works on 'file:line' format injection command." do
45
44
  Proc.new{ target_func_00 }.should_not raise_error
46
45
 
47
- inject_fault "target_00.rb:9", SecurityError, "This is a error"
46
+ FaultInjection.inject("target_00.rb:9",
47
+ SecurityError,
48
+ "This is a error").should be_true
48
49
  Proc.new{
49
50
  target_func_00
50
51
  }.should raise_error(SecurityError,"This is a error")
@@ -62,15 +63,15 @@ describe "Method tracing fault-injection" do
62
63
  it "should check arguments in Array format command." do
63
64
  Proc.new{ Bar.new.bar }.should_not raise_error
64
65
 
65
- Proc.new{ inject_fault([]) }.should raise_error(ArgumentError)
66
- Proc.new{ inject_fault([:Array]) }.should raise_error(ArgumentError)
66
+ Proc.new{ FaultInjection.inject([]) }.should raise_error(ArgumentError)
67
+ Proc.new{ FaultInjection.inject([:Array]) }.should raise_error(ArgumentError)
67
68
  end
68
69
 
69
70
  it "should inject faults properly with Array format command" do
70
71
  Proc.new{ Bar.new.bar }.should_not raise_error
71
72
 
72
73
  # raise on method calling chane, "Bar#bar --> Foo#foo"
73
- inject_fault [:Bar,:bar,:Foo,:foo],RangeError
74
+ FaultInjection.inject([:Bar,:bar,:Foo,:foo],RangeError).should be_true
74
75
  Proc.new{ Bar.new.bar }.should raise_error(RangeError)
75
76
  end
76
77
  end
@@ -79,7 +80,8 @@ describe "Specifying Exception class" do
79
80
  require 'target_01.rb'
80
81
 
81
82
  it "can inject fault with specified Exception class" do
82
- inject_fault({:file => 'target_01.rb', :line => 3},ArgumentError)
83
+ include FaultInjection
84
+ inject({:file => 'target_01.rb', :line => 3},ArgumentError).should be_true
83
85
 
84
86
  Proc.new{ target_func_01 }.should raise_error(ArgumentError)
85
87
 
data/website/index.html CHANGED
@@ -10,31 +10,13 @@
10
10
  <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
11
  <style>
12
12
 
13
- </style>
14
- <!--
15
- <script type="text/javascript">
16
- window.onload = function() {
17
- settings = {
18
- tl: { radius: 10 },
19
- tr: { radius: 10 },
20
- bl: { radius: 10 },
21
- br: { radius: 10 },
22
- antiAlias: true,
23
- autoPad: true,
24
- validTags: ["div"]
25
- }
26
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
27
- versionBox.applyCornersToAll();
28
- }
29
- </script>
30
- -->
31
13
  </head>
32
14
  <body>
33
15
  <div id="main">
34
16
 
35
17
  <h1>fault_injection.rb</h1>
36
18
  <div style="text-align:right;">
37
- Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.1</a>
19
+ Last version: <a href="http://rubyforge.org/projects/fault_injection" class="numbers">0.0.2</a>
38
20
  </div>
39
21
  <h2>Overview</h2>
40
22
 
@@ -49,7 +31,7 @@
49
31
 
50
32
 
51
33
  <p>Fault injection is one of testing techniques.
52
- It makes easier to test your application&#8217;s error handling behavior or
34
+ It makes it easier to test your application&#8217;s error handling behavior or
53
35
  to improve the coverage of your tests.</p>
54
36
 
55
37
 
@@ -58,6 +40,20 @@ http://en.wikipedia.org/wiki/Fault_injection
58
40
  </a> for more details.</p>
59
41
 
60
42
 
43
+ <h3>What can I do with fault_injection.rb ?</h3>
44
+
45
+
46
+ <p>You can raise error at any line of code or particular method call without
47
+ changing the target code.</p>
48
+
49
+
50
+ <h3>Cat it be used with Ruby on Rails testing?</h3>
51
+
52
+
53
+ <p>It should, but it&#8217;s not yet tested well with big applications.
54
+ Please try and feel free to send me a bug report.</p>
55
+
56
+
61
57
  <h3>Can I use it in my application code?</h3>
62
58
 
63
59
 
@@ -72,6 +68,10 @@ happen or difficult to set up (ex. IOError).
72
68
  If you can make &#8216;evil situation&#8217; easily, that&#8217;s better ;)</p>
73
69
 
74
70
 
71
+ <p>In addition, fault_injection.rb uses set_trace_func <span class="caps">API</span> of ruby and
72
+ it makes a script much slower.</p>
73
+
74
+
75
75
  <h2>Installing</h2>
76
76
 
77
77
 
@@ -95,6 +95,7 @@ If you can make &#8216;evil situation&#8217; easily, that&#8217;s better ;)</p>
95
95
  <span class="keyword">end</span>
96
96
 
97
97
  <span class="comment"># test.rb</span>
98
+ <span class="ident">require</span> <span class="punct">'</span><span class="string">rubygems</span><span class="punct">'</span>
98
99
  <span class="ident">require</span> <span class="punct">'</span><span class="string">fault_injection</span><span class="punct">'</span>
99
100
  <span class="ident">include</span> <span class="constant">FaultInjection</span>
100
101
 
@@ -127,7 +128,7 @@ If you can make &#8216;evil situation&#8217; easily, that&#8217;s better ;)</p>
127
128
 
128
129
  <p>(Please remove &#8221;.spam&#8221; from the address for anti-spam, and include &#8216;ruby&#8217; or &#8216;fault_injection&#8217; in the title)</p>
129
130
  <p class="coda">
130
- <a href="keisukefukuda.spam@gmail.com">Keisuke Fukuda</a>, 11th January 2008<br>
131
+ <a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>, 12th January 2008<br>
131
132
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
132
133
  </p>
133
134
  </div>
data/website/index.txt CHANGED
@@ -9,13 +9,23 @@ A 'fault injection' tool for ruby.
9
9
  h3. What is a 'fault injection'? What is it used for?
10
10
 
11
11
  Fault injection is one of testing techniques.
12
- It makes easier to test your application's error handling behavior or
12
+ It makes it easier to test your application's error handling behavior or
13
13
  to improve the coverage of your tests.
14
14
 
15
15
  See <a herf="http://en.wikipedia.org/wiki/Fault_injection">
16
16
  http://en.wikipedia.org/wiki/Fault_injection
17
17
  </a> for more details.
18
18
 
19
+ h3. What can I do with fault_injection.rb ?
20
+
21
+ You can raise error at any line of code or particular method call without
22
+ changing the target code.
23
+
24
+ h3. Cat it be used with Ruby on Rails testing?
25
+
26
+ It should, but it's not yet tested well with big applications.
27
+ Please try and feel free to send me a bug report.
28
+
19
29
  h3. Can I use it in my application code?
20
30
 
21
31
  No. It is for your testing code.
@@ -26,6 +36,9 @@ You should not. It is for some limited situation that rarely
26
36
  happen or difficult to set up (ex. IOError).
27
37
  If you can make 'evil situation' easily, that's better ;)
28
38
 
39
+ In addition, fault_injection.rb uses set_trace_func API of ruby and
40
+ it makes a script much slower.
41
+
29
42
  h2. Installing
30
43
 
31
44
  <pre syntax="ruby">sudo gem install faultinjection</pre>
@@ -46,6 +59,7 @@ class Foo
46
59
  end
47
60
 
48
61
  # test.rb
62
+ require 'rubygems'
49
63
  require 'fault_injection'
50
64
  include FaultInjection
51
65
 
@@ -10,24 +10,6 @@
10
10
  <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
11
  <style>
12
12
 
13
- </style>
14
- <!--
15
- <script type="text/javascript">
16
- window.onload = function() {
17
- settings = {
18
- tl: { radius: 10 },
19
- tr: { radius: 10 },
20
- bl: { radius: 10 },
21
- br: { radius: 10 },
22
- antiAlias: true,
23
- autoPad: true,
24
- validTags: ["div"]
25
- }
26
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
27
- versionBox.applyCornersToAll();
28
- }
29
- </script>
30
- -->
31
13
  </head>
32
14
  <body>
33
15
  <div id="main">
@@ -38,7 +20,7 @@
38
20
  </div>
39
21
  <%= body %>
40
22
  <p class="coda">
41
- <a href="keisukefukuda.spam@gmail.com">Keisuke Fukuda</a>, <%= modified.pretty %><br>
23
+ <a herf="http://keisukefukuda.rubyforge.org">Keisuke Fukuda</a>, <%= modified.pretty %><br>
42
24
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
43
25
  </p>
44
26
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faultinjection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ""
6
6
  authors:
7
7
  - FIXME full name
@@ -27,6 +27,10 @@ extra_rdoc_files:
27
27
  - website/index.txt
28
28
  files:
29
29
  - "#*scratch*#18552Tu2#"
30
+ - "#*scratch*#20064OwE#"
31
+ - "#*scratch*#20109z1E#"
32
+ - "#*scratch*#20389vPF#"
33
+ - "#*scratch*#20789Z7F#"
30
34
  - History.txt
31
35
  - License.txt
32
36
  - Manifest.txt