Sha256: 8add7f52fec51bb2116d1ceceaf79d3e19603a4c0572ac3d8e3b83da151c269e

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'bundler'

describe Bundler do
  describe "#load_gemspec_uncached" do
    it "should catch Psych syntax errors" do
      gemspec = <<-GEMSPEC
{:!00 ao=gu\g1= 7~f
GEMSPEC
      File.open(tmp("test.gemspec"), 'wb') do |file|
        file.puts gemspec
      end

      proc {
        Bundler.load_gemspec_uncached(tmp("test.gemspec"))
      }.should raise_error(Bundler::GemspecError)
    end

    it "can load a gemspec with unicode characters with default ruby encoding" do
      # spec_helper forces the external encoding to UTF-8 but that's not the
      # ruby default.
      encoding = nil

      if defined?(Encoding)
        encoding = Encoding.default_external
        Encoding.default_external = "ASCII"
      end

      File.open(tmp("test.gemspec"), "wb") do |file|
        file.puts <<-G.gsub(/^\s+/, '')
          # -*- encoding: utf-8 -*-
          Gem::Specification.new do |gem|
            gem.author = "André the Giant"
          end
        G
      end

      gemspec = Bundler.load_gemspec_uncached(tmp("test.gemspec"))
      gemspec.author.should == "André the Giant"

      Encoding.default_external = encoding if defined?(Encoding)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bundler-1.2.5 spec/bundler/bundler_spec.rb
bundler-1.2.4 spec/bundler/bundler_spec.rb