spec/lib/helpers.rb in request-log-analyzer-1.12.5 vs spec/lib/helpers.rb in request-log-analyzer-1.12.6

- old
+ new

@@ -8,10 +8,15 @@ # Load a log file from the fixture folder def log_fixture(name, extention = "log") File.dirname(__FILE__) + "/../fixtures/#{name}.#{extention}" end + # directory of logs + def log_directory_fixture(name) + File.dirname(__FILE__) + "/../fixtures/#{name}" + end + # Creates a log file given some lines def log_snippet(*lines) StringIO.new(lines.join("\n") << "\n") end @@ -47,16 +52,16 @@ # Return a filename that can be used as temporary file in specs def temp_output_file(file_type) File.expand_path("#{File.dirname(__FILE__)}/../../tmp/spec.#{file_type}.tmp") end - + # Check if a given string can be found in the given file # Returns the line number if found, nil otherwise def find_string_in_file(string, file, options = {}) return nil unless File.exists?(file) - + line_counter = 0 File.open( file ) do |io| io.each {|line| line_counter += 1 @@ -64,9 +69,9 @@ p line if options[:debug] return line_counter if line.include? string } end - + return nil end end