Skip to content

Commit

Permalink
some updates, works with latest quepid 7.4.x releases
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jun 9, 2023
1 parent 66c1018 commit 3a6cfdd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
44 changes: 22 additions & 22 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,48 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
capybara (3.35.3)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
capybara (3.39.1)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
cliver (0.3.2)
concurrent-ruby (1.1.9)
cuprite (0.13)
capybara (>= 2.1, < 4)
ferrum (~> 0.11.0)
ferrum (0.11)
concurrent-ruby (1.2.2)
cuprite (0.14.3)
capybara (~> 3.0)
ferrum (~> 0.13.0)
ferrum (0.13)
addressable (~> 2.5)
cliver (~> 0.3)
concurrent-ruby (~> 1.1)
webrick (~> 1.7)
websocket-driver (>= 0.6, < 0.8)
mini_mime (1.1.0)
mini_portile2 (2.6.1)
nokogiri (1.12.3)
mini_portile2 (~> 2.6.1)
matrix (0.4.2)
mini_mime (1.1.2)
nokogiri (1.15.2-x86_64-darwin)
racc (~> 1.4)
public_suffix (4.0.6)
racc (1.5.2)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
regexp_parser (2.1.1)
public_suffix (5.0.1)
racc (1.7.0)
rack (3.0.7)
rack-test (2.1.0)
rack (>= 1.3)
regexp_parser (2.8.0)
webrick (1.8.1)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
x86_64-darwin-22

DEPENDENCIES
agent_q!

BUNDLED WITH
1.17.3
2.4.13
4 changes: 2 additions & 2 deletions agent_q.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'agent_q'
s.version = '0.0.13'
s.date = '2020-12-01'
s.version = '0.0.16'
s.date = '2023-06-09'
s.summary = "Headless agent for test driven relevancy with Quepid.com"
s.description = "A ruby agent that wraps a head browser that runs a specific Quepid Case and returns if your relevancy score meets or falls below a threshold."
s.authors = ["Eric Pugh"]
Expand Down
11 changes: 5 additions & 6 deletions lib/agent_q.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Inspired by http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html

require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/cuprite'
Expand All @@ -18,14 +17,14 @@ def initialize(quepid_case, threshold_score, username, password, quepid_url)
@quepid_url = quepid_url

Capybara.default_driver = :cuprite
Capybara.app_host = @quepid_url
#Capybara.app_host = @quepid_url
end

def run

# we go direct to the case, which then prompts the login process. That way we only
# score the requested case
visit("/case/#{@quepid_case}/try/0")
visit("#{@quepid_url}/case/#{@quepid_case}/try/0")
#save_screenshot('quepid.png')
within('#login') do
fill_in('user_email', with: @username)
Expand All @@ -45,7 +44,7 @@ def run

#save_screenshot('quepid_dashboard.png')

visit "/api/cases/#{@quepid_case}/scores/all.json"
visit "#{@quepid_url}/api/cases/#{@quepid_case}/scores/all.json"
html = page.html
json = html[html.index('{')..html.rindex('}')]
case_results = JSON.parse(json)
Expand All @@ -54,7 +53,7 @@ def run
exit 1
end

visit "/api/cases/#{@quepid_case}.json"
visit "#{@quepid_url}/api/cases/#{@quepid_case}.json"
html = page.html
json = html[html.index('{')..html.rindex('}')]
case_details = JSON.parse(json)
Expand All @@ -65,7 +64,7 @@ def run
exit 1
else
score = case_results['scores'].first['score']
if score.to_i >= @threshold_score.to_i
if score.to_f >= @threshold_score.to_f
puts "Case #{case_name} (#{@quepid_case}) scored #{score}, \e[32mwhich meets the threshold of #{@threshold_score}\e[0m"
exit 0
else
Expand Down

0 comments on commit 3a6cfdd

Please sign in to comment.