Permalink
Browse files

Wrap RUBY_VERSION in stubbable method.

  • Loading branch information...
1 parent 8939287 commit e55da84496afbef74331961e345b4af68c47ade8 @dchelimsky committed Dec 18, 2008
Showing with 12 additions and 4 deletions.
  1. +1 −0 lib/spec.rb
  2. +1 −1 lib/spec/dsl/main.rb
  3. +9 −0 lib/spec/ruby.rb
  4. +1 −3 spec/spec/dsl/main_spec.rb
View
@@ -4,3 +4,4 @@
require 'spec/runner'
require 'spec/version'
require 'spec/dsl'
+require 'spec/ruby'
@@ -20,7 +20,7 @@ module Main
# register special implementations.
#
def describe(*args, &block)
- if (RUBY_VERSION.to_f == 1.9) && self.class.to_s == "Module"
+ if (Spec::Ruby.version.to_f == 1.9) && self.class.to_s == "Module"
original_block = block
context = self
block = lambda {include context;instance_eval(&original_block)}
View
@@ -0,0 +1,9 @@
+module Spec
+ module Ruby
+ class << self
+ def version
+ RUBY_VERSION
+ end
+ end
+ end
+end
@@ -33,8 +33,7 @@ module DSL
describe "#describe; with RUBY_VERSION = 1.9" do
it "should include an enclosing module into the block's scope" do
- v = RUBY_VERSION
- RUBY_VERSION = "1.9"
+ Spec::Ruby.stub!(:version).and_return("1.9")
class ::Module
alias_method :original_included, :included
def included(mod)
@@ -54,7 +53,6 @@ module Bar
$mod = nil
$in_block = nil
$foo_bar_included = nil
- RUBY_VERSION = v
class ::Module
alias_method :included, :original_included
remove_method :original_included

0 comments on commit e55da84

Please sign in to comment.