protractor-rails 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2d19507f5e5cad0d7b0637528266cd95a11b7fb
4
+ data.tar.gz: 556d7f32fd514d753a44cd5cedbe95b57e1678a0
5
+ SHA512:
6
+ metadata.gz: 967de443c66e8bf2cfad70734b0afab04a43b5aad6c5c192d10e665271fa1736cfd9e0666c55b0a25bd65b2ec2212033ade3e51e512ccf9fc15c52ca1d45bd35
7
+ data.tar.gz: 2bc78a1f6fa73387298da3bf04b01f5a55ed9ac16b2b56899c5d2eb909b118816d8180ea77619ed71646b248cda9b97fbf5f4bb0f9c97195d35d54a2655072eb
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .ruby-gemset
2
+ spec/javascripts/protractor.conf.js
3
+ spec/javascripts/example_spec.js
4
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in protractor-rails.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ protractor-rails (0.0.2)
5
+ colorize
6
+ railties
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (4.0.3)
12
+ activesupport (= 4.0.3)
13
+ builder (~> 3.1.0)
14
+ erubis (~> 2.7.0)
15
+ rack (~> 1.5.2)
16
+ rack-test (~> 0.6.2)
17
+ activesupport (4.0.3)
18
+ i18n (~> 0.6, >= 0.6.4)
19
+ minitest (~> 4.2)
20
+ multi_json (~> 1.3)
21
+ thread_safe (~> 0.1)
22
+ tzinfo (~> 0.3.37)
23
+ atomic (1.1.16)
24
+ builder (3.1.4)
25
+ colorize (0.7.0)
26
+ erubis (2.7.0)
27
+ i18n (0.6.9)
28
+ minitest (4.7.5)
29
+ multi_json (1.9.0)
30
+ rack (1.5.2)
31
+ rack-test (0.6.2)
32
+ rack (>= 1.0)
33
+ railties (4.0.3)
34
+ actionpack (= 4.0.3)
35
+ activesupport (= 4.0.3)
36
+ rake (>= 0.8.7)
37
+ thor (>= 0.18.1, < 2.0)
38
+ rake (10.1.1)
39
+ thor (0.18.1)
40
+ thread_safe (0.3.0)
41
+ atomic (>= 1.1.7, < 2)
42
+ tzinfo (0.3.39)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ bundler (~> 1.5)
49
+ protractor-rails!
50
+ rake
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tyrone
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Protractor::Rails
2
+
3
+ This gem helps you to not go through the same pain that I did trying to figure out the best way to run angularjs e2e tests in a rails application.
4
+
5
+ NB: This gem is in pre-release so don't use it yet.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'protractor-rails'
12
+
13
+ And then execute the following command to load dependencies on your machine:
14
+
15
+ $ rake protractor:install
16
+
17
+ You can test that everything has been set up correctly using the command below.
18
+ This command will run protractor's example configuration and test file against the
19
+ http://angular.org website. If everything starts up ok and runs till the end giving you
20
+ a summary of test results then you are 'good to go'!
21
+
22
+ $ rake protractor:example
23
+
24
+ NB: This uses `sudo` so you will need to enter your password
25
+
26
+ ## Usage
27
+
28
+
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( http://github.com/<my-github-username>/protractor-rails/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ load 'lib/tasks/install.rake'
4
+ load 'lib/tasks/protractor.rake'
@@ -0,0 +1,10 @@
1
+ module Protractor
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ rake_tasks do
5
+ load File.expand_path('../../../tasks/install.rake', __FILE__)
6
+ load File.expand_path('../../../tasks/protractor.rake', __FILE__)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Protractor
2
+ module Rails
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ require "protractor/rails/version"
2
+ require 'protractor/rails/railtie'
3
+
4
+ module Protractor
5
+ module Rails
6
+ class PlatformHelper
7
+ def self.mac?
8
+ RbConfig::CONFIG['target_os'] =~ /darwin/i
9
+ end
10
+
11
+ def self.linux?
12
+ RbConfig::CONFIG['target_os'] =~ /linux/i
13
+ end
14
+
15
+ def self.windows?
16
+ RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ require 'protractor/rails'
@@ -0,0 +1,65 @@
1
+ require 'colorize'
2
+
3
+ namespace :protractor do
4
+ desc "Install dependencies for running protractor on your machine"
5
+ task :install => [:install_nodejs, :install_protractor, :install_webdriver] do
6
+ end
7
+
8
+ task :install_nodejs do
9
+ if linux?
10
+ puts "Installing NodeJS via apt-get...".green
11
+ system "sudo apt-get -y install nodejs"
12
+ elsif mac?
13
+ puts "Installing NodeJS via homebrew...[THIS IS NOT TESTED YET I DON'T HAVE A MAC]".green
14
+ system "brew install nodejs"
15
+ elsif windows?
16
+ puts "Thank you for choosing to use protractor-rails. Unfortunately Windows is not yet supported. Feel free to contribute.".red
17
+ end
18
+ end
19
+
20
+ task :install_protractor do
21
+ puts "Installing Protractor using npm installer".green
22
+ system "sudo npm install -g protractor"
23
+ end
24
+
25
+ task :install_webdriver do
26
+ puts "Installing webdriver using protractor install manager...".green
27
+ system "sudo webdriver-manager update"
28
+ end
29
+
30
+ desc "Initialize protractor rails."
31
+ task :init do
32
+ if !File.directory?('spec/javascripts')
33
+ if !File.directory?('spec')
34
+ puts "create spec directory".yellow
35
+ `mkdir spec`
36
+ end
37
+ puts "Create spec/javascripts directory".yellow
38
+ `mkdir spec/javascripts`
39
+ end
40
+ if !File.exist?('spec/javascripts/protractor.conf.js')
41
+ puts "Creating template configuration file in spec/javascripts/protractor.conf.js".green
42
+ template_path = File.expand_path('../../../spec/javascripts/templates', __FILE__)
43
+ template_conf = File.join(template_path, 'protractor.conf.js')
44
+ template_spec = File.join(template_path, 'example_spec.js')
45
+ system "cp #{template_conf} spec/javascripts/protractor.conf.js"
46
+ puts "You will need to edit the spec/javascripts/protractor.conf.js file to suite your requirements."
47
+ system "cp #{template_spec} spec/javascripts/example_spec.js"
48
+ puts "created example_spec.js in spec/javascripts. You can test it out by running rake protractor:spec"
49
+ else
50
+ puts "You already have a configuration file. If you would like to start over, remove spec/javascripts/protractor.conf.js and run rake protractor:init".red
51
+ end
52
+ end
53
+ end
54
+
55
+ def mac?
56
+ RbConfig::CONFIG['target_os'] =~ /darwin/i
57
+ end
58
+
59
+ def linux?
60
+ RbConfig::CONFIG['target_os'] =~ /linux/i
61
+ end
62
+
63
+ def windows?
64
+ RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
65
+ end
@@ -0,0 +1,83 @@
1
+ namespace :protractor do
2
+ desc "starts protractor example test to see if you have your system set up correctly"
3
+ task :example do
4
+ begin
5
+ webdriver_pid = fork do
6
+ Rake::Task["protractor:webdriver"].invoke
7
+ end
8
+ puts "Waiting for test server and webdriver server to start"
9
+ sleep 5
10
+ file = File.expand_path('../../../spec/protractor_example.conf.js', __FILE__)
11
+ system "protractor #{file}"
12
+ ensure
13
+ Rake::Task["protractor:kill_webdriver"].invoke
14
+ Rake::Task["protractor:kill_selenium_processes"].invoke
15
+ end
16
+ end
17
+
18
+ desc "Run specs from spec/javascripts/protractor.conf.js"
19
+ task :spec do
20
+ begin
21
+ webdriver_pid = fork do
22
+ Rake::Task['protractor:webdriver'].invoke
23
+ end
24
+ rails_server_pid = fork do
25
+ Rake::Task['protractor:rails'].invoke
26
+ end
27
+ puts "webdriver PID: #{webdriver_pid}".yellow.bold
28
+ puts "Rails Server PID: #{rails_server_pid}".yellow.bold
29
+ puts "Waiting for servers to finish starting up...."
30
+ sleep 6
31
+ system 'protractor spec/javascripts/protractor.conf.js'
32
+ Process.kill 'TERM', webdriver_pid
33
+ Process.kill 'TERM', rails_server_pid
34
+ Process.wait webdriver_pid
35
+ Process.wait rails_server_pid
36
+ puts "Waiting to shut down cleanly.........".yellow.bold
37
+ sleep 5
38
+ rescue Exception => e
39
+ puts e
40
+ ensure
41
+ Rake::Task["protractor:kill"].invoke
42
+ end
43
+ end
44
+
45
+ task :spec_and_cleanup => [:spec, :cleanup]
46
+
47
+ task :kill do
48
+ puts "killing running protractor processes".green.bold
49
+ Rake::Task["protractor:kill_rails"].invoke
50
+ Rake::Task["protractor:kill_webdriver"].invoke
51
+ Rake::Task["protractor:kill_selenium_processes"].invoke
52
+ end
53
+
54
+ task :kill_selenium_processes do
55
+ puts "kill left over selenium processes...".yellow
56
+ system "ps aux | grep -ie 'protractor\/selenium' | awk '{print $2}' | xargs kill -9"
57
+ end
58
+
59
+ task :kill_webdriver do
60
+ puts "kill webdriver server...".yellow
61
+ system "ps aux | grep -ie '\-Dwebdriver' | awk '{print $2}' | xargs kill -9"
62
+ end
63
+
64
+ task :kill_rails do
65
+ puts "kill protractor rails tests server...".yellow
66
+ system "ps aux | grep -ie 'rails s -e test --port=4000 -P tmp/pids/protractor_test_server.pid' | awk '{print $2}' | xargs kill -9"
67
+ end
68
+
69
+ task :rails do
70
+ puts "Starting Rails server on port 4000 pid file in tmp/pids/protractor_test_server.pid".green
71
+ system 'rails s -e test --port=4000 -P tmp/pids/protractor_test_server.pid'
72
+ end
73
+
74
+ task :webdriver do
75
+ puts "Starting selenium server".green
76
+ system "webdriver-manager start"
77
+ end
78
+
79
+ task :cleanup do
80
+ puts "rake db:test:prepare to cleanup for the next test session".green.bold
81
+ system 'rake db:test:prepare --trace'
82
+ end
83
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path('../lib/protractor/rails/version', __FILE__)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "protractor-rails"
7
+ spec.version = Protractor::Rails::VERSION
8
+ spec.authors = ["Tyrone Wilson"]
9
+ spec.email = ["tdubs241083@gmail.com"]
10
+ spec.summary = %q{Seemlessly run protractor for angularjs in your rails app.}
11
+ spec.description = %q{Protractor rails makes it a bit easier to integrate and run angularjs' protractor e2e test framework directly in your rails app.}
12
+ spec.homepage = "http://github.com/tyronewilson/protractor-rails"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_runtime_dependency 'colorize'
23
+ spec.add_runtime_dependency 'railties'
24
+ end
@@ -0,0 +1,37 @@
1
+ describe('angularjs homepage', function() {
2
+ it('should greet the named user', function() {
3
+ browser.get('http://www.angularjs.org');
4
+
5
+ element(by.model('yourName')).sendKeys('Julie');
6
+
7
+ var greeting = element(by.binding('yourName'));
8
+
9
+ expect(greeting.getText()).toEqual('Hello Julie!');
10
+ });
11
+
12
+ describe('todo list', function() {
13
+ var todoList;
14
+
15
+ beforeEach(function() {
16
+ browser.get('http://www.angularjs.org');
17
+
18
+ todoList = element.all(by.repeater('todo in todos'));
19
+ });
20
+
21
+ it('should list todos', function() {
22
+ expect(todoList.count()).toEqual(2);
23
+ expect(todoList.get(1).getText()).toEqual('build an angular app');
24
+ });
25
+
26
+ it('should add a todo', function() {
27
+ var addTodo = element(by.model('todoText'));
28
+ var addButton = element(by.css('[value="add"]'));
29
+
30
+ addTodo.sendKeys('write a protractor test');
31
+ addButton.click();
32
+
33
+ expect(todoList.count()).toEqual(3);
34
+ expect(todoList.get(2).getText()).toEqual('write a protractor test');
35
+ });
36
+ });
37
+ });
@@ -0,0 +1,5 @@
1
+ describe('Example Specifcation', function() {
2
+ it('should be able to find the rails test server', function(done) {
3
+ expect(true).toBeTruthy();
4
+ })
5
+ });
@@ -0,0 +1,23 @@
1
+ // An example configuration file.
2
+ exports.config = {
3
+ // The address of a running selenium server.
4
+ seleniumAddress: 'http://localhost:4444/wd/hub',
5
+
6
+ // Capabilities to be passed to the webdriver instance.
7
+ capabilities: {
8
+ 'browserName': 'chrome'
9
+ },
10
+
11
+ // Spec patterns are relative to the current working directly when
12
+ // protractor is called.
13
+ specs: ['example_spec.js '],
14
+
15
+ baseUrl: 'http://localhost:4000',
16
+
17
+ // Options to be passed to Jasmine-node.
18
+ jasmineNodeOpts: {
19
+ showColors: true,
20
+ defaultTimeoutInterval: 30000
21
+ },
22
+
23
+ };
@@ -0,0 +1,20 @@
1
+ // An example configuration file.
2
+ exports.config = {
3
+ // The address of a running selenium server.
4
+ seleniumAddress: 'http://localhost:4444/wd/hub',
5
+
6
+ // Capabilities to be passed to the webdriver instance.
7
+ capabilities: {
8
+ 'browserName': 'chrome'
9
+ },
10
+
11
+ // Spec patterns are relative to the current working directly when
12
+ // protractor is called.
13
+ specs: ['example_spec.js'],
14
+
15
+ // Options to be passed to Jasmine-node.
16
+ jasmineNodeOpts: {
17
+ showColors: true,
18
+ defaultTimeoutInterval: 30000
19
+ }
20
+ };
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: protractor-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tyrone Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: railties
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Protractor rails makes it a bit easier to integrate and run angularjs'
70
+ protractor e2e test framework directly in your rails app.
71
+ email:
72
+ - tdubs241083@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/protractor-rails.rb
84
+ - lib/protractor/rails.rb
85
+ - lib/protractor/rails/railtie.rb
86
+ - lib/protractor/rails/version.rb
87
+ - lib/tasks/install.rake
88
+ - lib/tasks/protractor.rake
89
+ - protractor-rails.gemspec
90
+ - spec/example_spec.js
91
+ - spec/javascripts/templates/example_spec.js
92
+ - spec/javascripts/templates/protractor.conf.js
93
+ - spec/protractor_example.conf.js
94
+ homepage: http://github.com/tyronewilson/protractor-rails
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Seemlessly run protractor for angularjs in your rails app.
118
+ test_files:
119
+ - spec/example_spec.js
120
+ - spec/javascripts/templates/example_spec.js
121
+ - spec/javascripts/templates/protractor.conf.js
122
+ - spec/protractor_example.conf.js