Skip to content

Add print page command to ruby binding - #8920

Merged
diemol merged 16 commits into
SeleniumHQ:trunkfrom
raju249:print-page-ruby
Dec 18, 2020
Merged

Add print page command to ruby binding#8920
diemol merged 16 commits into
SeleniumHQ:trunkfrom
raju249:print-page-ruby

Conversation

@raju249

@raju249 raju249 commented Nov 30, 2020

Copy link
Copy Markdown
Member

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@raju249
raju249 force-pushed the print-page-ruby branch 2 times, most recently from fcb3d59 to 6cabffb Compare December 10, 2020 09:23
@raju249
raju249 marked this pull request as ready for review December 10, 2020 09:23
@raju249
raju249 requested a review from p0deje December 10, 2020 09:23
@raju249 raju249 added the C-rb Ruby Bindings label Dec 10, 2020

@luke-hill luke-hill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few tips/tricks/fixes

def print_page(**options)
options[:page_ranges] &&= Array(options[:page_ranges])

bridge.print_page(options)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bridge here isn't defined as an accessor / reader to try mask it better. So you need to directly call the iVar @bridge here.

def print_page(**options)
options[:page_ranges] &&= Array(options[:page_ranges])

bridge.print_page(options)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. and all others.


module Selenium
module WebDriver
MAGIC_NUMBER = 'JVBER'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you set this as a let it's probably syntatically better.

let(:magic_number) { 'JVBER' }

end

it 'should return base64 for print command' do
expect(@driver.print_page().include?(MAGIC_NUMBER)).to be true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be re-written to expect(@driver.print_page).to include(magic_number)

Reason: Rspec includes most predicates built into ruby as rspec matchers

Use this style for the ones below

@raju249
raju249 requested review from titusfortner and removed request for p0deje December 10, 2020 09:53
@raju249

raju249 commented Dec 11, 2020

Copy link
Copy Markdown
Member Author

Few tips/tricks/fixes

@luke-hill Applied your review comments. Please take a look.

Thanks 🙇

@luke-hill luke-hill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. There are also a few stylistic ruby specific things you could do. But I'll let you learn those yourself.

If inside /rb you run the command rubocop it will flag up minor tweaks. If you then run rubocop -A or maybe rubocop -a dependent on version it will auto fix many of them.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@diemol
diemol merged commit 7661e5e into SeleniumHQ:trunk Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-rb Ruby Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants