Repository navigation
Expand file tree
/
Copy pathtest_run.rb
More file actions
42 lines (35 loc) 路 1.47 KB
/
Copy pathtest_run.rb
File metadata and controls
42 lines (35 loc) 路 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require "test_helper"
class LambdaConsoleTestRun < LambdaConsoleSpec
it 'pwd file context is top level gem directory' do
response = LambdaConsole::Run.handle(event('pwd'))
expect(response[:statusCode]).must_equal 0
expect(response[:headers]).must_equal({})
expect(response[:body]).must_match %r{\/lambda-console-ruby\n\z}
response = LambdaConsole::Run.handle(event('cat lib/lambda-console-ruby/version.rb'))
expect(response[:statusCode]).must_equal 0
expect(response[:headers]).must_equal({})
expect(response[:body]).must_match %r{#{LambdaConsole::VERSION}}
end
it 'non shell captureable errors due to command not existing' do
response = LambdaConsole::Run.handle(event('dirdoesnotexist'))
expect(response[:statusCode]).must_equal 1
expect(response[:headers]).must_equal({})
expect(response[:body]).must_match %r{No such file or directory}
end
it 'shell errors' do
response = LambdaConsole::Run.handle(event('cat /foo/bar'))
expect(response[:statusCode]).must_equal 1
expect(response[:headers]).must_equal({})
expect(response[:body]).must_match %r{cat.*No such file or directory}
end
it 'captures standard error' do
response = LambdaConsole::Run.handle(event('echo "This is a message" >&2'))
expect(response[:statusCode]).must_equal 0
expect(response[:headers]).must_equal({})
expect(response[:body]).must_match %r{This is a message}
end
private
def event(command)
super 'run', command
end
end