Skip to content

Commit 5dc27dd

Browse files
committed
Adding fail tests
1 parent fd8b152 commit 5dc27dd

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

lib/connector/test.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,48 @@ class Runtime
1414
attr_accessor :responses, :last_message
1515

1616
def expect_log(message)
17-
expect_hash({}, type:'log', message:message)
17+
expect_hash(type:'log', message:message)
1818
end
1919

2020
def expect_info(message)
21-
expect_hash({}, type:'log', status:'info', message:message)
21+
expect_hash(type:'log', status:'info', message:message)
2222
end
2323

2424
def expect_warn(message)
25-
expect_hash({}, type:'log', status:'warn', message:message)
25+
expect_hash(type:'log', status:'warn', message:message)
2626
end
2727

2828
def expect_error(message)
29-
expect_hash({}, type:'log', status:'error', message:message)
29+
expect_hash(type:'log', status:'error', message:message)
3030
end
3131

3232
def expect_response(data={})
33-
expect_hash({}, type:'response', data:data)
33+
expect_hash(type:'response', data:data)
3434
end
3535

36-
def expect_hash(options={}, hash)
36+
def expect_fail(message=nil)
37+
hash = {type:'fail'}
38+
hash[:message] = message if message
39+
expect_hash(hash)
40+
end
41+
42+
def expect_hash(hash={})
3743
set_callback
3844

39-
eventually(options) do
45+
eventually do
4046
expect(@responses).to include( a_hash_including(hash) )
4147
end
4248
end
4349

50+
def expect_eventually(options, something)
51+
set_callback
52+
53+
options={}
54+
eventually(options) do
55+
expect(@responses).to include( something )
56+
end
57+
end
58+
4459
private
4560

4661
def set_callback

spec/connectors/runtime_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ def initialize
4646
end
4747

4848
it 'can fail an action' do
49-
# expect {
50-
# @runtime.run([:action_fail])
51-
# }.to raise_error(Factor::Connector::Error)
49+
@runtime.run([:action_fail], foo:'bar')
50+
@runtime.expect_fail('Something broke')
5251
end
5352

5453
end

0 commit comments

Comments
 (0)