flash_rails_messages 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FlashRailsMessages::Helper do
4
- let!(:subject){ ActionView::Base.new }
5
-
6
- describe '#render_flash_messages' do
7
- context 'when flash does not have messages' do
8
- it 'returns nothing' do
9
- allow(subject).to receive(:flash).and_return({})
10
- expect(subject.render_flash_messages).to eql('')
11
- end
12
- end
13
-
14
- context 'when flash has messages' do
15
- context 'when flash type is notice' do
16
- it 'returns the correct message' do
17
- allow(subject).to receive(:flash).and_return({ notice: 'notice' })
18
- alert_expected = alert_element('notice', 'info')
19
- expect(subject.render_flash_messages).to eql(alert_expected)
20
- end
21
- end
22
-
23
- context 'when flash type is success' do
24
- it 'returns the correct message' do
25
- allow(subject).to receive(:flash).and_return({ success: 'success' })
26
- alert_expected = alert_element('success', 'success')
27
- expect(subject.render_flash_messages).to eql(alert_expected)
28
- end
29
- end
30
-
31
- context 'when flash type is alert' do
32
- it 'returns the correct message' do
33
- allow(subject).to receive(:flash).and_return({ alert: 'alert' })
34
- alert_expected = alert_element('alert', 'error')
35
- expect(subject.render_flash_messages).to eql(alert_expected)
36
- end
37
- end
38
-
39
- context 'when flash type is error' do
40
- it 'returns the correct message' do
41
- allow(subject).to receive(:flash).and_return({ error: 'error' })
42
- alert_expected = alert_element('error', 'error')
43
- expect(subject.render_flash_messages).to eql(alert_expected)
44
- end
45
- end
46
-
47
- context 'when has more than one message' do
48
- it 'returns all the correct messages' do
49
- allow(subject).to receive(:flash).and_return({ alert: 'alert', notice: 'notice' })
50
- alerts_expected = alert_element('alert', 'error') +
51
- alert_element('notice', 'info')
52
- expect(subject.render_flash_messages).to eql(alerts_expected)
53
- end
54
- end
55
- end
56
- end
57
-
58
- def alert_element msg, klass
59
- subject.content_tag(:div, close_element + msg.html_safe, class: 'alert')
60
- end
61
-
62
- def close_element
63
- subject.content_tag(:a, '×'.html_safe, class: 'close', href: '#')
64
- end
65
- end
data/spec/spec_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
- require 'simplecov'
5
- SimpleCov.start
6
-
7
- require 'action_view'
8
- require 'flash_rails_messages'
9
- require 'rails/all'