Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed mSpec's ci runner filter explosion.

Changed mSpec runner back to using #call on blocks
rather than instance_eval. Thanks to headius for pointing
out how to override #include at the top level.
  • Loading branch information...
commit 8990e4edde5fbcd9facc8b834a134ea15da23b4a 1 parent a33af5b
@brixen brixen authored
View
2  .gitignore
@@ -13,7 +13,7 @@ tags
tmtags
*.rbc
.spec/bm.yml
-spec/files.txt
+spec/core/kernel/fixtures/load/load_spec_rba.rba
tmp
scratch
!runtime/stable/loader.rbc
View
2  mspec/matchers/include.rb
@@ -23,7 +23,7 @@ def negative_failure_message
end
end
-class Object
+class << self
def include(*expected)
IncludeMatcher.new(*expected)
end
View
21 mspec/runner/runner.rb
@@ -24,9 +24,7 @@ def it
class SpecRunner
def initialize(formatter=nil)
- @only = []
- @except = []
- @env = Object.new
+ clear_filters
@stack = []
@formatter = formatter
if @formatter.nil?
@@ -72,6 +70,11 @@ def except(*args)
@except.concat convert_to_regexps(*args)
end
+ def clear_filters
+ @only = []
+ @except = []
+ end
+
def skip?(example)
@except.each { |re| return true if re.match(example) }
return false if @only.empty?
@@ -109,21 +112,21 @@ def describe(*args, &block)
formatter.before_describe(dmsg)
begin
- @env.instance_eval &block
+ block.call
- @stack.last.before_all.each { |ba| @env.instance_eval &ba }
+ @stack.last.before_all.each { |ba| ba.call }
@stack.last.it.each do |msg, b|
unless skip?("#{dmsg} #{msg}")
formatter.before_it(msg)
begin
begin
- @stack.last.before_each.each { |be| @env.instance_eval &be }
- @env.instance_eval &b
+ @stack.last.before_each.each { |be| be.call }
+ b.call
Mock.verify_count
rescue Exception => e
formatter.exception(e)
ensure
- @stack.last.after_each.each { |ae| @env.instance_eval &ae }
+ @stack.last.after_each.each { |ae| ae.call }
Mock.cleanup
end
rescue Exception => e
@@ -133,7 +136,7 @@ def describe(*args, &block)
end
end
ensure
- @stack.last.after_all.each { |aa| @env.instance_eval &aa }
+ @stack.last.after_all.each { |aa| aa.call }
Mock.cleanup
end
View
1  mspec/scripts/ci.rb
@@ -162,6 +162,7 @@ def read_excludes(file)
STDERR.print "," if #{status}
load file
formatter.summary
+ spec_runner.clear_filters
%s
end
STDERR.puts "" if #{status}
View
19 mspec/spec/matchers/output_spec.rb
@@ -20,18 +20,16 @@
matcher = OutputMatcher.new("expected", "error")
matcher.matches?(proc)
matcher.failure_message.should ==
- ["Expected:\n $stdout: expected\n $stderr: error\n",
- " got:\n $stdout: unexpected\n $stderr: unerror\n"]
+ ["Expected:\n $stdout: \"expected\"\n $stderr: \"error\"\n",
+ " got:\n $stdout: \"unexpected\"\n $stderr: \"unerror\"\n"]
matcher = OutputMatcher.new("expected", nil)
matcher.matches?(proc)
matcher.failure_message.should ==
- ["Expected:\n $stdout: expected\n",
- " got:\n $stdout: unexpected\n"]
+ ["Expected:\n $stdout: \"expected\"\n", " got:\n $stdout: \"unexpected\"\n"]
matcher = OutputMatcher.new(nil, "error")
matcher.matches?(proc)
matcher.failure_message.should ==
- ["Expected:\n $stderr: error\n",
- " got:\n $stderr: unerror\n"]
+ ["Expected:\n $stderr: \"error\"\n", " got:\n $stderr: \"unerror\"\n"]
end
it "provides a useful negative failure message" do
@@ -39,17 +37,14 @@
matcher = OutputMatcher.new("expected", "error")
matcher.matches?(proc)
matcher.negative_failure_message.should ==
- ["Expected output not to be:\n",
- " $stdout: expected\n $stderr: error\n"]
+ ["Expected output not to be:\n", " $stdout: \"expected\"\n $stderr: \"error\"\n"]
matcher = OutputMatcher.new("expected", nil)
matcher.matches?(proc)
matcher.negative_failure_message.should ==
- ["Expected output not to be:\n",
- " $stdout: expected\n"]
+ ["Expected output not to be:\n", " $stdout: \"expected\"\n"]
matcher = OutputMatcher.new(nil, "error")
matcher.matches?(proc)
matcher.negative_failure_message.should ==
- ["Expected output not to be:\n",
- " $stderr: error\n"]
+ ["Expected output not to be:\n", " $stderr: \"error\"\n"]
end
end
View
10 mspec/spec/runner/runner_spec.rb
@@ -51,6 +51,16 @@ module Mock; end
@runner.except('a', 'b', 'c').should == [/a/, /b/, /c/]
end
+ it "provides #clear_filters that removes any #except and #only filters" do
+ @runner.only('a', 'b', 'c').should == [/a/, /b/, /c/]
+ @runner.only('d').should == [/a/, /b/, /c/, /d/]
+ @runner.except('a', 'b', 'c').should == [/a/, /b/, /c/]
+ @runner.except('d').should == [/a/, /b/, /c/, /d/]
+ @runner.clear_filters
+ @runner.only('a').should == [/a/]
+ @runner.except('a').should == [/a/]
+ end
+
it "provides #skip? that returns true if current spec full message matches an except element" do
@runner.except('this one')
@runner.skip?('this one').should == true
Please sign in to comment.
Something went wrong with that request. Please try again.