You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mattermost_client_spec.rb 1.1KB

12345678910111213141516171819202122232425262728293031323334
  1. require "dotenv/load"
  2. require "slack_mattermost_emoji/mattermost_client"
  3. RSpec.describe SlackMattermostEmoji::MattermostClient do
  4. it 'should raise if credentials are missing' do
  5. expect do
  6. SlackMattermostEmoji::MattermostClient.new(
  7. username: '',
  8. password: '',
  9. domain: '',
  10. )
  11. end.to raise_error('Mattermost username, password, and domain are all required')
  12. end
  13. it 'should be able to log in to mattermost using the provided credentials' do
  14. client = SlackMattermostEmoji::MattermostClient.new(
  15. username: ENV['MATTERMOST_USERNAME'],
  16. password: ENV['MATTERMOST_PASSWORD'],
  17. domain: ENV['MATTERMOST_DOMAIN'],
  18. )
  19. client.authenticate
  20. expect(client.authenticated?).to be true
  21. end
  22. it 'should handle a bad credentials error' do
  23. client = SlackMattermostEmoji::MattermostClient.new(
  24. username: ENV['MATTERMOST_USERNAME'],
  25. password: 'wrongpassword',
  26. domain: ENV['MATTERMOST_DOMAIN'],
  27. )
  28. expect { client.authenticate }.to raise_error('Invalid Mattermost credentials')
  29. end
  30. end