Sha256: daa807a5c95f610dd4afadddc8f3e71af7bcacb9af8a7bfd03e4252c419f3ad9

Contents?: true

Size: 1.61 KB

Versions: 11

Compression:

Stored size: 1.61 KB

Contents

require "spec_helper"

if defined?(Encoding) && Encoding.default_external != "UTF-8"
  Encoding.default_external = "UTF-8"
end

describe "The library itself" do
  def check_for_tab_characters(filename)
    failing_lines = []
    File.readlines(filename).each_with_index do |line,number|
      failing_lines << number + 1 if line =~ /\t/
    end

    unless failing_lines.empty?
      "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
    end
  end

  def check_for_extra_spaces(filename)
    failing_lines = []
    File.readlines(filename).each_with_index do |line,number|
      next if line =~ /^\s+#.*\s+\n$/
      failing_lines << number + 1 if line =~ /\s+\n$/
    end

    unless failing_lines.empty?
      "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
    end
  end

  RSpec::Matchers.define :be_well_formed do
    failure_message_for_should do |actual|
      actual.join("\n")
    end

    match do |actual|
      actual.empty?
    end
  end

  it "has no malformed whitespace" do
    error_messages = []
    Dir.chdir(File.expand_path("../..", __FILE__)) do
      `git ls-files`.split("\n").each do |filename|
        next if filename =~ /\.gitmodules|\.marshal|fixtures|vendor/
        error_messages << check_for_tab_characters(filename)
        error_messages << check_for_extra_spaces(filename)
      end
    end
    expect(error_messages.compact).to be_well_formed
  end

  it "can still be built" do
    Dir.chdir(root) do
      `gem build bundler.gemspec`
      expect($?).to eq(0)

      # clean up the .gem generated
      system("rm bundler-#{Bundler::VERSION}.gem")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bundler-1.3.2 spec/quality_spec.rb
bundler-1.3.1 spec/quality_spec.rb
bundler-1.3.0 spec/quality_spec.rb
bundler-1.3.0.pre.8 spec/quality_spec.rb
bundler-1.3.0.pre.7 spec/quality_spec.rb
bundler-1.3.0.pre.6 spec/quality_spec.rb
bundler-1.3.0.pre.5 spec/quality_spec.rb
bundler-1.3.0.pre.4 spec/quality_spec.rb
bundler-1.3.0.pre.3 spec/quality_spec.rb
bundler-1.3.0.pre.2 spec/quality_spec.rb
bundler-1.3.0.pre spec/quality_spec.rb