Permalink
Browse files

Added custom mspec guard engine_is.

  • Loading branch information...
1 parent 3fb11eb commit e6970e5aa15f43a28dab19b67c781dbcd711663e @brixen committed Oct 24, 2010
Showing with 27 additions and 0 deletions.
  1. +27 −0 spec/custom/guards/engine.rb
@@ -0,0 +1,27 @@
+class EngineGuard < SpecGuard
+ def match?
+ if defined?(RUBY_ENGINE)
+ @args.any? { |name| RUBY_ENGINE == name.to_s }
+ else
+ false
+ end
+ end
+end
+
+class Object
+ def engine_is(*names)
+ g = EngineGuard.new(*names)
+ g.name = :engine_is
+ yield if g.yield?
+ ensure
+ g.unregister
+ end
+
+ def engine_is_not(*names)
+ g = EngineGuard.new(*names)
+ g.name = :engine_is_not
+ yield if g.yield? true
+ ensure
+ g.unregister
+ end
+end

0 comments on commit e6970e5

Please sign in to comment.