fuzzbert 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'fuzzbert'
3
3
 
4
4
  describe FuzzBert::Executor do
5
5
 
6
- describe "new" do
6
+ describe "::new" do
7
7
  let(:test) do
8
8
  test = FuzzBert::Test.new(lambda { |data| data })
9
9
  FuzzBert::TestSuite.create("suite") do
@@ -18,6 +18,14 @@ describe FuzzBert::Executor do
18
18
  FuzzBert::Executor.new([test]).should be_an_instance_of(FuzzBert::Executor)
19
19
  end
20
20
 
21
+ it "raises an ArgumentError if the TestSuite argument is nil" do
22
+ -> { FuzzBert::Executor.new(nil) }.should raise_error ArgumentError
23
+ end
24
+
25
+ it "raises an ArgumentError if the TestSuite argument is empty" do
26
+ -> { FuzzBert::Executor.new([]) }.should raise_error ArgumentError
27
+ end
28
+
21
29
  it "allows a pool_size argument" do
22
30
  size = 1
23
31
  executor = FuzzBert::Executor.new(test, pool_size: size)
@@ -36,6 +44,12 @@ describe FuzzBert::Executor do
36
44
  executor.handler.should == handler
37
45
  end
38
46
 
47
+ it "allows a sleep_delay argument" do
48
+ delay = 0.1
49
+ executor = FuzzBert::Executor.new(test, sleep_delay: delay)
50
+ executor.sleep_delay.should == delay
51
+ end
52
+
39
53
  it "defaults pool_size to 4" do
40
54
  FuzzBert::Executor.new(test).pool_size.should == 4
41
55
  end
@@ -47,18 +61,22 @@ describe FuzzBert::Executor do
47
61
  it "defaults handler to a FileOutputHandler" do
48
62
  FuzzBert::Executor.new(test).handler.should be_an_instance_of(FuzzBert::Handler::FileOutput)
49
63
  end
64
+
65
+ it "defaults sleep_delay to 1" do
66
+ FuzzBert::Executor.new(test).sleep_delay.should == 1
67
+ end
50
68
  end
51
69
 
52
70
  describe "#run" do
53
- subject { FuzzBert::Executor.new(suite, pool_size: 1, limit: 1, handler: handler).run }
71
+ subject { FuzzBert::Executor.new(suite, pool_size: 1, limit: 1, handler: handler, sleep_delay: 0.05).run }
54
72
 
55
73
  class TestHandler
56
74
  def initialize(&blk)
57
75
  @handler = blk
58
76
  end
59
77
 
60
- def handle(id, data, pid, status)
61
- @handler.call(id, data, pid, status)
78
+ def handle(error_data)
79
+ @handler.call(error_data)
62
80
  end
63
81
  end
64
82
 
@@ -69,7 +87,7 @@ describe FuzzBert::Executor do
69
87
  data("1") { -> { "a" } }
70
88
  end
71
89
  end
72
- let (:handler) { TestHandler.new { |i, d, p, s| raise RuntimeError.new } }
90
+ let (:handler) { TestHandler.new { |data| raise RuntimeError.new } }
73
91
  it { -> { subject }.should_not raise_error }
74
92
  end
75
93
 
@@ -81,7 +99,7 @@ describe FuzzBert::Executor do
81
99
  data("1") { -> { "a" } }
82
100
  end
83
101
  end
84
- let (:handler) { TestHandler.new { |i, d, p, s| called = true } }
102
+ let (:handler) { TestHandler.new { |data| called = true } }
85
103
  it { -> { subject }.should_not raise_error; called.should be_true }
86
104
  end
87
105
 
@@ -92,7 +110,7 @@ describe FuzzBert::Executor do
92
110
  data("1") { -> { "a" } }
93
111
  end
94
112
  end
95
- let (:handler) { TestHandler.new { |i, d, p, s| raise RuntimeError.new } }
113
+ let (:handler) { TestHandler.new { |data| raise RuntimeError.new } }
96
114
  it { -> { subject }.should_not raise_error }
97
115
  end
98
116
 
@@ -104,7 +122,7 @@ describe FuzzBert::Executor do
104
122
  data("1") { -> { "a" } }
105
123
  end
106
124
  end
107
- let (:handler) { TestHandler.new { |i, d, p, s| called = true } }
125
+ let (:handler) { TestHandler.new { |data| called = true } }
108
126
  let (:generator) { FuzzBert::Generator.new("test") { "a" } }
109
127
  it { -> { subject }.should_not raise_error; called.should be_true }
110
128
  end if false #don't want to SEGV every time
@@ -3,7 +3,7 @@ require 'fuzzbert'
3
3
 
4
4
  describe FuzzBert::Generator do
5
5
 
6
- describe "new" do
6
+ describe "::new" do
7
7
  it "takes a description and a generator" do
8
8
  desc = "desc"
9
9
  value = "test"
@@ -11,8 +11,17 @@ describe FuzzBert::Generator do
11
11
  gen.description.should == desc
12
12
  gen.to_data.should == value
13
13
  end
14
+ end
14
15
 
15
- it "takes a block that is executed when to_data is called when no explicit generator is given" do
16
+ describe "#generator" do
17
+ it "implements Generation" do
18
+ gen = FuzzBert::Generator.new("test") { "test" }
19
+ gen.generator.should_not be_nil
20
+ end
21
+ end
22
+
23
+ describe "#to_data" do
24
+ it "returns the value returned by its generator" do
16
25
  value = "test"
17
26
  desc = "desc"
18
27
  gen = FuzzBert::Generator.new(desc) { value }
@@ -20,6 +29,5 @@ describe FuzzBert::Generator do
20
29
  gen.to_data.should == value
21
30
  end
22
31
  end
23
-
24
32
  end
25
33
 
@@ -3,16 +3,18 @@ require 'fuzzbert'
3
3
 
4
4
  describe FuzzBert::Mutator do
5
5
 
6
- describe "new" do
6
+ describe "::new" do
7
7
  it "takes a (valid) base value" do
8
8
  value = "test"
9
9
  mut = FuzzBert::Mutator.new(value)
10
10
  end
11
11
  end
12
12
 
13
- it "includes Generation" do
14
- mut = FuzzBert::Mutator.new("value")
15
- mut.generator.should_not be_nil
13
+ describe "#generator" do
14
+ it "implements Generation" do
15
+ mut = FuzzBert::Mutator.new("value")
16
+ mut.generator.should_not be_nil
17
+ end
16
18
  end
17
19
 
18
20
  describe "#to_data" do
@@ -3,13 +3,13 @@ require 'fuzzbert'
3
3
 
4
4
  describe FuzzBert::Template do
5
5
 
6
- describe "new" do
6
+ describe "::new" do
7
7
  it "takes a String parameter" do
8
8
  FuzzBert::Template.new("test").should be_an_instance_of(FuzzBert::Template)
9
9
  end
10
10
  end
11
11
 
12
- describe "set" do
12
+ describe "#set" do
13
13
  it "allows to define callbacks for template variables" do
14
14
  t = FuzzBert::Template.new "a${var}c"
15
15
  t.set(:var) { "b" }
@@ -23,7 +23,14 @@ describe FuzzBert::Template do
23
23
  end
24
24
  end
25
25
 
26
- describe "to_data" do
26
+ describe "#generator" do
27
+ it "implements Generation" do
28
+ t = FuzzBert::Template.new "test"
29
+ t.generator.should_not be_nil
30
+ end
31
+ end
32
+
33
+ describe "#to_data" do
27
34
  it "can replace multiple template variables that possess a callback defined by set" do
28
35
  t = FuzzBert::Template.new "a${var1}c${var2}"
29
36
  t.set(:var1) { "b" }
@@ -79,6 +86,16 @@ describe FuzzBert::Template do
79
86
  t.set(:name) { "FuzzBert" }
80
87
  t.to_data.should == "{ user: { id: 5, name: \"FuzzBert\" } }\n"
81
88
  end
89
+
90
+ it "raises an error if a variable callback hasn't been set and indicates which one" do
91
+ t = FuzzBert::Template.new "a${var}c"
92
+ begin
93
+ t.to_data
94
+ fail
95
+ rescue StandardError => e
96
+ e.message.should include("var")
97
+ end
98
+ end
82
99
  end
83
100
 
84
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzbert
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-16 00:00:00.000000000 Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A random testing / fuzzer framework for Ruby.
15
15
  email: Martin.Bosslet@gmail.com
@@ -20,30 +20,29 @@ extra_rdoc_files:
20
20
  - README.md
21
21
  files:
22
22
  - lib/fuzzbert.rb
23
- - lib/fuzzbert/error_handler.rb
24
- - lib/fuzzbert/test.rb
25
- - lib/fuzzbert/autorun.rb
26
- - lib/fuzzbert/autorun.rb~
27
23
  - lib/fuzzbert/generators.rb
28
- - lib/fuzzbert/mutator.rb
29
- - lib/fuzzbert/template.rb
30
- - lib/fuzzbert/rake_task.rb
31
24
  - lib/fuzzbert/test_suite.rb
25
+ - lib/fuzzbert/rake_task.rb
32
26
  - lib/fuzzbert/generator.rb
27
+ - lib/fuzzbert/error_handler.rb
28
+ - lib/fuzzbert/version.rb
29
+ - lib/fuzzbert/autorun.rb
30
+ - lib/fuzzbert/test.rb
31
+ - lib/fuzzbert/generation.rb
33
32
  - lib/fuzzbert/container.rb
34
33
  - lib/fuzzbert/executor.rb
35
- - lib/fuzzbert/version.rb
34
+ - lib/fuzzbert/template.rb
36
35
  - lib/fuzzbert/dsl.rb
37
- - lib/fuzzbert/generation.rb
36
+ - lib/fuzzbert/mutator.rb
38
37
  - LICENSE
39
38
  - README.md
40
- - spec/autorun_spec.rb
41
- - spec/template_spec.rb
42
- - spec/mutator_spec.rb
43
- - spec/executor_spec.rb
44
- - spec/dsl_spec.rb
45
39
  - spec/generator_spec.rb
46
40
  - spec/test_spec.rb
41
+ - spec/executor_spec.rb
42
+ - spec/mutator_spec.rb
43
+ - spec/autorun_spec.rb
44
+ - spec/dsl_spec.rb
45
+ - spec/template_spec.rb
47
46
  - bin/fuzzbert
48
47
  homepage: https://github.com/krypt/FuzzBert
49
48
  licenses:
@@ -71,10 +70,10 @@ signing_key:
71
70
  specification_version: 3
72
71
  summary: Fuzz your applications and libraries with minimal effort.
73
72
  test_files:
74
- - spec/autorun_spec.rb
75
- - spec/template_spec.rb
76
- - spec/mutator_spec.rb
77
- - spec/executor_spec.rb
78
- - spec/dsl_spec.rb
79
73
  - spec/generator_spec.rb
80
74
  - spec/test_spec.rb
75
+ - spec/executor_spec.rb
76
+ - spec/mutator_spec.rb
77
+ - spec/autorun_spec.rb
78
+ - spec/dsl_spec.rb
79
+ - spec/template_spec.rb
@@ -1,33 +0,0 @@
1
-
2
- module FuzzBert::AutoRun
3
-
4
- TEST_CASES = []
5
-
6
- module_function
7
-
8
- def register(suite)
9
- TEST_CASES << suite
10
- end
11
-
12
- def autorun
13
- at_exit do
14
- next if $! # don't run if there was an exception
15
-
16
- load_files(ARGV)
17
- run
18
-
19
- end unless @@installed_at_exit
20
- @@installed_at_exit = true
21
- end
22
-
23
- def run
24
- FuzzBert::Executor.new(TEST_CASES).run
25
- end
26
-
27
- private
28
-
29
- def load_files(args)
30
- end
31
-
32
- end
33
-