Sha256: 035ece0e9d766a403f5412d44dbf6e0781e8980eae9615713214a411b873d099

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

require "spec_helper"

describe Lazier do
  describe ".is_ruby_18?" do
    it "it return true for Ruby 1.8" do
      original_ruby_version = RUBY_VERSION

      ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", "1.8.7") }
      expect(::Lazier.is_ruby_18?).to be_true
      ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", original_ruby_version) }
    end

    it "it return false otherwise" do
      original_ruby_version = RUBY_VERSION

      ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", "1.9.3") }
      expect(::Lazier.is_ruby_18?).to be_false
      ::Kernel::silence_warnings { Object.const_set("RUBY_VERSION", original_ruby_version) }
    end
  end

  describe ".load!" do
    describe "should load all extensions by default" do
      ::Lazier.load!

      it "for Boolean" do
        expect(true).to respond_to("value")
        expect(true).to respond_to("to_i")
      end

      it "for DateTime" do
        expect(::DateTime).to respond_to("custom_format")
        expect(::DateTime.now).to respond_to("lstrftime")
      end

      it "for Hash" do
        expect({:a => "b"}).to respond_to("a")
      end

      it "for Math" do
        expect(::Math).to respond_to("min")
      end

      it "for Object" do
        expect(0).to respond_to("debug_dump")
      end

      it "for Pathname" do
        expect(::Pathname.new($0)).to respond_to("components")
      end

      it "for String" do
        expect("").to respond_to("remove_accents")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lazier-1.0.4 spec/lazier_spec.rb
lazier-1.0.3 spec/lazier_spec.rb
lazier-1.0.2 spec/lazier_spec.rb
lazier-1.0.1 spec/lazier_spec.rb
lazier-1.0.0 spec/lazier_spec.rb