Advice on testing code which uses Ferrum::Browser
?
#347
Replies: 4 comments 1 reply
-
I think you can try to serve a file or there's a https://github.com/rubycdp/ferrum#interceptoptions with |
Beta Was this translation helpful? Give feedback.
-
@route correct. I want to test scenarios where Ferrum will visit multiple URLs in order or visits a URL which causes multiple requests for JavaScript/CSS/etc. I could try to find websites that I could test against, but I would prefer to keep the tests self-contained and have the HTML contained within the tests. I suppose I could define a large |
Beta Was this translation helpful? Give feedback.
-
Hello, I am in a similar position where I want to use Vessel to crawl some urls, but I'm unsure if there's a simple way to mock those requests in tests. Has there been any significant change in this area? Or is there some documentation / other gem I could take a look at? Thanks! |
Beta Was this translation helpful? Give feedback.
-
There was no change, but everything ferrum uses under spec can and should be extracted. One downside of it is that if we extract this code and put it to libs we would need to add extra dependencies of puma/webrick/rack + sinatra to a gem that in general doesn't require it. |
Beta Was this translation helpful? Give feedback.
-
Say I write a class which uses
Ferrum::Browser
. How do I then test that class, such that the tests will work in GitHub Actions? I see from Ferrum's own specs there's quite a bit of setup code inspec/spec_helper.rb
, even aFerrum::Server
which is used to serve content up toFerrum::Browser
. I was wondering if there was boilerplate code I could use to setup RSpec tests. Could I usefile://
URLs instead of a local HTTP server?I at least figured out that I need to call
browser-actions/setup-chrome@latest
in the GitHub Actions workflow., and callFerrum::Browser#quit
to cleanup the browser instance.Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions