|
3 | 3 | require 'spec_helper' |
4 | 4 | require 'file_handler' |
5 | 5 |
|
6 | | -describe FileHandler do |
| 6 | +describe 'FileHandler - Validations' do |
7 | 7 | let(:basic_log_path) { 'spec/fixtures/basic.log' } |
| 8 | + let(:complex_log_path) { 'spec/fixtures/webserver.log' } |
8 | 9 | subject(:options) { { file_path: log_path } } |
9 | | - subject(:call_scope) { described_class.new(options).call } |
| 10 | + subject(:call_scope) { FileHandler.new(options).call } |
10 | 11 | subject(:result) { call_scope } |
11 | 12 |
|
12 | | - context 'data collect' do |
| 13 | + context 'with a simple file' do |
13 | 14 | let(:log_path) { basic_log_path } |
14 | 15 | subject(:result_first) { result['/help_page/1'] } |
15 | 16 |
|
16 | | - it 'count hits and uniques' do |
| 17 | + it 'collect data' do |
17 | 18 | expect(result_first[:hits]).to eq 3 |
18 | 19 | expect(result_first[:uniques]).to eq 1 |
19 | 20 | end |
20 | 21 | end |
21 | 22 |
|
22 | | - context 'validations' do |
23 | | - let(:log_path) { '' } |
24 | | - subject(:first_error) { result[:errors][0] } |
| 23 | + context 'with a complex file' do |
| 24 | + let(:log_path) { complex_log_path } |
| 25 | + subject(:result_home) { result['/home'] } |
25 | 26 |
|
26 | | - it 'no filepath' do |
27 | | - expect(first_error[:message]).to eq 'Please provide a file to be analysed.' |
28 | | - end |
29 | | - |
30 | | - it 'empty file' do |
31 | | - options[:file_path] = 'spec/fixtures/empty.log' |
32 | | - expect(first_error[:message]).to eq 'File is empty.' |
33 | | - end |
34 | | - |
35 | | - it 'empty lines' do |
36 | | - options[:file_path] = 'spec/fixtures/with-empty-lines.log' |
37 | | - expect(first_error[:message]).to eq 'File have empty lines.' |
38 | | - end |
39 | | - |
40 | | - it 'malformed lines' do |
41 | | - options[:file_path] = 'spec/fixtures/malformed-lines.log' |
42 | | - expect(first_error[:message]).to eq 'File have malformed lines.' |
| 27 | + it 'collect data' do |
| 28 | + expect(result_home[:hits]).to eq 78 |
| 29 | + expect(result_home[:uniques]).to eq 23 |
43 | 30 | end |
44 | 31 | end |
45 | 32 | end |
0 commit comments