forked from josephholsten/rets4r
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b58825b
commit 31bdf65
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env ruby -w | ||
libdir = File.expand_path('../../lib', __FILE__) | ||
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) | ||
|
||
require "test/unit" | ||
|
||
class TestQuality < Test::Unit::TestCase | ||
def test_can_still_be_built | ||
Dir.chdir(root) do | ||
`gem build rets4r.gemspec` | ||
assert_equal 0, $? | ||
end | ||
end | ||
|
||
def test_has_no_malformed_whitespace | ||
error_messages = [] | ||
Dir.chdir(root) do | ||
File.read("MANIFEST").split("\n").each do |filename| | ||
error_messages << check_for_tab_characters(filename) | ||
error_messages << check_for_extra_spaces(filename) | ||
end | ||
end | ||
assert_well_formed error_messages.compact | ||
end | ||
|
||
def assert_well_formed(actual) | ||
assert actual.empty?, actual.join("\n") | ||
end | ||
|
||
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 | ||
|
||
def root | ||
File.expand_path("../..", __FILE__) | ||
end | ||
end |