Permalink
Browse files

Make sure runner uses supplied custom config

  • Loading branch information...
1 parent 7bbe18f commit 558c4f584a9ab9a3236c24e43eaf28913e5b06aa @robmitch robmitch committed Oct 7, 2009
Showing with 28 additions and 2 deletions.
  1. +2 −2 lib/roodi/core/runner.rb
  2. +25 −0 spec/roodi/core/runner_spec.rb
  3. +1 −0 spec/roodi/roodi.yml
View
4 lib/roodi/core/runner.rb
@@ -15,12 +15,12 @@ class Runner
def initialize(*checks)
@config = DEFAULT_CONFIG
@checks = checks unless checks.empty?
- @checks ||= load_checks
- @checker ||= CheckingVisitor.new(@checks)
@parser = Parser.new
end
def check(filename, content)
+ @checks ||= load_checks
+ @checker ||= CheckingVisitor.new(@checks)
node = parse(filename, content)
node.accept(@checker) if node
end
View
25 spec/roodi/core/runner_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+describe Roodi::Core::Runner do
+
+ describe "given a custom config file" do
+ before do
+ @runner = Roodi::Core::Runner.new
+ @runner.config= File.expand_path(File.dirname(__FILE__) + '/../roodi.yml')
+ end
+
+ it "uses check from it" do
+ # @runner.check_file(File.expand_path(File.dirname(__FILE__) + '/../fixtures/test_class.rb'))
+ content = <<-RUBY
+ class TestClass
+
+ def METHOD
+
+ end
+ end
+ RUBY
+ @runner.check_content(content)
+ @runner.errors.should be_empty
+ end
+ end
+end
View
1 spec/roodi/roodi.yml
@@ -0,0 +1 @@
+MethodNameCheck: { pattern: !ruby/regexp /^[A-Z]+$/ }

0 comments on commit 558c4f5

Please sign in to comment.