Add this to your Gemfile and run bundle install in the Terminal.
gem "http"You can follow along in the rails console.
| namespace(:dev) do | |
| desc "Hydrate the database with some dummy data to look at so that developing is easier" | |
| task({ :prime => :environment}) do | |
| `rm -rf screenshots` | |
| `mkdir screenshots` | |
| start_time = Time.now | |
| browser = Ferrum::Browser.new(headless: true, slowmo: 0.05, browser_options: {"disable-gpu": true, "no-sandbox": true}) | |
| browser.goto("https://duckduckgo.com") | |
| browser.screenshot(path: "screenshots/duckduckgo.png") | |
| # input = browser.at_xpath("//div[@id='searchform']/form//input[@type='text']") |
I'm trying to write tests for a gem that is mounted in a Rails app. It's similar to a Rails Engine, except it's a Sinatra app that is mounted alongside the Rails app using the Rack Builder method.
I've configured config.ru like so
require_relative 'config/environment'
map '/git' do
run WebGit::Server
endTake this git graph as an example:
* ef99623 (c-branch) Other spaces
* 3c391fc (master) Merge branch 'b-branch'
|\
* | f0c357b Add spaces
| | * bc9833b (HEAD -> b-branch) Another space
| |/| p "first argument " + ARGV[0] | |
| p "second argument " + ARGV[1] | |
| remaining = "" | |
| for argument in ARGV do | |
| if argument != ARGV[0] && argument != ARGV[1] | |
| remaining = remaining + argument | |
| end | |
| end |