Sha256: ad05321c8ea67d720445f497aaa88ae6e8c97e390797a194930530d862b54da5
Contents?: true
Size: 1.67 KB
Versions: 15
Compression:
Stored size: 1.67 KB
Contents
require 'test_helper' module Components class CommandButtonTest < ActiveSupport::TestCase def assigns {} end def helpers mock_action_view do def twiddle_widget_path(id) "/widgets/#{id}/twiddle" end def trash_part_path(id) "/parts/#{id}/trash" end end end def command_button(*args) arbre(widget: widgets(:one)) { command_button(*args) } end test "command button creates a form with a submit button having the correct name" do assert_match /form.*action="\/widgets\/\d+\/twiddle"/, command_button(:twiddle, resource_name: :widget) assert_match /input type="submit" value="Twiddle"/, command_button(:twiddle, resource_name: :widget) end test "command button accepts a confirm parameter to display a prompt" do assert_match /input data-confirm="Are you sure\?" type="submit" value="Twiddle"/, command_button(:twiddle, resource_name: :widget, confirm: "Are you sure?") end def command_button_list_widget arbre(widget: widgets(:one)) { command_button_list(:widget) } end test "command_button_list creates a list of command buttons" do assert_match /ul class="command-button-list"/, command_button_list_widget assert_match /li.*<form.*\<\/li>/, command_button_list_widget.split("\n").join end def command_button_list_parts arbre(part: parts(:one)) { command_button_list(:part) } end test "command_button_list accepts confirm parameters" do assert_match /input data-confirm="Are you sure\?" type="submit" value="Trash"/, command_button_list_parts end end end
Version data entries
15 entries across 15 versions & 1 rubygems