Sha256: 1b80b6edbe2e26d56c0aa01c53c9fcc63a5de341de7cb05b83f812a94d7218f3

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'

describe Object, "#language_version" do
  before :all do
    @ruby_version = Object.const_get :RUBY_VERSION

    Object.const_set :RUBY_VERSION, "8.2.3"

    dir = "#{File.expand_path('../', __FILE__)}/versions"
    @method82  = "#{dir}/method_8.2.rb"
    @method823 = "#{dir}/method_8.2.3.rb"
  end

  after :all do
    Object.const_set :RUBY_VERSION, @ruby_version
  end

  it "loads the most version-specific file if it exists" do
    File.should_receive(:exists?).with(@method823).and_return(true)
    should_receive(:require).with(@method823)
    language_version __FILE__, "method"
  end

  it "loads a less version-specific file if it exists" do
    File.should_receive(:exists?).with(@method823).and_return(false)
    File.should_receive(:exists?).with(@method82).and_return(true)
    should_receive(:require).with(@method82)
    language_version __FILE__, "method"
  end

  it "does not load the file if it does not exist" do
    File.should_receive(:exists?).with(@method82).and_return(false)
    File.should_receive(:exists?).with(@method823).and_return(false)
    should_not_receive(:require).with(@method82)
    should_not_receive(:require).with(@method823)
    language_version __FILE__, "method"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mspec-1.5.20 spec/helpers/language_version_spec.rb
mspec-1.5.19 spec/helpers/language_version_spec.rb
mspec-1.5.18 spec/helpers/language_version_spec.rb