-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding shared_examples for rich_text_elements
- Loading branch information
1 parent
8661b0c
commit 443b213
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
spec/lib/slack/block_kit/layout/rich_text/rich_text_elements_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.shared_examples 'rich text element: channel' do |klass| | ||
describe '#channel' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'channel', channel_id: 'AAAAAAAAA' }] | ||
elements = klass.channel(channel_id: 'AAAAAAAAA').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end | ||
|
||
RSpec.shared_examples 'rich text element: emoji' do |klass| | ||
describe '#emoji' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'emoji', name: 'wave' }] | ||
elements = klass.emoji(name: 'wave').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end | ||
|
||
RSpec.shared_examples 'rich text element: link' do |klass| | ||
describe '#link' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'link', url: 'https://github.com' }] | ||
elements = klass.link(url: 'https://github.com').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end | ||
|
||
RSpec.shared_examples 'rich text element: text' do |klass| | ||
describe '#text' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'text', text: 'Some text' }] | ||
elements = klass.text(text: 'Some text').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end | ||
|
||
RSpec.shared_examples 'rich text element: user' do |klass| | ||
describe '#user' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'user', user_id: 'AAAAAAAAA' }] | ||
elements = klass.user(user_id: 'AAAAAAAAA').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end | ||
|
||
RSpec.shared_examples 'rich text element: usergroup' do |klass| | ||
describe '#usergroup' do | ||
it 'correctly serializes' do | ||
expected_json = [{ type: 'usergroup', usergroup_id: 'AAAAAAAAA' }] | ||
elements = klass.usergroup(usergroup_id: 'AAAAAAAAA').as_json[:elements] | ||
|
||
expect(elements).to match(expected_json) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters