spec/lib/mocks.rb in request-log-analyzer-1.2.9 vs spec/lib/mocks.rb in request-log-analyzer-1.3.0
- old
+ new
@@ -7,10 +7,11 @@
source.stub!(:skipped_requests).and_return(1)
source.stub!(:parse_lines).and_return(10)
source.stub!(:warning=)
source.stub!(:progress=)
+ source.stub!(:source_changes=)
source.stub!(:prepare)
source.stub!(:finalize)
source.stub!(:each_request).and_return do |block|
@@ -41,18 +42,29 @@
output.stub!(:table).and_yield([])
output.stub!(:io).and_return(mock_io)
return output
end
- def mock_migrator
+ def mock_database(*stubs)
+ database = mock('RequestLogAnalyzer::Database')
+ database.stub!(:connect)
+ database.stub!(:disconnect)
+ database.stub!(:connection).and_return(mock_connection)
+ stubs.each { |s| database.stub!(s)}
+ return database
+ end
+
+ def mock_connection
table_creator = mock('ActiveRecord table creator')
table_creator.stub!(:column)
- migrator = mock('ActiveRecord::Base.connection for migrations')
- migrator.stub!(:add_index)
- migrator.stub!(:create_table).and_yield(table_creator).and_return(true)
- migrator.stub!(:table_creator).and_return(table_creator)
- return migrator
+ connection = mock('ActiveRecord::Base.connection')
+ connection.stub!(:add_index)
+ connection.stub!(:remove_index)
+ connection.stub!(:table_exists?).and_return(false)
+ connection.stub!(:create_table).and_yield(table_creator).and_return(true)
+ connection.stub!(:table_creator).and_return(table_creator)
+ return connection
end
end
\ No newline at end of file