Skip to content

Commit

Permalink
Built-in binaries for linux/mac
Browse files Browse the repository at this point in the history
Closes #17

This will make it a lot easier to get started and you won't have to
worry about conflicting binaries and path issues.
  • Loading branch information
paulcsmith committed Jun 9, 2018
1 parent 5834a17 commit 6cdf0cb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -40,7 +40,7 @@ end
Habitat.raise_if_missing_settings!
```

Then install Chromedriver and view the guides: https://luckyframework.org/guides/browser-tests/
Then view the guides: https://luckyframework.org/guides/browser-tests/

You should be ready to go!

Expand All @@ -61,4 +61,4 @@ View guide at: https://luckyframework.org/guides/browser-tests/

## Contributors

* [paulcsmith](https://github.com/paulcsmith) Paul Smith - creator, maintainer
- [paulcsmith](https://github.com/paulcsmith) Paul Smith - creator, maintainer
26 changes: 12 additions & 14 deletions src/lucky_flow/chromedriver.cr
Expand Up @@ -6,36 +6,34 @@ class LuckyFlow::Chromedriver
getter log_io = IO::Memory.new

private def initialize
ensure_chromedriver_is_installed
@process = start_chromedriver
end

def self.start
new
end

private def ensure_chromedriver_is_installed
if !Process.find_executable("chromedriver")
raise <<-ERROR
Chromedriver must be available from the command line to use LuckyFlow.
▸ On macOS: brew install chromedriver
▸ On Linux: https://makandracards.com/makandra/29465-install-chromedriver-on-linux
ERROR
end
end

private def start_chromedriver : Process
Process.new(
"chromedriver",
"#{__DIR__}/../../vendor/chromedriver-2.40-#{os}",
["--port=4444", "--url-base=/wd/hub"],
output: log_io,
error: STDERR,
shell: true
)
end

private def os
os_name = IO::Memory.new
Process.run("uname -a", shell: true, output: os_name, error: STDERR)

if os_name.to_s.includes?("Darwin")
"mac64"
else
"linux64"
end
end

def stop
process.kill unless process.terminated?
end
Expand Down
Binary file added vendor/chromedriver-2.40-linux64
Binary file not shown.
Binary file added vendor/chromedriver-2.40-mac64
Binary file not shown.

0 comments on commit 6cdf0cb

Please sign in to comment.