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 :variant alert option' all_tests_pass_with 'the :dismissible alert option' all_tests_pass_with 'the :priority alert option' all_tests_pass_with 'the :size alert option' end #-- shared_examples_for 'no alert options' do specify 'sets the role and the class to "alert"' do html = '' expect(:alert_box).to generate html end end shared_examples_for 'extra alert options' do specify 'passes the options to the wrapping
' do options = {class: 'important', data: {value: 1}, id: 'my-alert'} html = '' expect(alert_box: options).to generate html end end shared_examples_for 'the :variant alert option' do Railsstrap::AlertBox.variants.each do |variant, variant_class| specify %Q{set to :#{variant}, adds the class "#{variant_class}"} do html = %Q{} expect(alert_box: {variant: variant.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 = '' expect(alert_box: {dismissible: false}).to generate html end specify 'set to true, displays a button to dismiss the alert' do html = %r{.*(class="close").*(dismiss="alert")} 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{.*(class="close").*(dismiss="alert")} expect(alert_box: {priority: :anything}).to generate html end specify 'set to :notice, adds the class "alert-success"' do html = %r{