fix raw_value

master
Kanezoh 2021-06-19 06:42:44 +09:00
parent acbd92c79a
commit 93b8151abd
2 changed files with 14 additions and 2 deletions

View File

@ -8,7 +8,7 @@ WebMock.stub(:get, "example.com/form/fields").to_return(body:
</head>
<body>
<form action="post_path" method="post" name="sample_form">
<input type="text" name="name">
<input type="text" name="name" value="kanezoh">
<input type="text" name="email">
</form>
</body>
@ -24,5 +24,7 @@ describe "Form Fields" do
field = form.fields.first
field.type.should eq "text"
field.name.should eq "name"
field.value.should eq "kanezoh"
field.raw_value.should eq "kanezoh"
end
end

View File

@ -10,10 +10,20 @@ class MechanizeCr::FormContent::Field
@name = node.fetch("name", "")
@value = value || node.fetch("value", nil)
@type = node.fetch("type", "")
@raw_value = value
@raw_value = @value
end
def query_value
[@name, @value || ""]
end
# returns DOM 'id' value
def dom_id
node.fetch("id", "")
end
# returns DOM 'class' value
def dom_class
node.fetch("class", "")
end
end