Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add rubocop
- Loading branch information
1 parent
3b46023
commit 94d5523
Showing
11 changed files
with
121 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: when_needed, always, never | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. | ||
# SupportedStyles: space, no_space, compact | ||
# SupportedStylesForEmptyBraces: space, no_space | ||
Layout/SpaceInsideHashLiteralBraces: | ||
EnforcedStyle: no_space | ||
|
||
Style/CommentedKeyword: | ||
Enabled: false | ||
|
||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. | ||
# URISchemes: http, https | ||
Metrics/LineLength: | ||
Max: 120 | ||
|
||
# Configuration parameters: CountComments, ExcludedMethods. | ||
# ExcludedMethods: refine | ||
Metrics/BlockLength: | ||
Exclude: | ||
- 'spec/**/*' | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
# Configuration parameters: CountComments. | ||
Metrics/MethodLength: | ||
Max: 13 | ||
|
||
Metrics/CyclomaticComplexity: | ||
Max: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
sudo: false | ||
language: ruby | ||
rvm: | ||
- 2.4.1 | ||
- 2.3.7 | ||
before_install: | ||
- export DISPLAY=:99 | ||
- sh -e /etc/init.d/xvfb start | ||
- export PATH=~/.webdrivers:$PATH | ||
script: bundle exec rake $RAKE_TASK | ||
env: | ||
- RAKE_TASK=spec | ||
- RAKE_TASK=watirspec:run | ||
- RAKE_TASK=rubocop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | ||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
||
# Specify your gem's dependencies in watigiri.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
require 'watirspec/rake_tasks' | ||
WatirSpec::RakeTasks.new | ||
|
||
task default: %i[spec watirspec:run] | ||
|
||
require 'rubocop/rake_task' | ||
RuboCop::RakeTask.new(:rubocop) do |t| | ||
t.options = ['--display-cop-names'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,70 @@ | ||
require "watirspec_helper" | ||
require 'watirspec_helper' | ||
|
||
describe Watigiri do | ||
require 'watirspec_helper' | ||
|
||
describe '#text!' do | ||
before do | ||
browser.goto(WatirSpec.url_for("non_control_elements.html")) | ||
browser.goto(WatirSpec.url_for('non_control_elements.html')) | ||
end | ||
|
||
it "locates with page_source driver call" do | ||
it 'locates with page_source driver call' do | ||
expect(browser.driver).to_not receive(:find_element) | ||
expect(browser.driver).to_not receive(:find_elements) | ||
|
||
expect(browser.li(id: "non_link_1").text!).to eq 'Non-link 1' | ||
expect(browser.li(id: 'non_link_1').text!).to eq 'Non-link 1' | ||
expect(browser.li(id: /non_link_1/).text!).to eq 'Non-link 1' | ||
expect(browser.li(title: "This is not a link!").text!).to eq 'Non-link 1' | ||
expect(browser.li(title: 'This is not a link!').text!).to eq 'Non-link 1' | ||
expect(browser.li(title: /This is not a link!/).text!).to eq 'Non-link 1' | ||
expect(browser.li(class: "nonlink").text!).to eq 'Non-link 1' | ||
expect(browser.li(class: 'nonlink').text!).to eq 'Non-link 1' | ||
expect(browser.li(class: /nonlink/).text!).to eq 'Non-link 1' | ||
expect(browser.li(id: /non_link/, index: 1).text!).to eq 'Non-link 2' | ||
expect(browser.li(xpath: "//li[@id='non_link_1']").text!).to eq 'Non-link 1' | ||
expect(browser.li(css: "li#non_link_1").text!).to eq 'Non-link 1' | ||
expect(browser.li(css: 'li#non_link_1').text!).to eq 'Non-link 1' | ||
end | ||
|
||
it "locates with inner html driver call" do | ||
it 'locates with inner html driver call' do | ||
div = browser.div(id: 'header').tap(&:exist?) | ||
expect(browser.driver).to_not receive(:find_element) | ||
expect(browser.driver).to_not receive(:find_elements) | ||
|
||
expect(div.li(id: "non_link_1").text!).to eq 'Non-link 1' | ||
expect(div.li(id: 'non_link_1').text!).to eq 'Non-link 1' | ||
expect(div.li(id: /non_link_1/).text!).to eq 'Non-link 1' | ||
expect(div.li(title: "This is not a link!").text!).to eq 'Non-link 1' | ||
expect(div.li(title: 'This is not a link!').text!).to eq 'Non-link 1' | ||
expect(div.li(title: /This is not a link!/).text!).to eq 'Non-link 1' | ||
expect(div.li(class: "nonlink").text!).to eq 'Non-link 1' | ||
expect(div.li(class: 'nonlink').text!).to eq 'Non-link 1' | ||
expect(div.li(class: /nonlink/).text!).to eq 'Non-link 1' | ||
expect(div.li(id: /non_link/, index: 1).text!).to eq 'Non-link 2' | ||
expect(div.li(xpath: "//li[@id='non_link_1']").text!).to eq 'Non-link 1' | ||
expect(div.li(css: "li#non_link_1").text!).to eq 'Non-link 1' | ||
expect(div.li(css: 'li#non_link_1').text!).to eq 'Non-link 1' | ||
end | ||
|
||
it "reloads the cached document from after hooks" do | ||
it 'reloads the cached document from after hooks' do | ||
expect(browser.driver).to receive(:page_source).exactly(3).times.and_return(browser.driver.page_source) | ||
|
||
expect(browser.li(id: "non_link_1").text!).to eq 'Non-link 1' | ||
expect(browser.li(id: 'non_link_1').text!).to eq 'Non-link 1' | ||
browser.refresh | ||
expect(browser.li(id: /non_link_1/).text!).to eq 'Non-link 1' | ||
browser.li.click | ||
expect(browser.li(title: "This is not a link!").text!).to eq 'Non-link 1' | ||
expect(browser.li(title: 'This is not a link!').text!).to eq 'Non-link 1' | ||
browser.li.click | ||
end | ||
|
||
it "locates by sub-element" do | ||
it 'locates by sub-element' do | ||
navbar = browser.ul(id: 'navbar').tap(&:exist?) | ||
expect(browser.driver).to_not receive(:find_element) | ||
expect(browser.driver).to_not receive(:find_elements) | ||
expect(navbar.li(id: "non_link_1").text!).to eq "Non-link 1" | ||
expect(navbar.li(id: 'non_link_1').text!).to eq 'Non-link 1' | ||
end | ||
|
||
describe "#exists?" do | ||
it "finds Watir::Element when selector uses regular expression" do | ||
describe '#exists?' do | ||
it 'finds Watir::Element when selector uses regular expression' do | ||
expect_any_instance_of(Selenium::WebDriver::Element).to_not receive(:attribute) | ||
|
||
li = browser.li(id: /link/, index: 1) | ||
expect(li).to exist | ||
expect(li).to be_a(Watir::Element) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path("../lib", __FILE__) | ||
lib = File.expand_path('lib', __dir__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "watigiri" | ||
spec.version = "0.4.0" | ||
spec.authors = ["Titus Fortner"] | ||
spec.email = ["titusfortner@gmail.com"] | ||
spec.name = 'watigiri' | ||
spec.version = '0.4.0' | ||
spec.authors = ['Titus Fortner'] | ||
spec.email = ['titusfortner@gmail.com'] | ||
|
||
spec.summary = %q{Nokogiri locator engine for Watir} | ||
spec.description = <<-DESCRIPTION_MESSAGE | ||
By default Watir locates elements with Selenium; this gem will replace Selenium calls | ||
with Nokogiri calls where designated. | ||
spec.summary = 'Nokogiri locator engine for Watir' | ||
spec.description = <<~DESCRIPTION_MESSAGE | ||
By default Watir locates elements with Selenium; this gem will replace Selenium calls | ||
with Nokogiri calls where designated. | ||
DESCRIPTION_MESSAGE | ||
spec.homepage = "http://github.com/titusfortner/watigiri" | ||
spec.license = "MIT" | ||
spec.homepage = 'http://github.com/titusfortner/watigiri' | ||
spec.license = 'MIT' | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject do |f| | ||
f.match(%r{^(test|spec|features)/}) | ||
end | ||
spec.bindir = "exe" | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_development_dependency "bundler", "~> 1.15" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
spec.add_development_dependency "rspec", "~> 3.0" | ||
spec.add_development_dependency 'bundler', '~> 1.15' | ||
spec.add_development_dependency 'rake', '~> 10.0' | ||
spec.add_development_dependency 'rspec', '~> 3.0' | ||
spec.add_development_dependency 'rubocop' | ||
spec.add_development_dependency 'webdrivers', '~> 3.3', '>= 3.3.3' | ||
|
||
spec.add_runtime_dependency "watir", "~> 6.12" | ||
spec.add_runtime_dependency "nokogiri" | ||
spec.add_runtime_dependency 'nokogiri' | ||
spec.add_runtime_dependency 'watir', '~> 6.12' | ||
end |