selenium-connect 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ LineLength:
2
+ Enabled: false
3
+
4
+ MethodLength:
5
+ Max: 30
6
+
7
+ EndAlignment:
8
+ Enabled: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p429
1
+ ruby-1.9.3
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ notifications:
5
+ hipchat: 2a07784c1aeed1b6efa332242d3fc3@Regulation Station
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ #2.1.0 (2013-07-02)
2
+
1
3
  #2.0.0 (2013-06-27)
2
4
  - Added selenium server jar as explicit dependency
3
5
  - Updated ruby version
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ Master Branch: [![Build Status](https://travis-ci.org/arrgyle/selenium-connect.png?branch=master)](https://travis-ci.org/arrgyle/selenium-connect)
2
+
3
+ Develop Branch: [![Build Status](https://travis-ci.org/arrgyle/selenium-connect.png?branch=develop)](https://travis-ci.org/arrgyle/selenium-connect)
4
+
1
5
  #selenium-connect [![Code Climate](https://codeclimate.com/github/arrgyle/selenium-connect.png)](https://codeclimate.com/github/arrgyle/selenium-connect)
2
6
 
3
7
  A stupid simple way to run your Selenium tests on your computer, against a Selenium Grid, or in the cloud (e.g. SauceLabs).
@@ -19,24 +23,24 @@ SeleniumConnect.finish
19
23
  ## Helpful bits
20
24
 
21
25
  ### Start
22
- If host is set to "localhost" and no jar file is specified, it will run the version of [selenium-standalone-server.jar](https://code.google.com/p/selenium/downloads/list) that is bundled with the library (currently 2.33.0). Or, you can specify your own jar if you have one you prefer to use. This is done with c.jar = 'path-to-jar-file'.
26
+ If host is set to "localhost" and no jar file is specified, it will run the version of [selenium-standalone-server.jar](https://code.google.com/p/selenium/downloads/list) that is bundled with the library (currently 2.33.0). Or, you can specify your own jar if you have one you prefer to use. This is done with c.jar = 'path-to-jar-file'.
23
27
 
24
- If no additional parameters are set, the Selenium Server will be run in the background with logging disabled. If a logging directory is provided (with c.log = 'path-to-log-dir') then 3 output files will be generated:
25
- + Selenium Server JSON Wire Protocol output (server.log)
26
- + Browser output (browser.log) -- currently only available for Firefox
27
- + Test output (SPEC-testname.xml)
28
+ If no additional parameters are set, the Selenium Server will be run in the background with logging disabled. If a logging directory is provided (with c.log = 'path-to-log-dir') then 3 output files will be generated:
29
+ + Selenium Server JSON Wire Protocol output (server.log)
30
+ + Browser output (browser.log) -- currently only available for Firefox
31
+ + Test output (SPEC-testname.xml)
28
32
 
29
- This localhost functionality is driven using the [Selenium Rake Server Task](http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/Rake/ServerTask.html).
33
+ This localhost functionality is driven using the [Selenium Rake Server Task](http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/Rake/ServerTask.html).
30
34
 
31
35
  ### Finish
32
36
  The finish command issues a quit command to the driver and stops the local server if your host is set to "localhost".
33
37
 
34
38
  ### Support
35
- - [Firefox](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/firefox_spec.rb)
36
- - [Chrome](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/chrome_spec.rb)
37
- - [Internet Explorer](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/ie_spec.rb)
38
- - [PhantomJS](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/headless_spec.rb)
39
- - [SauceLabs](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/sauce_spec.rb)
39
+ - [Firefox](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/firefox_spec.rb)
40
+ - [Chrome](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/chrome_spec.rb)
41
+ - [Internet Explorer](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/ie_spec.rb)
42
+ - [PhantomJS](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/headless_spec.rb)
43
+ - [SauceLabs](https://github.com/arrgyle/selenium-connect/blob/develop/spec/acceptance/sauce_spec.rb)
40
44
 
41
45
  ## Contributing
42
46
 
data/Rakefile CHANGED
@@ -1,17 +1,127 @@
1
- require "bundler/gem_tasks"
1
+ # Encoding: utf-8
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
- task :default => [:build]
6
+ task default: :build_ci
7
+
8
+ task build_ci: [:clean, :prepare, :rubocop, :spec_unit]
5
9
 
6
10
  desc 'Runs standard build activities.'
7
- task :build => [:clean, :prepare, :spec]
11
+ task build: [:clean, :prepare, :rubocop, :spec_unit, :spec_full]
8
12
 
9
13
  desc 'Removes the build directory.'
10
14
  task :clean do
11
- FileUtils.rm_rf('build');
15
+ FileUtils.rm_rf('build')
12
16
  end
13
17
  desc 'Adds the build tmp directory for test kit creation.'
14
18
  task :prepare do
15
19
  FileUtils.mkdir_p('build/tmp')
16
20
  end
17
- RSpec::Core::RakeTask.new(:spec)
21
+ RSpec::Core::RakeTask.new(:spec_full)
22
+
23
+ RSpec::Core::RakeTask.new(:spec_unit) do |t|
24
+ t.rspec_opts = "--tag ~selenium"
25
+ end
26
+
27
+ desc 'Runs code quality check'
28
+ task :rubocop do
29
+ sh 'rubocop'
30
+ end
31
+
32
+ # TODO This could probably be more cleanly automated
33
+ desc 'Start a release (Requires Git Flow)'
34
+ task :release_start, :version do |t, args|
35
+ version = args['version']
36
+
37
+ # make sure we have the latest stuff
38
+ system 'git fetch --all'
39
+
40
+ # first make sure master is checked out and up to date
41
+ system 'git checkout master'
42
+ system 'git pull --no-edit origin master'
43
+
44
+ # then make sure develop is up to date
45
+ system 'git checkout develop'
46
+ system 'git pull --no-edit origin develop'
47
+
48
+ # next assure all the tests run
49
+ task(:build).invoke
50
+
51
+ # start the release process
52
+ system "git flow release start #{version}"
53
+
54
+ # update the version number in the .gemspec file
55
+ gemspec = File.join(Dir.getwd, 'selenium-connect.gemspec')
56
+ updated = File.read(gemspec).gsub(
57
+ /s.version(\s+)=(\s?["|']).+(["|'])/,
58
+ "s.version\\1=\\2#{version}\\3"
59
+ )
60
+ File.open(gemspec, 'w') { |f| f.write(updated) }
61
+
62
+ # commit the version bump
63
+ system 'git add selenium-connect.gemspec'
64
+ system "git commit -m 'Bumped version to #{version} to prepare for release.'"
65
+
66
+ puts "You've started release #{version}, make any last minute updates now.\n"
67
+ end
68
+
69
+ # TODO This could probablly be more cleanly automated
70
+ desc 'Finish a release (Requires Git Flow and Gem Deploy Permissions'
71
+ task :release_finish, :update_message do |t, args|
72
+ message = args['update_message']
73
+ gemspec = File.join(Dir.getwd, 'selenium-connect.gemspec')
74
+ changelog = File.join(Dir.getwd, 'CHANGELOG.md')
75
+ version = File.read(gemspec).match(/s.version\s+=\s?["|'](.+)["|']/)[1]
76
+
77
+ ### Changelog
78
+ # get the latest tag
79
+ last_tag = `git describe --abbrev=0`
80
+ # get the commit hash since the last that version was merged to develop
81
+ hash = `git log --grep="Merge branch 'release/#{last_tag.chomp}' into develop" --format="%H"`
82
+ # get all the commits since them less merges
83
+ log = `git log --format="- %s" --no-merges #{hash.chomp}..HEAD`
84
+
85
+ changelog_contents = File.read(changelog)
86
+ date = Time.new.strftime('%Y-%m-%d')
87
+ # create the new heading
88
+ updated_changelog = "##{version} (#{date})\n" + log + "\n" + changelog_contents
89
+ # update the contents
90
+ File.open(changelog, 'w') { |f| f.write(updated_changelog) }
91
+ puts "Updated change log for version #{version}\n"
92
+
93
+ ### Update the gemspec with the message
94
+ updated_gemspec = File.read(gemspec).gsub(
95
+ /s.description(\s+)=(\s?["|']).+(["|'])/,
96
+ "s.description\\1=\\2#{message}\\3"
97
+ )
98
+ File.open(gemspec, 'w') { |f| f.write(updated_gemspec) }
99
+
100
+ # Commit the updated change log and gemspec
101
+ system "git commit -am 'Updated CHANGELOG.md and gemspec for #{version} release.'"
102
+
103
+ # build the gem
104
+ system 'gem build selenium-connect.gemspec'
105
+
106
+ # push the gem
107
+ system "gem push selenium-connect-#{version}.gem"
108
+
109
+ # remove the gem file
110
+ system "rm selenium-connect-#{version}.gem"
111
+
112
+ # finish the release
113
+ # TODO there is a bug with git flow, and you still need to deal with merge
114
+ # messages, might just do this with git directly
115
+ system "git flow release finish -m'#{version}' #{version}"
116
+
117
+ # push develop
118
+ system 'git push origin develop'
119
+
120
+ # push master
121
+ system 'git push origin master'
122
+
123
+ # push tags
124
+ system 'git push --tags'
125
+
126
+ puts "Rock and roll, you just released Selenium Connect #{version}!\n"
127
+ end
@@ -1,44 +1,40 @@
1
+ # Encoding: utf-8
2
+
3
+ require 'yaml'
4
+
1
5
  module SeleniumConnect
6
+ # Encapsulates the configuration
2
7
  class Configuration
3
- #Selenium Server
8
+
9
+ # Selenium Server
4
10
  attr_accessor :host, :port, :version,
5
11
  :background, :log, :jar
6
12
 
7
- #Browsers
13
+ # Browsers
8
14
  attr_accessor :browser, :browser_path,
9
15
  :profile_path, :profile_name
10
16
 
11
- #SauceLabs
17
+ # SauceLabs
12
18
  attr_accessor :sauce_username, :sauce_api_key,
13
19
  :os, :browser_version, :description
14
20
 
15
- def config_file=(file)
16
- set_config_values_from_file(get_config_values_from_file(file))
17
- end
18
-
19
- private
20
-
21
21
  def initialize
22
- defaults
22
+ @host = 'localhost'
23
+ @port = 4444
24
+ @browser = 'firefox'
23
25
  end
24
26
 
25
- def defaults
26
- @host = 'localhost' unless host
27
- @port = 4444 unless port
28
- @browser = 'firefox' unless browser
27
+ def populate_with_hash(hash)
28
+ hash.each do |key, value|
29
+ self.send "#{key}=", value unless value.nil?
30
+ end
29
31
  end
30
32
 
31
- def get_config_values_from_file(file)
32
- require 'yaml'
33
- YAML.load_file(file)
33
+ def populate_with_yaml(file)
34
+ populate_with_hash YAML.load_file file
34
35
  end
35
36
 
36
- def set_config_values_from_file(config_file_values)
37
- config_file_values.each do |config_parameter, config_value|
38
- instance_variable_set("@#{config_parameter}", config_value)
39
- end
40
- defaults
41
- end
37
+ alias_method :config_file=, :populate_with_yaml
42
38
 
43
- end #Configuration
44
- end #SeleniumConnect
39
+ end # Configuration
40
+ end # SeleniumConnect
@@ -1,3 +1,5 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect/runners/firefox'
2
4
  require 'selenium-connect/runners/ie'
3
5
  require 'selenium-connect/runners/chrome'
@@ -6,6 +8,7 @@ require 'selenium-connect/runners/no_browser'
6
8
  require 'selenium-connect/runners/saucelabs'
7
9
 
8
10
  module SeleniumConnect
11
+ # Initializes the driver
9
12
  class Runner
10
13
  attr_reader :driver, :config
11
14
 
@@ -26,13 +29,14 @@ module SeleniumConnect
26
29
  else
27
30
  Selenium::WebDriver.for(
28
31
  :remote,
29
- :url => set_server_url,
30
- :desired_capabilities => get_browser)
32
+ url: set_server_url,
33
+ desired_capabilities: get_browser
34
+ )
31
35
  end
32
36
  end
33
37
 
34
38
  def get_browser
35
- browser = browsers.find { |browser| browser.match? }
39
+ browser = browsers.find { |found_browser| found_browser.match? }
36
40
  browser.launch
37
41
  end
38
42
 
@@ -42,9 +46,8 @@ module SeleniumConnect
42
46
  chrome = Chrome.new(config)
43
47
  phantomjs = PhantomJS.new(config)
44
48
  no_browser = NoBrowser.new(config)
45
-
46
- browsers = [ firefox, ie, chrome, phantomjs, no_browser ]
49
+ [firefox, ie, chrome, phantomjs, no_browser]
47
50
  end
48
51
 
49
- end #Runner
50
- end #SeleniumConnect
52
+ end # Runner
53
+ end # SeleniumConnect
@@ -1,5 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Runner
2
5
  class Runner
6
+ # Chrome browser runner
3
7
  class Chrome
4
8
  attr_reader :config
5
9
 
@@ -8,7 +12,7 @@ module SeleniumConnect
8
12
  end
9
13
 
10
14
  def match?
11
- config.browser == "chrome"
15
+ config.browser == 'chrome'
12
16
  end
13
17
 
14
18
  def launch
@@ -21,6 +25,6 @@ module SeleniumConnect
21
25
  config.browser.to_sym
22
26
  end
23
27
 
24
- end #Chrome
25
- end #Runner
26
- end #SeleniumConnect
28
+ end # Chrome
29
+ end # Runner
30
+ end # SeleniumConnect
@@ -1,5 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Runner
2
5
  class Runner
6
+ # Firefox browser runner
3
7
  class Firefox
4
8
  attr_reader :config
5
9
 
@@ -8,7 +12,7 @@ module SeleniumConnect
8
12
  end
9
13
 
10
14
  def match?
11
- config.browser == "firefox"
15
+ config.browser == 'firefox'
12
16
  end
13
17
 
14
18
  def launch
@@ -41,6 +45,6 @@ module SeleniumConnect
41
45
  config_browser
42
46
  end
43
47
 
44
- end #Firefox
45
- end #Runner
46
- end #SeleniumConnect
48
+ end # Firefox
49
+ end # Runner
50
+ end # SeleniumConnect
@@ -1,5 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Runner
2
5
  class Runner
6
+ # IE Browser Runner
3
7
  class InternetExplorer
4
8
  attr_reader :config
5
9
 
@@ -8,7 +12,7 @@ module SeleniumConnect
8
12
  end
9
13
 
10
14
  def match?
11
- config.browser == "ie"
15
+ config.browser == 'ie'
12
16
  end
13
17
 
14
18
  def launch
@@ -21,6 +25,6 @@ module SeleniumConnect
21
25
  config.browser.to_sym
22
26
  end
23
27
 
24
- end #InternetExplorer
25
- end #Runner
26
- end #SeleniumConnect
28
+ end # InternetExplorer
29
+ end # Runner
30
+ end # SeleniumConnect
@@ -1,5 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Runner
2
5
  class Runner
6
+ # No Browser Runner
3
7
  class NoBrowser
4
8
  attr_reader :config
5
9
 
@@ -12,10 +16,10 @@ module SeleniumConnect
12
16
  end
13
17
 
14
18
  def execute
15
- puts "Please specify a valid browser."
19
+ puts 'Please specify a valid browser.'
16
20
  exit 1
17
21
  end
18
22
 
19
- end #NoBrowser
20
- end #Runner
21
- end #SeleniumConnect
23
+ end # NoBrowser
24
+ end # Runner
25
+ end # SeleniumConnect
@@ -1,5 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Runner
2
5
  class Runner
6
+ # PhantomJS browser runner
3
7
  class PhantomJS
4
8
  attr_reader :config
5
9
 
@@ -8,7 +12,7 @@ module SeleniumConnect
8
12
  end
9
13
 
10
14
  def match?
11
- config.browser == "phantomjs"
15
+ config.browser == 'phantomjs'
12
16
  end
13
17
 
14
18
  def launch
@@ -19,7 +23,7 @@ module SeleniumConnect
19
23
 
20
24
  def get_executable_path
21
25
  current_dir_path = File.join(File.dirname(File.expand_path(__FILE__)))
22
- current_dir_path + "/../../../bin/phantomjs"
26
+ current_dir_path + '/../../../bin/phantomjs'
23
27
  end
24
28
 
25
29
  def config_browser
@@ -33,6 +37,6 @@ module SeleniumConnect
33
37
  config_browser
34
38
  end
35
39
 
36
- end #Chrome
37
- end #Runner
38
- end #SeleniumConnect
40
+ end # Chrome
41
+ end # Runner
42
+ end # SeleniumConnect
@@ -1,7 +1,11 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'sauce'
2
4
 
3
5
  module SeleniumConnect
6
+ # Runner
4
7
  class Runner
8
+ # Sauce runner
5
9
  class Saucelabs
6
10
  attr_reader :config
7
11
 
@@ -23,12 +27,12 @@ module SeleniumConnect
23
27
  def init_browser
24
28
  get_credentials
25
29
  Sauce::Selenium2.new({
26
- :os => config.os,
27
- :browser => config.browser,
28
- :browser_version => config.browser_version,
29
- :job_name => config.description })
30
+ os: config.os,
31
+ browser: config.browser,
32
+ browser_version: config.browser_version,
33
+ job_name: config.description })
30
34
  end
31
35
 
32
- end #Saucelabs
33
- end #Runner
34
- end #SeleniumConnect
36
+ end # Saucelabs
37
+ end # Runner
38
+ end # SeleniumConnect
@@ -1,4 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  module SeleniumConnect
4
+ # Creates a server connection
2
5
  class Server
3
6
  attr_reader :configuration, :current_dir_path
4
7
 
@@ -8,15 +11,15 @@ module SeleniumConnect
8
11
  end
9
12
 
10
13
  def start
11
- rake "start"
14
+ rake 'start'
12
15
  end
13
16
 
14
17
  def stop
15
- rake "stop"
18
+ rake 'stop'
16
19
  end
17
20
 
18
21
  def restart
19
- rake "restart"
22
+ rake 'restart'
20
23
  end
21
24
 
22
25
  private
@@ -61,5 +64,5 @@ module SeleniumConnect
61
64
  system "rake -f #{get_rake_file} server:#{task}"
62
65
  end
63
66
 
64
- end #Server
65
- end #SeleniumConnect
67
+ end # Server
68
+ end # SeleniumConnect
@@ -1,8 +1,11 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-webdriver'
2
4
  require 'selenium-connect/configuration'
3
5
  require 'selenium-connect/runner'
4
6
  require 'selenium-connect/server'
5
7
 
8
+ # Selenium Connect main module
6
9
  module SeleniumConnect
7
10
 
8
11
  extend self
@@ -35,12 +38,14 @@ module SeleniumConnect
35
38
  def finish
36
39
  begin
37
40
  driver.quit
41
+ # rubocop:disable HandleExceptions
38
42
  rescue Selenium::WebDriver::Error::WebDriverError
39
- #no-op
43
+ # rubocop:enable HandleExceptions
44
+ # no-op
40
45
  end
41
- if localhost? then server.stop end
46
+ server.stop unless localhost?
42
47
  end
43
48
 
44
- alias :start :run
45
- alias :stop :finish
49
+ alias_method :start, :run
50
+ alias_method :stop, :finish
46
51
  end
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'selenium-connect'
3
- s.version = '2.0.0'
3
+ s.version = '2.1.0'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Dave Haeffner', 'Jason Fox']
6
6
  s.email = ['dave@arrgyle.com', 'jason@arrgyle.com']
7
7
  s.homepage = 'https://github.com/arrgyle/selenium-connect'
8
8
  s.summary = 'A stupid simple way to run your Selenium tests on localhost, against a Selenium Grid, or in the cloud (e.g. SauceLabs).'
9
- s.description = 'Added the latest selenium server jar to the gem, updated documentation, and fixed a performance issue when running against localhost.'
9
+ s.description = 'Updated configuration methods and improved code quality.'
10
10
  s.license = 'MIT'
11
11
 
12
12
  s.files = `git ls-files`.split($/)
@@ -19,5 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'sauce', '~> 2.4.4'
20
20
 
21
21
  s.add_development_dependency 'rspec'
22
+ s.add_development_dependency "rubocop", "~> 0.9.0"
22
23
 
23
24
  end
@@ -1,18 +1,20 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
  require_relative 'helper'
3
5
 
4
- describe "Chrome" do
6
+ describe 'Chrome', selenium: true do
5
7
 
6
8
  let(:google) { Google.new(SeleniumConnect.start) }
7
9
  let(:quit) { SeleniumConnect.finish }
8
10
 
9
- it "localhost" do
10
- #currently only works on Mac
11
+ it 'localhost' do
12
+ # currently only works on Mac
11
13
  SeleniumConnect.configure do |c|
12
14
  c.browser = 'chrome'
13
15
  end
14
16
  google.visit
15
- google.page_title.should include("Google")
17
+ google.page_title.should include('Google')
16
18
  quit
17
19
  end
18
20
 
@@ -1,59 +1,61 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
  require_relative 'helper'
3
5
 
4
- describe "Firefox" do
6
+ describe 'Firefox', selenium: true do
5
7
 
6
8
  let(:google) { Google.new(SeleniumConnect.start) }
7
9
  let(:quit) { SeleniumConnect.finish }
8
10
 
9
- it "blank config" do
10
- SeleniumConnect.configure do end
11
+ it 'blank config' do
12
+ SeleniumConnect.configure {}
11
13
  google.visit
12
- google.page_title.should include("Google")
14
+ google.page_title.should include('Google')
13
15
  quit
14
16
  end
15
17
 
16
- it "localhost" do
18
+ it 'localhost' do
17
19
  SeleniumConnect.configure do |c|
18
- c.host = "localhost"
20
+ c.host = 'localhost'
19
21
  end
20
22
  google.visit
21
- google.page_title.should include("Google")
23
+ google.page_title.should include('Google')
22
24
  quit
23
25
  end
24
26
 
25
- it "local jar file specified" do
27
+ it 'local jar file specified' do
26
28
  SeleniumConnect.configure do |c|
27
- c.host = "localhost"
29
+ c.host = 'localhost'
28
30
  c.jar = "#{Dir.pwd}/bin/selenium-server-standalone-2.33.0.jar"
29
31
  end
30
32
  google.visit
31
- google.page_title.should include("Google")
33
+ google.page_title.should include('Google')
32
34
  quit
33
35
  end
34
36
 
35
- it "profile name" do
36
- pending "requires machine setup to run, and need a public example"
37
+ it 'profile name' do
38
+ pending 'requires machine setup to run, and need a public example'
37
39
  SeleniumConnect.configure do |c|
38
- c.profile_name = "YourProfileNameGoesHere"
40
+ c.profile_name = 'YourProfileNameGoesHere'
39
41
  end
40
42
  end
41
43
 
42
- it "profile path" do
43
- pending "need to add a profile to the repo"
44
+ it 'profile path' do
45
+ pending 'need to add a profile to the repo'
44
46
  SeleniumConnect.configure do |c|
45
47
  c.profile_path = "#{Dir.pwd}/path/to/profile"
46
48
  end
47
49
  end
48
50
 
49
- it "browser path" do
50
- #example only works on Mac
51
+ it 'browser path' do
52
+ # example only works on Mac
51
53
  SeleniumConnect.configure do |c|
52
- c.browser = "firefox"
53
- c.browser_path = "/Applications/Firefox.app/Contents/MacOS/firefox"
54
+ c.browser = 'firefox'
55
+ c.browser_path = '/Applications/Firefox.app/Contents/MacOS/firefox'
54
56
  end
55
57
  google.visit
56
- google.page_title.should include("Google")
58
+ google.page_title.should include('Google')
57
59
  quit
58
60
  end
59
61
 
@@ -1,26 +1,28 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
  require_relative 'helper'
3
5
 
4
- describe "Headless" do
6
+ describe 'Headless', selenium: true do
5
7
 
6
8
  let(:google) { Google.new(SeleniumConnect.start) }
7
9
  let(:quit) { SeleniumConnect.finish }
8
10
 
9
- it "should run a basic test with phantom js" do
11
+ it 'should run a basic test with phantom js' do
10
12
  SeleniumConnect.configure do |c|
11
- c.browser = "phantomjs"
13
+ c.browser = 'phantomjs'
12
14
  end
13
15
  google.visit
14
- google.page_title.should include("Google")
16
+ google.page_title.should include('Google')
15
17
  quit
16
18
  end
17
19
 
18
- it "should not find something on a page" do
20
+ it 'should not find something on a page' do
19
21
  SeleniumConnect.configure do |c|
20
- c.browser = "phantomjs"
22
+ c.browser = 'phantomjs'
21
23
  end
22
24
  google.visit
23
- google.page_title.should_not include("Poogle")
25
+ google.page_title.should_not include('Poogle')
24
26
  quit
25
27
  end
26
28
 
@@ -1,3 +1,5 @@
1
+ # Encoding: utf-8
2
+
1
3
  class Google
2
4
  attr_accessor :page
3
5
 
@@ -6,7 +8,7 @@ class Google
6
8
  end
7
9
 
8
10
  def visit
9
- page.get "http://www.google.com"
11
+ page.get 'http://www.google.com'
10
12
  end
11
13
 
12
14
  def page_title
@@ -1,16 +1,18 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
  require_relative 'helper'
3
5
 
4
- describe "IE" do
6
+ describe 'IE', selenium: true do
5
7
 
6
8
  let(:google) { Google.new(SeleniumConnect.start) }
7
9
  let(:quit) { SeleniumConnect.finish }
8
10
 
9
- it "with Selenium Grid" do
11
+ it 'with Selenium Grid' do
10
12
  pending
11
13
  SeleniumConnect.configure do |c|
12
- c.host = "192.168.1.139"
13
- c.browser = "ie"
14
+ c.host = '192.168.1.139'
15
+ c.browser = 'ie'
14
16
  end
15
17
  driver.get 'https://mashup.ic.mantech.com/ispace'
16
18
  quit
@@ -1,7 +1,9 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
  require_relative 'helper'
3
5
 
4
- describe "Logging" do
6
+ describe 'Logging', selenium: true do
5
7
 
6
8
  before(:all) do
7
9
  @log_dir = 'build'
@@ -14,13 +16,13 @@ describe "Logging" do
14
16
  SeleniumConnect.finish
15
17
  end
16
18
 
17
- it "server" do
18
- server_log = File.read(@log_dir+'/server.log')
19
+ it 'server' do
20
+ server_log = File.read(@log_dir + '/server.log')
19
21
  server_log.empty?.should be false
20
22
  end
21
23
 
22
- it "browser" do
23
- browser_log = File.read(@log_dir+'/firefox.log')
24
+ it 'browser' do
25
+ browser_log = File.read(@log_dir + '/firefox.log')
24
26
  browser_log.empty?.should be false
25
27
  end
26
28
  end
@@ -1,6 +1,8 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
 
3
- describe "Sauce Labs" do
5
+ describe 'Sauce Labs', selenium: true do
4
6
 
5
7
  it 'hello world' do
6
8
  SeleniumConnect.configure do |c|
@@ -0,0 +1,42 @@
1
+ # Encoding: utf-8
2
+
3
+ require 'selenium-connect/configuration'
4
+
5
+ describe SeleniumConnect::Configuration do
6
+
7
+ VALID_JAR = 'test.jar'
8
+ VALID_HOST = '111.000.111.000'
9
+ VALID_SAUCE_USERNAME = 'test_user_name'
10
+
11
+ before :each do
12
+ @configuration = SeleniumConnect::Configuration.new
13
+ end
14
+
15
+ it 'can be populated by a hash' do
16
+ @configuration.populate_with_hash jar: VALID_JAR, host: VALID_HOST
17
+ @configuration.jar.should eq VALID_JAR
18
+ @configuration.host.should eq VALID_HOST
19
+ end
20
+
21
+ it 'can be populated with a yaml file' do
22
+ @configuration.populate_with_yaml "#{Dir.pwd}/spec/example.yaml"
23
+ @configuration.sauce_username.should eq VALID_SAUCE_USERNAME
24
+ end
25
+
26
+ it 'supports the config_file= method' do
27
+ @configuration.config_file= "#{Dir.pwd}/spec/example.yaml"
28
+ @configuration.sauce_username.should eq VALID_SAUCE_USERNAME
29
+ end
30
+
31
+ it 'should throw an exception for unsupported config variable' do
32
+ expect do
33
+ @configuration.hash = { bad: 'config-value' }
34
+ end.to raise_error NoMethodError
35
+ end
36
+
37
+ it 'sensible defaults persist when nothing is set' do
38
+ @configuration.host.should eq 'localhost'
39
+ @configuration.port.should eq 4444
40
+ @configuration.browser.should eq 'firefox'
41
+ end
42
+ end
data/spec/example.yaml CHANGED
@@ -1,23 +1,23 @@
1
- #Setup & Debugging
1
+ # Setup & Debugging
2
2
  jar:
3
3
  log:
4
4
 
5
5
 
6
- #Where to run your tests
6
+ # Where to run your tests
7
7
  host: 'localhost'
8
8
  port:
9
9
 
10
10
 
11
- #Browser
11
+ # Browser
12
12
  browser: 'firefox'
13
13
  browser_path:
14
14
  profile_path:
15
15
  profile_name:
16
16
 
17
17
 
18
- #Saucelabs
18
+ # Saucelabs
19
19
  os:
20
- sauce_username:
20
+ sauce_username: 'test_user_name'
21
21
  sauce_api_key:
22
22
  browser_version:
23
23
  description:
@@ -1,9 +1,11 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
 
3
- describe "Quit and Finish" do
5
+ describe 'Quit and Finish', selenium: true do
4
6
 
5
- it "quit when already finished doesn't blow up" do
6
- SeleniumConnect.configure do |c| end
7
+ it 'quit when already finished doesn\'t blow up' do
8
+ SeleniumConnect.configure {}
7
9
  @driver = SeleniumConnect.start
8
10
  @driver.quit
9
11
  SeleniumConnect.finish
@@ -1,23 +1,25 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect/configuration'
2
4
  require 'selenium-connect/runners/phantomjs'
3
5
  require 'selenium-webdriver'
4
6
 
5
- describe "phantomjs runner" do
6
- it "should match against phantomjs if configured as such" do
7
+ describe 'phantomjs runner', selenium: true do
8
+ it 'should match against phantomjs if configured as such' do
7
9
  config = SeleniumConnect::Configuration.new
8
10
  config.browser = 'phantomjs'
9
11
  runner = SeleniumConnect::Runner::PhantomJS.new(config)
10
12
  runner.match?.should be_true
11
13
  end
12
14
 
13
- it "should not match if there is a different browser specified" do
15
+ it 'should not match if there is a different browser specified' do
14
16
  config = SeleniumConnect::Configuration.new
15
17
  config.browser = 'chrome'
16
18
  runner = SeleniumConnect::Runner::PhantomJS.new(config)
17
19
  runner.match?.should be_false
18
20
  end
19
21
 
20
- it "should return a browser capabilities object for the browser on launch" do
22
+ it 'should return a browser capabilities object for the browser on launch' do
21
23
  config = SeleniumConnect::Configuration.new
22
24
  config.browser = 'phantomjs'
23
25
  runner = SeleniumConnect::Runner::PhantomJS.new(config)
data/spec/yaml_spec.rb CHANGED
@@ -1,17 +1,46 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'selenium-connect'
2
4
 
3
- describe "YAML" do
5
+ describe 'YAML' do
4
6
 
5
7
  it 'setting config_file returns a proper config object' do
6
8
  SeleniumConnect.configure do |c|
7
9
  c.config_file = "#{Dir.pwd}/spec/example.yaml"
8
10
  end
9
11
  config = SeleniumConnect.debug_config
10
- config.class.should == SeleniumConnect::Configuration
11
- config.inspect.empty?.should == false
12
+ config.class.should eq SeleniumConnect::Configuration
13
+ config.inspect.empty?.should be_false
14
+ end
15
+
16
+ it 'chrome', wip: true, selenium: true do
17
+ SeleniumConnect.configure do |c|
18
+ c.config_file = "#{Dir.pwd}/spec/example.yaml"
19
+ end
20
+ driver = SeleniumConnect.start
21
+ driver.get 'http://google.com'
22
+ SeleniumConnect.finish
23
+ end
24
+
25
+ it 'chrome', wip: true, selenium: true do
26
+ SeleniumConnect.configure do |c|
27
+ c.config_file = "#{Dir.pwd}/spec/example.yaml"
28
+ end
29
+ driver = SeleniumConnect.start
30
+ driver.get 'http://google.com'
31
+ SeleniumConnect.finish
32
+ end
33
+
34
+ it 'chrome', wip: true, selenium: true do
35
+ SeleniumConnect.configure do |c|
36
+ c.config_file = "#{Dir.pwd}/spec/example.yaml"
37
+ end
38
+ driver = SeleniumConnect.start
39
+ driver.get 'http://google.com'
40
+ SeleniumConnect.finish
12
41
  end
13
42
 
14
- it 'chrome', :wip => true do
43
+ it 'chrome', wip: true, selenium: true do
15
44
  SeleniumConnect.configure do |c|
16
45
  c.config_file = "#{Dir.pwd}/spec/example.yaml"
17
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-27 00:00:00.000000000 Z
13
+ date: 2013-07-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: selenium-webdriver
@@ -76,8 +76,23 @@ dependencies:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
- description: Added the latest selenium server jar to the gem, updated documentation,
80
- and fixed a performance issue when running against localhost.
79
+ - !ruby/object:Gem::Dependency
80
+ name: rubocop
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 0.9.0
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 0.9.0
95
+ description: Updated configuration methods and improved code quality.
81
96
  email:
82
97
  - dave@arrgyle.com
83
98
  - jason@arrgyle.com
@@ -86,8 +101,10 @@ extensions: []
86
101
  extra_rdoc_files: []
87
102
  files:
88
103
  - .gitignore
104
+ - .rubocop.yml
89
105
  - .ruby-gemset
90
106
  - .ruby-version
107
+ - .travis.yml
91
108
  - CHANGELOG.md
92
109
  - Gemfile
93
110
  - README.md
@@ -113,6 +130,7 @@ files:
113
130
  - spec/acceptance/ie_spec.rb
114
131
  - spec/acceptance/logging_spec.rb
115
132
  - spec/acceptance/sauce_spec.rb
133
+ - spec/configuration_spec.rb
116
134
  - spec/example.yaml
117
135
  - spec/quit_and_finish_spec.rb
118
136
  - spec/runners/phantomjs_spec.rb
@@ -136,6 +154,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
154
  - - ! '>='
137
155
  - !ruby/object:Gem::Version
138
156
  version: '0'
157
+ segments:
158
+ - 0
159
+ hash: 2242765007989864300
139
160
  requirements: []
140
161
  rubyforge_project:
141
162
  rubygems_version: 1.8.25