flash_rails_messages 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +9 -18
- data/.rspec +1 -0
- data/.travis.yml +8 -5
- data/Appraisals +4 -8
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -6
- data/LICENSE.txt +17 -18
- data/README.md +32 -13
- data/Rakefile +3 -7
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/flash_rails_messages.gemspec +19 -10
- data/gemfiles/rails_5.2.gemfile +1 -4
- data/gemfiles/rails_5.2.gemfile.lock +90 -95
- data/gemfiles/{rails_4.gemfile → rails_6.0.gemfile} +1 -4
- data/gemfiles/rails_6.0.gemfile.lock +181 -0
- data/lib/flash_rails_messages/version.rb +1 -1
- data/lib/generators/flash_rails_messages/templates/config/initializers/flash_rails_messages_bootstrap.rb +2 -2
- data/lib/generators/flash_rails_messages/templates/config/initializers/flash_rails_messages_foundation.rb +1 -1
- metadata +80 -25
- data/gemfiles/rails_4.gemfile.lock +0 -155
- data/gemfiles/rails_5.gemfile +0 -10
- data/gemfiles/rails_5.gemfile.lock +0 -162
- data/spec/flash_rails_messages_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -9
@@ -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
|