Permalink
Browse files

ConversionObserver::Checker#run

Get files to check and either check/approve the files or, if none, do nothing and return nil.
  • Loading branch information...
1 parent a29a9ae commit 2b2bd42ec28b816cc4caa51af13c21ff5d23c545 @ymendel committed Jun 27, 2008
Showing with 59 additions and 7 deletions.
  1. +10 −0 lib/conversion_observer/checker.rb
  2. +49 −7 spec/checker_spec.rb
@@ -5,5 +5,15 @@ class Checker
def initialize
@files = {}
end
+
+ def run
+ files_to_check = ConversionObserver.files_to_check
+
+ unless files_to_check.empty?
+ okay_files = check_files(files_to_check)
+ approve_files(okay_files)
+ true
+ end
+ end
end
end
View
@@ -5,20 +5,62 @@
@checker = ConversionObserver::Checker.new
end
- it 'should run'
+ it 'should run' do
+ @checker.should respond_to(:run)
+ end
describe 'when run' do
- it 'should get files to check'
+ before :each do
+ @checker.stubs(:check_files)
+ @checker.stubs(:approve_files)
+ end
+
+ it 'should get files to check' do
+ ConversionObserver.expects(:files_to_check).returns([])
+ @checker.run
+ end
describe 'when there are files to check' do
- it 'should check files'
- it 'should approve the files that checked out okay'
- it 'should return true'
+ before :each do
+ @files = Array.new(3) { |i| stub("file #{i+1}") }
+ ConversionObserver.stubs(:files_to_check).returns(@files)
+ end
+
+ it 'should check files' do
+ @checker.expects(:check_files).with(@files)
+ @checker.run
+ end
+
+ it 'should approve the files that checked out okay' do
+ @okay_files = stub('okay files')
+ @checker.stubs(:check_files).returns(@okay_files)
+ @checker.expects(:approve_files).with(@okay_files)
+ @checker.run
+ end
+
+ it 'should return true' do
+ @checker.run.should be(true)
+ end
end
describe 'when there are no files to check' do
- it 'should return nil'
- it 'should not check files'
+ before :each do
+ ConversionObserver.stubs(:files_to_check).returns([])
+ end
+
+ it 'should return nil' do
+ @checker.run.should be_nil
+ end
+
+ it 'should not check files' do
+ @checker.expects(:check_files).never
+ @checker.run
+ end
+
+ it 'should not approve files' do
+ @checker.expects(:approve_files).never
+ @checker.run
+ end
end
end

0 comments on commit 2b2bd42

Please sign in to comment.