From b4f4b6a02190a9672121ebe038ddcbe0c29563c8 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Thu, 1 Jul 2021 20:11:16 +0900 Subject: [PATCH] add option test --- spec/form/option_spec.cr | 35 +++++++++++++++++++++++++++ spec/form/select_list_spec.cr | 45 ----------------------------------- 2 files changed, 35 insertions(+), 45 deletions(-) create mode 100644 spec/form/option_spec.cr delete mode 100644 spec/form/select_list_spec.cr diff --git a/spec/form/option_spec.cr b/spec/form/option_spec.cr new file mode 100644 index 0000000..8540b7f --- /dev/null +++ b/spec/form/option_spec.cr @@ -0,0 +1,35 @@ +require "../spec_helper" + +WebMock.stub(:get, "example.com/form/multi_select_list").to_return(body: +<<-BODY + + + page_title + + +
+ +
+ + +BODY +) + +describe "Form Fields Multiple Select List Option" do + agent = Mechanize.new + page = agent.get("http://example.com/form/multi_select_list") + form = page.forms[0] + selectbox = form.selectboxes[0] + + it "can be clicked multiple option" do + selectbox.values.empty?.should eq true + option1 = selectbox.options[0].click + selectbox.values.should eq ["dog"] + option2 = selectbox.options[1].click + selectbox.values.should eq ["dog", "cat"] + end +end diff --git a/spec/form/select_list_spec.cr b/spec/form/select_list_spec.cr deleted file mode 100644 index 2c63995..0000000 --- a/spec/form/select_list_spec.cr +++ /dev/null @@ -1,45 +0,0 @@ -require "../spec_helper" - -WebMock.stub(:get, "example.com/form/select_list").to_return(body: -<<-BODY - - - page_title - - -
- -
- - -BODY -) - -describe "Form Fields Multiple Select List" do - agent = Mechanize.new - page = agent.get("http://example.com/form/select_list") - form = page.forms[0] - - it "returns selectboxes size" do - form.selectboxes.size.should eq 1 - end - - selectbox = form.selectboxes[0] - - it "returns selectbox options size" do - selectbox.options.size.should eq 3 - end - - it "returns selected values" do - selectbox.values.empty?.should eq true - selectbox.select_all - selectbox.values.size.should eq 3 - selectbox.values.should eq ["dog", "cat", "hamster"] - selectbox.select_none - selectbox.values.empty?.should eq true - end -end