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 files
  • rake spec - Run RSpec tests
  • rake pre_build - Run RSpec, RuboCop linting.
  • rake rubocop - Run RuboCop linting
  • rake coverage - Run tests with coverage report
  • rake quality - Run all quality checks (tests, linting, coverage)
  • rake build - Build the gem with obfuscation (includes proto compilation)
  • rake clean - Clean generated files
  • rake clean_proto - Clean generated Protocol Buffer files
  • rake version:show - Show current version
  • rake version:patch - Bump patch version
  • rake version:minor - Bump minor version
  • rake 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

  1. Edit Proto Files: Modify .proto files in proto/browserstack/sdk/v1/
  2. Compile: Run rake proto to generate Ruby gRPC stubs
  3. Generated Files: Ruby classes are created in generated/browserstack/sdk/v1/
  4. Build: Run rake build to 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

  1. Update CHANGELOG.md with new features/fixes
  2. Run rake version:patch (or minor/major as appropriate)
  3. Run rake prepare_release to ensure all checks pass
  4. Commit and push changes
  5. Create a GitHub release with tag v<version>
  6. 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