File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ def tail(path, opts = {})
35
35
end
36
36
37
37
def read_file_chunk ( path , start_line , end_line )
38
- if start_line . instance_of? ( Integer ) || end_line . instance_of? ( Integer ) ||
39
- start_line > end_line || start_line . negative?
38
+ if ! start_line . instance_of? ( Integer ) || ! end_line . instance_of? ( Integer ) ||
39
+ start_line > end_line || start_line . negative? || end_line . negative?
40
40
raise ArgumentError , 'Invalid start or end'
41
41
end
42
42
Original file line number Diff line number Diff line change 74
74
expect ( result . data ) . to eq ( [ 'a' , 'file!' ] )
75
75
end
76
76
77
+ it 'reads a chunk of text from a file' do
78
+ file = host . file ( "#{ spec_dir } /test-file-chunk.txt" )
79
+ file . touch
80
+ file . append do |f |
81
+ f << 'This'
82
+ f << 'is'
83
+ f << 'is'
84
+ f << 'a'
85
+ f << 'file'
86
+ f << 'forever...'
87
+ end
88
+
89
+ result = host . read_file_chunk ( "#{ spec_dir } /test-file-chunk.txt" , 2 , 4 )
90
+ expect ( result ) . to be_success
91
+ expect ( result . data . length ) . to eq ( 3 )
92
+ expect ( result . data ) . to eq ( [ 'is' , 'is' , 'a' ] )
93
+ end
94
+
77
95
it 'cats a file' do
78
96
result = host . cat ( '/etc/group' )
79
97
expect ( result . success? ) . to eq ( true )
You can’t perform that action at this time.
0 commit comments