From 087bcdd8f21ead2dd4e587b554e8248e5ffd4b99 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Sun, 27 Oct 2024 20:48:47 +0900 Subject: [PATCH] Add specs for float values --- spec/models/agents/website_agent_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/models/agents/website_agent_spec.rb b/spec/models/agents/website_agent_spec.rb index 2c3e22df79..3140c1d8f8 100644 --- a/spec/models/agents/website_agent_spec.rb +++ b/spec/models/agents/website_agent_spec.rb @@ -738,7 +738,8 @@ 'url' => "http://xkcd.com", 'mode' => "on_change", 'extract' => { - 'slogan' => { 'css' => "#slogan", 'value' => ".//text()", 'raw' => true } + 'slogan' => { 'css' => "#slogan", 'value' => ".//text()", 'raw' => true }, + 'slogan_length' => { 'css' => "#slogan", 'value' => "string-length(.)", 'raw' => true }, } } rel = Agents::WebsiteAgent.new(name: "xkcd", options: rel_site) @@ -747,6 +748,7 @@ rel.check event = Event.last expect(event.payload['slogan']).to eq(["A webcomic of romance,", " sarcasm, math, & language."]) + expect(event.payload['slogan_length']).to eq(49) end it "should return a string value returned by XPath" do @@ -757,7 +759,8 @@ 'url' => "http://xkcd.com", 'mode' => "on_change", 'extract' => { - 'slogan' => { 'css' => "#slogan", 'value' => "string(.)" } + 'slogan' => { 'css' => "#slogan", 'value' => "string(.)" }, + 'slogan_length' => { 'css' => "#slogan", 'value' => "string-length(.)" }, } } rel = Agents::WebsiteAgent.new(name: "xkcd", options: rel_site) @@ -766,6 +769,7 @@ rel.check event = Event.last expect(event.payload['slogan']).to eq("A webcomic of romance, sarcasm, math, & language.") + expect(event.payload['slogan_length']).to eq("49") end it "should interpolate _response_" do