BrowserStack Ruby SDK
A comprehensive Ruby SDK for BrowserStack that provides observability, automation capabilities, and enhanced testing features for web applications.
Installation
Add this line to your application's Gemfile:
gem 'browserstack-ruby-sdk'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install browserstack-ruby-sdk
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
Available Rake Tasks
rake- Run proto compilation, tests and linting (default)rake proto- Compile Protocol Buffer filesrake spec- Run RSpec testsrake pre_build- Run RSpec, RuboCop linting.rake rubocop- Run RuboCop lintingrake coverage- Run tests with coverage reportrake quality- Run all quality checks (tests, linting, coverage)rake build- Build the gem with obfuscation (includes proto compilation)rake clean- Clean generated filesrake clean_proto- Clean generated Protocol Buffer filesrake version:show- Show current versionrake version:patch- Bump patch versionrake version:minor- Bump minor versionrake version:major- Bump major version
Protocol Buffers (gRPC)
This SDK uses Protocol Buffers for gRPC communication with BrowserStack services. The proto definitions are stored in proto/browserstack/sdk/v1/ and are automatically compiled during the build process.
Proto Development Workflow
- Edit Proto Files: Modify
.protofiles inproto/browserstack/sdk/v1/ - Compile: Run
rake prototo generate Ruby gRPC stubs - Generated Files: Ruby classes are created in
generated/browserstack/sdk/v1/ - Build: Run
rake buildto ensure proto compilation is included
The build process automatically compiles proto files before running tests and building the gem.
CLI Infrastructure
The SDK includes a comprehensive CLI infrastructure for managing BrowserStack services:
GrpcClient (lib/browserstack/cli/grpc_client.rb)
- Singleton pattern for managing gRPC connections
- Automatic fallback to mock responses when gRPC server unavailable
- Support for session management (start, connect, stop)
- Integrated with generated Protocol Buffer stubs
SdkCliUtils (lib/browserstack/cli/sdk_cli_utils.rb)
- Binary management and download utilities
- Framework detection (RSpec, Cucumber, Selenium, Playwright)
- Version compatibility checking
- Development environment detection
BrowserstackCLI (lib/browserstack/cli/browserstack_cli.rb)
- Main CLI orchestration and process management
- Module loading (Observability, Accessibility, TestHub)
- Process lifecycle control and cleanup
- Configuration management integration
Code Quality
This project maintains high code quality standards:
- Testing: RSpec for comprehensive test coverage (currently 100%)
- Linting: RuboCop with performance and RSpec extensions
- Coverage: SimpleCov for code coverage reporting
- Semantic Versioning: Automated version management
- Documentation: YARD for API documentation
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/browserstack/browserstack-ruby-sdk.
Development Dependencies
- RSpec 3.12+ for testing
- RuboCop 1.56+ for code linting
- SimpleCov 0.22+ for coverage reporting
- YARD 0.9+ for documentation
- Pry for debugging
Release Process
- Update CHANGELOG.md with new features/fixes
- Run
rake version:patch(or minor/major as appropriate) - Run
rake prepare_releaseto ensure all checks pass - Commit and push changes
- Create a GitHub release with tag
v<version> - CI/CD will automatically publish to RubyGems
License
The gem is available as open source under the terms of the MIT License. Browserstack Ruby SDK