Module: Capybara::Presenter::Notifications
- Included in:
- InstanceMethods
- Defined in:
- lib/capybara/presenter/notifications.rb
Overview
Provides browser notification functionality for presenting test milestones. Injects JavaScript to display visual notifications during test execution. rubocop:disable Metrics/ModuleLength
Instance Method Summary collapse
- #presenter_milestone(title, message = nil) ⇒ Object
- #presenter_notification(title, message = nil, type: :info, duration: 4000) ⇒ Object
- #presenter_test_start_notification(test_class, test_method) ⇒ Object
Instance Method Details
#presenter_milestone(title, message = nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/capybara/presenter/notifications.rb', line 15 def presenter_milestone(title, = nil) return unless presenter_mode? presenter_notification("๐ #{title}", , type: :success, duration: 3000) presenter_delay(1.0) end |
#presenter_notification(title, message = nil, type: :info, duration: 4000) ⇒ Object
9 10 11 12 13 |
# File 'lib/capybara/presenter/notifications.rb', line 9 def presenter_notification(title, = nil, type: :info, duration: 4000) return unless presenter_mode? && presenter_notifications_enabled? show_browser_notification(title, , type, duration) end |
#presenter_test_start_notification(test_class, test_method) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/capybara/presenter/notifications.rb', line 22 def presenter_test_start_notification(test_class, test_method) return unless presenter_mode? && presenter_notifications_enabled? test_name = test_class.name.gsub(/Test$/, '') method_name = test_method.gsub(/^test_/, '').gsub('_', ' ').split.map(&:capitalize).join(' ') presenter_notification("๐งช #{test_name}", "Running: #{method_name}", type: :info, duration: 8000) puts "๐ Starting test: #{test_name} - #{method_name}" presenter_delay(Capybara::Presenter.configuration.test_start_delay) end |