evanphx / rubinius

Rubinius, the Ruby VM

This URL has Read+Write access

rubinius / mspec / 0001-Added-d-debug-to-set-MSpec-debugging-verbosity.patch
63f7c37a » brixen 2009-04-29 Updated MSpec source to ef1... 1 From b29d3477bfaae5d4de3fd4c10eb64203773d3bdd Mon Sep 17 00:00:00 2001
2 From: Brian Ford <bford@engineyard.com>
3 Date: Wed, 29 Apr 2009 12:22:12 -0700
4 Subject: [PATCH 1/3] Added -d, --debug to set MSpec debugging (verbosity) flag.
5
6 ---
7 lib/mspec/commands/mspec-ci.rb | 1 +
8 lib/mspec/commands/mspec-run.rb | 1 +
9 lib/mspec/commands/mspec-tag.rb | 1 +
10 lib/mspec/utils/options.rb | 7 +++++++
11 spec/commands/mspec_ci_spec.rb | 5 +++++
12 spec/commands/mspec_run_spec.rb | 5 +++++
13 spec/commands/mspec_tag_spec.rb | 5 +++++
14 spec/utils/options_spec.rb | 26 ++++++++++++++++++++++++++
15 8 files changed, 51 insertions(+), 0 deletions(-)
16
17 diff --git a/lib/mspec/commands/mspec-ci.rb b/lib/mspec/commands/mspec-ci.rb
18 index e838ffc..f5bc84f 100644
19 --- a/lib/mspec/commands/mspec-ci.rb
20 +++ b/lib/mspec/commands/mspec-ci.rb
21 @@ -42,6 +42,7 @@ class MSpecCI < MSpecScript
22 options.action_filters
23
24 options.doc "\n Help!"
25 + options.debug
26 options.version MSpec::VERSION
27 options.help
28
29 diff --git a/lib/mspec/commands/mspec-run.rb b/lib/mspec/commands/mspec-run.rb
30 index 547a484..1026f71 100644
31 --- a/lib/mspec/commands/mspec-run.rb
32 +++ b/lib/mspec/commands/mspec-run.rb
33 @@ -53,6 +53,7 @@ class MSpecRun < MSpecScript
34 options.action_filters
35
36 options.doc "\n Help!"
37 + options.debug
38 options.version MSpec::VERSION
39 options.help
40
41 diff --git a/lib/mspec/commands/mspec-tag.rb b/lib/mspec/commands/mspec-tag.rb
42 index 804599a..bba35e7 100644
43 --- a/lib/mspec/commands/mspec-tag.rb
44 +++ b/lib/mspec/commands/mspec-tag.rb
45 @@ -72,6 +72,7 @@ class MSpecTag < MSpecScript
46 end
47
48 options.doc "\n Help!"
49 + options.debug
50 options.version MSpec::VERSION
51 options.help
52
53 diff --git a/lib/mspec/utils/options.rb b/lib/mspec/utils/options.rb
54 index 0a7d815..52183f6 100644
55 --- a/lib/mspec/utils/options.rb
56 +++ b/lib/mspec/utils/options.rb
57 @@ -440,4 +440,11 @@ class MSpecOptions
58 config[:gdb] = true
59 end
60 end
61 +
62 + def debug
63 + on("-d", "--debug",
64 + "Set MSpec debugging flag for more verbose output") do
65 + $MSPEC_DEBUG = true
66 + end
67 + end
68 end
69 diff --git a/spec/commands/mspec_ci_spec.rb b/spec/commands/mspec_ci_spec.rb
70 index c6c84f7..b0f1515 100644
71 --- a/spec/commands/mspec_ci_spec.rb
72 +++ b/spec/commands/mspec_ci_spec.rb
73 @@ -88,6 +88,11 @@ describe MSpecCI, "#options" do
74 @script.options
75 end
76
77 + it "enables the debug option" do
78 + @options.should_receive(:debug)
79 + @script.options @argv
80 + end
81 +
82 it "calls #custom_options" do
83 @script.should_receive(:custom_options).with(@options)
84 @script.options
85 diff --git a/spec/commands/mspec_run_spec.rb b/spec/commands/mspec_run_spec.rb
86 index a53aa86..6d930d6 100644
87 --- a/spec/commands/mspec_run_spec.rb
88 +++ b/spec/commands/mspec_run_spec.rb
89 @@ -118,6 +118,11 @@ describe MSpecRun, "#options" do
90 @script.options @argv
91 end
92
93 + it "enables the debug option" do
94 + @options.should_receive(:debug)
95 + @script.options @argv
96 + end
97 +
98 it "exits if there are no files to process" do
99 @options.should_receive(:parse).and_return([])
100 @script.should_receive(:exit)
101 diff --git a/spec/commands/mspec_tag_spec.rb b/spec/commands/mspec_tag_spec.rb
102 index 2c048b3..d2092af 100644
103 --- a/spec/commands/mspec_tag_spec.rb
104 +++ b/spec/commands/mspec_tag_spec.rb
105 @@ -98,6 +98,11 @@ describe MSpecTag, "#options" do
106 @script.options @argv
107 end
108
109 + it "enables the debug option" do
110 + @options.should_receive(:debug)
111 + @script.options @argv
112 + end
113 +
114 it "calls #custom_options" do
115 @script.should_receive(:custom_options).with(@options)
116 @script.options @argv
117 diff --git a/spec/utils/options_spec.rb b/spec/utils/options_spec.rb
118 index e488b89..c8383f6 100644
119 --- a/spec/utils/options_spec.rb
120 +++ b/spec/utils/options_spec.rb
121 @@ -1290,3 +1290,29 @@ describe "The --spec-gdb option" do
122 @config[:gdb].should == true
123 end
124 end
125 +
126 +describe "The -d, --debug option" do
127 + before :each do
128 + @options, @config = new_option
129 + @options.debug
130 + end
131 +
132 + after :each do
133 + $MSPEC_DEBUG = nil
134 + end
135 +
136 + it "is enabled with #debug" do
137 + @options.stub!(:on)
138 + @options.should_receive(:on).with("-d", "--debug", an_instance_of(String))
139 + @options.debug
140 + end
141 +
142 + it "sets $MSPEC_DEBUG to true" do
143 + ["-d", "--debug"].each do |opt|
144 + $MSPEC_DEBUG.should_not be_true
145 + @options.parse opt
146 + $MSPEC_DEBUG.should be_true
147 + $MSPEC_DEBUG = nil
148 + end
149 + end
150 +end
151 --
152 1.6.1.1
153