/
rake_taks_spec.rb
82 lines (69 loc) · 2.44 KB
/
rake_taks_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'spec_helper'
module Scanny
describe RakeTask do
before(:each) { MockTask.reset_tasks }
it "executes clean scanny" do
task = RakeTask.new
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny"
end
it "executes scanny with format" do
task = RakeTask.new { |t| t.format = :stdout }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -f stdout"
end
it "executes scanny with include option" do
task = RakeTask.new { |t| t.include = "./checks" }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -i ./checks"
end
it "executes scanny with many include option" do
task = RakeTask.new { |t| t.include = ["./checks", "./checks2"] }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -i ./checks ./checks2"
end
it "executes scanny with disable options" do
task = RakeTask.new { |t| t.disable = "HTTPRequestCheck" }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -d HTTPRequestCheck"
end
it "executes scanny with many disable options" do
task = RakeTask.new { |t| t.disable = ["HTTPRequestCheck", "Check"] }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -d HTTPRequestCheck Check"
end
it "executes scanny in strict mode" do
task = RakeTask.new { |t| t.strict = true }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -s"
end
it "executes scanny with custom directory" do
task = RakeTask.new { |t| t.path = "./custom/app" }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny ./custom/app"
end
describe "system command return false" do
before do
task = RakeTask.new { |t| t.fail_on_error = true }
def task.system(*) return false end
end
it "fails on error" do
lambda {
MockTask.last_instance.call
}.should raise_error(RuntimeError)
end
end
describe "ruby parser mode" do
it "executes scanny with ruby 18 mode" do
task = RakeTask.new { |t| t.ruby_mode = "18" }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -m 18"
end
it "executes scanny with ruby 19 mode" do
task = RakeTask.new { |t| t.ruby_mode = "19" }
MockTask.last_instance.call
MockTask.last_cmd.should == "scanny -m 19"
end
end
end
end