@@ -60,16 +60,34 @@ def have_table_scopes(options = {})
6060 have_selector ( "#{ table_scopes_container_selector } > #{ table_scope_selector } " , **options )
6161 end
6262
63- # @param options [Hash]
64- # @option exact_text [String] title of scope
65- # @option counter [Integer,String,nil] counter value in brackets (nil if skipped)
66- # @option selected [Boolean] is scope active (default false)
67- def have_table_scope ( options = { } )
68- active = options . delete ( :active )
63+ # @param title [String, nil] exact title of scope to match.
64+ # @param selected [Boolean] whether to match selected (active) scope only (default false).
65+ # @param options [Hash] additional options passed to have_selector.
66+ def have_table_scope ( title = nil , selected : false , **options )
6967 selector = "#{ table_scopes_container_selector } > #{ table_scope_selector } "
70- selector = active ? "#{ selector } .selected" : "#{ selector } :not(.selected)"
68+ if title . nil?
69+ selector = selected ? "#{ selector } .selected" : "#{ selector } :not(.selected)"
70+ have_selector ( selector , **options )
71+ else
72+ selector = selected ? "#{ selector } .selected" : selector
73+ have_selector ( selector , exact_text : title . to_s , **options )
74+ end
75+ end
7176
72- have_selector ( selector , **options )
77+ # @param text [String] column header text.
78+ # @param options [Hash]
79+ # @option column [String, nil] column name override (defaults to text).
80+ # @option sortable [Boolean] whether the column is sortable.
81+ # @option sort_direction [String, nil] sort direction ('asc' or 'desc').
82+ # @example
83+ # expect(page).to have_table_header('Full Name')
84+ # expect(page).to have_table_header('Full Name', sortable: true)
85+ # expect(page).to have_table_header('Full Name', sort_direction: :asc)
86+ #
87+ def have_table_header ( text , options = { } )
88+ selector = table_header_selector ( text , options )
89+ opts = options . except ( :column , :sortable , :sort_direction ) . merge ( exact_text : text )
90+ have_selector ( selector , **opts )
7391 end
7492 end
7593 end
0 commit comments