shared_examples_for 'the alert_box helper' do
all_tests_pass_with 'no alert options'
all_tests_pass_with 'extra alert options'
all_tests_pass_with 'the :context alert option'
all_tests_pass_with 'the :dismissible alert option'
all_tests_pass_with 'the :priority alert option'
end
#--
shared_examples_for 'no alert options' do
specify 'sets the role and the class to "alert"' do
html = '
' do
options = {class: 'important', data: {value: 1}, id: 'my-alert'}
html = '
content
'
expect(alert_box: options).to generate html
end
end
shared_examples_for 'the :context alert option' do
Bh::AlertBox.contexts.each do |context, context_class|
specify %Q{set to :#{context}, adds the class "#{context_class}"} do
html = %Q{
content
}
expect(alert_box: {context: context.to_s}).to generate html
end
end
end
shared_examples_for 'the :dismissible alert option' do
specify 'set to false, does not display a button to dismiss the alert' do
html = '
content
'
expect(alert_box: {dismissible: false}).to generate html
end
specify 'set to true, displays a button to dismiss the alert' do
html = %r{
×}
expect(alert_box: {dismissible: true}).to generate html
end
end
shared_examples_for 'the :priority alert option' do
specify 'set, displays a button to dismiss the alert' do
html = %r{
×}
expect(alert_box: {priority: :anything}).to generate html
end
specify 'set to :notice, adds the class "alert-success"' do
html = %r{
}
expect(alert_box: {priority: :notice}).to generate html
end
specify 'set to :alert, adds the class "alert-danger"' do
html = %r{
}
expect(alert_box: {priority: :alert}).to generate html
end
end