capybara_angular_helpers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb94ff67d26fcc7566ac5b31dd4c162b58aaa54f
4
+ data.tar.gz: c9a4db8ce2ff5b707a056f9184fffd1e8eaf6bce
5
+ SHA512:
6
+ metadata.gz: a0fe554b0a98e6732e6230f76168225879af16f7af40a3916f43871dbf694a27a9ae909b93a8b48cb87a413f331e5452a3fbaa446317a88582685a68852b0b5a
7
+ data.tar.gz: 428a16a44fd34ffb2de3c9e08da331f9cb2cdc8c8333cc54ae9355180581e224abd43b9ca27d9565276af92967fc018597e176d169142ae699fd4ccb136e1014
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capybara_angular_helpers.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # CapybaraAngularHelpers
2
+
3
+ Helpers for writing integration tests against Angular apps. Also includes helpers for the Ionic framework.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'capybara_angular_helpers'
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ TODO: Write usage instructions here
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capybara_angular_helpers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capybara_angular_helpers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capybara_angular_helpers"
8
+ spec.version = CapybaraAngularHelpers::VERSION
9
+ spec.authors = ["Michael Bianco"]
10
+ spec.email = ["mike@cliffsidemedia.com"]
11
+
12
+ spec.summary = "Helpers for writing integration tests against Angular apps"
13
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/iloveitaly/capybara_angular_helpers"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rspec"
22
+ spec.add_dependency "capybara"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.12"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
@@ -0,0 +1,63 @@
1
+ require "capybara_angular_helpers/version"
2
+
3
+ # https://github.com/ConradIrwin/pry-rescue/commit/b03b3db680430473ef37bd823bbff48f2dcec5c5
4
+ require 'rspec' unless defined?(RSpec)
5
+
6
+ module CapybaraAngularHelpers
7
+ def ng_fill_in(target, opts)
8
+ if opts.is_a?(Fixnum)
9
+ opts = opts.to_s
10
+ end
11
+
12
+ if opts.is_a?(String)
13
+ opts = { with: opts }
14
+ end
15
+
16
+ selector = "input[ng-model='#{target}']"
17
+
18
+ if element_index = opts[:index]
19
+ page_element = all(selector)[element_index]
20
+
21
+ if page_element
22
+ page_element.set(opts[:with])
23
+ else
24
+ raise "#{target} could not be found"
25
+ end
26
+ else
27
+ find(selector).set(opts[:with])
28
+ end
29
+ end
30
+
31
+ def ng_click_on(target)
32
+ begin
33
+ find('*[ui-sref]', text: target)
34
+ rescue Capybara::ElementNotFound
35
+ begin
36
+ find('*[ng-click]', text: target)
37
+ rescue Capybara::ElementNotFound
38
+ find('button', text: target)
39
+ end
40
+ end.click
41
+ end
42
+
43
+ def ng_ionic_click_left_nav
44
+ find('ion-header-bar .buttons-left button').click
45
+ end
46
+
47
+ def ng_ionic_click_right_nav
48
+ find('ion-header-bar .buttons-right button').click
49
+ end
50
+
51
+ def ng_ionic_list_item_click_on(list_item_text, button_text = nil)
52
+ if button_text.nil?
53
+ # find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[contains(text(), '#{target}')]/ancestor-or-self::ion-item").click
54
+ find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[text()[contains(., '#{list_item_text}')]]/ancestor-or-self::ion-item").click
55
+ else
56
+ find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[text()[contains(., '#{list_item_text}')]]/ancestor-or-self::ion-item/descendant-or-self::*[text()[contains(., '#{button_text}')]]").click
57
+ end
58
+ end
59
+ end
60
+
61
+ RSpec.configure do |config|
62
+ config.include CapybaraAngularHelpers
63
+ end
@@ -0,0 +1,3 @@
1
+ module CapybaraAngularHelpers
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara_angular_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Bianco
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description:
84
+ email:
85
+ - mike@cliffsidemedia.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - bin/console
95
+ - bin/setup
96
+ - capybara_angular_helpers.gemspec
97
+ - lib/capybara_angular_helpers.rb
98
+ - lib/capybara_angular_helpers/version.rb
99
+ homepage: https://github.com/iloveitaly/capybara_angular_helpers
100
+ licenses: []
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.6.4
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Helpers for writing integration tests against Angular apps
122
+ test_files: []