Sha256: 2e94e1780b30dcadc95063e09246d2dc6c99c3310589de9bd2b50f6a98584649

Contents?: true

Size: 1.18 KB

Versions: 20

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe "The library itself" do
  Rspec::Matchers.define :have_no_tab_characters do
    match do |filename|
      @failing_lines = []
      File.readlines(filename).each_with_index do |line,number|
        @failing_lines << number + 1 if line =~ /\t/
      end
      @failing_lines.empty?
    end

    failure_message_for_should do |filename|
      "The file #{filename} has tab characters on lines #{@failing_lines.join(', ')}"
    end
  end

  Rspec::Matchers.define :have_no_extraneous_spaces do
    match do |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
      @failing_lines.empty?
    end

    failure_message_for_should do |filename|
      "The file #{filename} has spaces on the EOL on lines #{@failing_lines.join(', ')}"
    end
  end

  it "has no tab characters" do
    Dir.chdir(File.dirname(__FILE__) + '/..') do
      Dir.glob("./lib/**/*.rb").each do |filename|
        filename.should have_no_tab_characters
        filename.should have_no_extraneous_spaces
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
sinatra_auth_github-0.13.3 spec/quality_spec.rb
sinatra_auth_github-0.13.2 spec/quality_spec.rb
sinatra_auth_github-0.13.1 spec/quality_spec.rb
sinatra_auth_github-0.12.1 spec/quality_spec.rb
sinatra_auth_github-0.12.0 spec/quality_spec.rb
sinatra_auth_github-0.11.0 spec/quality_spec.rb
sinatra_auth_github-0.10.1 spec/quality_spec.rb
sinatra_auth_github-0.10.0 spec/quality_spec.rb
sinatra_auth_github-0.9.0 spec/quality_spec.rb
sinatra_auth_github-0.8.2 spec/quality_spec.rb
sinatra_auth_github-0.8.1 spec/quality_spec.rb
sinatra_auth_github-0.8.0 spec/quality_spec.rb
sinatra_auth_github-0.7.0 spec/quality_spec.rb
sinatra_auth_github-0.6.0 spec/quality_spec.rb
sinatra_auth_github-0.5.5 spec/quality_spec.rb
sinatra_auth_github-0.5.4 spec/quality_spec.rb
sinatra_auth_github-0.5.3 spec/quality_spec.rb
sinatra_auth_github-0.5.2 spec/quality_spec.rb
sinatra_auth_github-0.5.1 spec/quality_spec.rb
sinatra_auth_github-0.4.2 spec/quality_spec.rb