Skip to content

Commit

Permalink
fix timing on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRuiz committed Feb 19, 2021
1 parent 1d9f47d commit 4d32c0d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spec/slack/smart-bot/commands/general/bot_help_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
expect(buffer(to: channel, from: :ubot).join).not_to match(@master_admin)
expect(buffer(to: channel, from: :ubot).join).not_to match(@direct)
expect(buffer(to: channel, from: :ubot).join).not_to match(@without_bot)
expect(buffer(to: channel, from: :ubot).join).not_to match(@rules) #not expanded
expect(buffer(to: channel, from: :ubot).join).to match(@rules)
end
end
describe "bot channel" do
Expand Down Expand Up @@ -138,7 +138,7 @@
expect(buffer(to: channel, from: :ubot).join).not_to match(@master_admin)
expect(buffer(to: channel, from: :ubot).join).not_to match(@direct)
expect(buffer(to: channel, from: :ubot).join).not_to match(@without_bot)
expect(buffer(to: channel, from: :ubot).join).not_to match(@rules) #not expanded
expect(buffer(to: channel, from: :ubot).join).to match(@rules)
end
it "responds to normal user in master channel" do
send_message "bot rules expanded", from: :user2, to: channel
Expand Down
6 changes: 4 additions & 2 deletions spec/slack/smart-bot/commands/on_bot/add_shortcut_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
end
it "can modify a shortcut added by yourself" do
send_message "!shortcut example: echo Text", from: user, to: channel
sleep 1
send_message "!shortcut example: echo Text2", from: user, to: channel
sleep 1
message = "The shortcut already exists, are you sure you want to overwrite it?"
expect(bufferc(to: channel, from: :ubot)[-1]).to match(/#{message}/)
send_message "yes", from: user, to: channel
Expand All @@ -99,7 +101,7 @@
it "cannot modify a shortcut for all added by other" do
send_message "!shortcut for all example: echo Text", from: :uadmin, to: channel
send_message "!shortcut for all example: echo Text2", from: user, to: channel
sleep 1
sleep 2
message = "Only the creator of the shortcut can modify it"
expect(buffer(to: channel, from: :ubot)[-1]).to match(/#{message}/)
end
Expand All @@ -113,7 +115,7 @@
it "calls shortcut on inline command" do
send_message "!shortcut example: This is a text to display", from: user, to: channel
send_message "!echo $example", from: user, to: channel
sleep 2
sleep 3
expect(buffer(to: channel, from: :ubot)[-1]).to match(/^This is a text to display$/)
end
it "calls two shortcuts on inline command" do
Expand Down
3 changes: 2 additions & 1 deletion spec/slack/smart-bot/commands/on_bot/delete_shortcut_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

after(:each) do
send_message "bye bot", from: user, to: channel
sleep 1
end

it "works: delete shortcut on demand" do
Expand Down Expand Up @@ -115,7 +116,7 @@
sleep 1
expect(buffer(to: channel, from: :ubot).join).to match(/global shortcut deleted!/i)
send_message "!exampleglobaldel", from: user, to: channel
sleep 1
sleep 4
expect(buffer(to: channel, from: :ubot).join).to match(/I don't understand/i)
send_message "!exampleglobaldel", from: user, to: :cbot1cm
sleep 1
Expand Down
4 changes: 3 additions & 1 deletion spec/slack/smart-bot/commands/on_bot/run_repl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
send_message "bye", from: user, to: channel
clean_buffer()
send_message "!run repl runreplexe", from: user, to: channel
sleep 2
expect(buffer(to: channel, from: :ubot).join).to match(/done/i)
end

Expand All @@ -22,6 +23,7 @@
send_message "bye", from: user, to: channel
clean_buffer()
send_message "!run repl runreplexe2 PARAM='xxxx'", from: user, to: channel
sleep 2
expect(buffer(to: channel, from: :ubot).join).to match(/xxxx/i)
end

Expand All @@ -31,8 +33,8 @@
send_message "bye", from: :user2, to: channel
clean_buffer()
send_message "!run repl runreplexePrivate", from: user, to: channel
sleep 3
expect(buffer(to: channel, from: :ubot).join).not_to match(/done/i)
sleep 1
expect(buffer(to: channel, from: :ubot).join).to match(/The REPL with session name: runreplexePrivate is private/)
end

Expand Down
2 changes: 2 additions & 0 deletions spec/slack/smart-bot/commands/on_bot/see_repls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
send_message "bye", from: :user2, to: channel
send_message "!repl seerepl5 ", from: :user2, to: channel
send_message "bye", from: :user2, to: channel
sleep 2
end
after(:all) do
send_message "bye bot", from: user, to: channel
end

it 'list all public repls' do
send_message "!see repls", from: user, to: channel
sleep 2
expect(buffer(to: channel, from: :ubot).join).to match(/\(public\) \*seerepl1\*/i)
expect(buffer(to: channel, from: :ubot).join).to match(/\(public_clean\) \*seerepl2\*/i)
expect(buffer(to: channel, from: :ubot).join).to match(/\(public\) \*seerepl5\*/i)
Expand Down
2 changes: 1 addition & 1 deletion spec/slack/smart-bot/commands/on_bot/see_shortcuts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
send_message "!add global sc exampleglobalsee: echo Text", from: user, to: :cmaster
sleep 1
send_message "!see shortcuts", from: user, to: channel
sleep 1
sleep 2
expect(buffer(to: channel, from: :ubot).join).to match(/exampleglobalsee \(global\): echo Text/)
end

Expand Down

0 comments on commit 4d32c0d

Please sign in to comment.