Class: Waylon::RSpec::TestMessage
- Inherits:
-
Object
- Object
- Waylon::RSpec::TestMessage
- Includes:
- Message
- Defined in:
- lib/waylon/rspec/test_message.rb
Overview
A test Message class
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
-
.all ⇒ Array<TestMessage>
Simple way to list all TestMessages.
Instance Method Summary collapse
-
#author ⇒ TestUser
Provides the user that authored the message.
-
#channel ⇒ TestChannel
The TestChannel where this TestMessage lives.
-
#created_at ⇒ Time
Easy access to when the TestMessage was created.
-
#details ⇒ Hash
private
Lazily provides the details for TestMessages.
-
#initialize(message_id, details = {}) ⇒ TestMessage
constructor
A new instance of TestMessage.
-
#private_message? ⇒ Boolean
Is this a private message?.
-
#text ⇒ String
(also: #body)
The Message content.
Methods included from Message
#mentions_bot?, #private?, #to_bot?
Constructor Details
#initialize(message_id, details = {}) ⇒ TestMessage
Returns a new instance of TestMessage.
19 20 21 22 |
# File 'lib/waylon/rspec/test_message.rb', line 19 def initialize(, details = {}) @id = .to_i @details = details end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/waylon/rspec/test_message.rb', line 9 def id @id end |
Class Method Details
.all ⇒ Array<TestMessage>
Simple way to list all TestMessages
13 14 15 |
# File 'lib/waylon/rspec/test_message.rb', line 13 def self.all TestSense..each_index.map { |id| new(id) } end |
Instance Method Details
#author ⇒ TestUser
Provides the user that authored the message
26 27 28 |
# File 'lib/waylon/rspec/test_message.rb', line 26 def TestUser.new(details[:user_id]) end |
#channel ⇒ TestChannel
The TestChannel where this TestMessage lives
44 45 46 |
# File 'lib/waylon/rspec/test_message.rb', line 44 def channel TestChannel.new(details[:channel_id]) end |
#created_at ⇒ Time
Easy access to when the TestMessage was created
32 33 34 |
# File 'lib/waylon/rspec/test_message.rb', line 32 def created_at details[:created_at] end |
#details ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lazily provides the details for TestMessages
59 60 61 62 |
# File 'lib/waylon/rspec/test_message.rb', line 59 def details @details = TestSense.[id] if @details.empty? @details.dup end |
#private_message? ⇒ Boolean
Is this a private message?
38 39 40 |
# File 'lib/waylon/rspec/test_message.rb', line 38 def details[:type] == :private end |
#text ⇒ String Also known as: body
The Message content
50 51 52 |
# File 'lib/waylon/rspec/test_message.rb', line 50 def text details[:text] end |