diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-01-01 00:42:56 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-01-13 19:34:58 +0300 |
commit | 5a1706791e46fd69a67fcdebfc384a702b00a7ff (patch) | |
tree | afc7d4f071946e3b4c5a0c066bd2a65407b059d4 /spec | |
parent | 8086b2bd2ecb0ff647da766c436eda47b7434599 (diff) |
Update broadcast_message helper
Now it returns the fully-formatted message so we can be consistent about
how it's shown.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/helpers/broadcast_messages_helper_spec.rb | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb index c7c6f45d144..0fb8a7284f3 100644 --- a/spec/helpers/broadcast_messages_helper_spec.rb +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -1,22 +1,40 @@ require 'spec_helper' describe BroadcastMessagesHelper do - describe 'broadcast_styling' do - let(:broadcast_message) { double(color: '', font: '') } + describe 'broadcast_message' do + it 'returns nil when no current message' do + expect(helper.broadcast_message(nil)).to be_nil + end + + it 'includes the current message' do + current = double(message: 'Current Message') + + allow(helper).to receive(:broadcast_message_style).and_return(nil) + + expect(helper.broadcast_message(current)).to include 'Current Message' + end + + it 'includes custom style' do + current = double(message: 'Current Message') + + allow(helper).to receive(:broadcast_message_style).and_return('foo') + + expect(helper.broadcast_message(current)).to include 'style="foo"' + end + end + + describe 'broadcast_message_style' do + it 'defaults to no style' do + broadcast_message = spy - context "default style" do - it "should have no style" do - expect(broadcast_styling(broadcast_message)).to eq '' - end + expect(helper.broadcast_message_style(broadcast_message)).to eq '' end - context "customized style" do - let(:broadcast_message) { double(color: "#f2dede", font: '#b94a48') } + it 'allows custom style' do + broadcast_message = double(color: '#f2dede', font: '#b94a48') - it "should have a customized style" do - expect(broadcast_styling(broadcast_message)). - to match('background-color: #f2dede; color: #b94a48') - end + expect(helper.broadcast_message_style(broadcast_message)). + to match('background-color: #f2dede; color: #b94a48') end end end |