capybara_angular_helpers 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/lib/capybara_angular_helpers.rb +26 -9
- data/lib/capybara_angular_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92df3b8c246265cf954ed7cbd8968eddc64c13da
|
4
|
+
data.tar.gz: e5f2905bedb65a5963b3b241207310d9172b3ef3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28074a6a30665da9b2595c5f790a7c3900ead0a0888aa984df232afbda6d60678c161f3beaed9c1d1bcc086194ec9f3bd41a6759d8a607dd8b980a5f2030fd8b
|
7
|
+
data.tar.gz: e78ada88af276cd6b6edbdcc8764d6304a74a4db5349c8e8a543a248b9e06df65a77583cf9eeb6e6e9dea8471136c91a76d7da711fa756adfb7c71e87962d56c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CapybaraAngularHelpers
|
2
2
|
|
3
|
-
Helpers for writing integration tests against Angular apps. Also includes helpers for the Ionic framework.
|
3
|
+
Helpers for writing integration tests against Angular apps using capybara + rspec. Also includes helpers for the Ionic framework.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -10,4 +10,23 @@ gem 'capybara_angular_helpers'
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
|
13
|
+
```ruby
|
14
|
+
visit '/app/'
|
15
|
+
|
16
|
+
ng_click_on 'Sign up'
|
17
|
+
|
18
|
+
# if there are multiple buttons/link with the same title
|
19
|
+
ng_click_on 'Sign up', index: 1
|
20
|
+
|
21
|
+
ng_fill_in 'registration.email', with: 'parent@example.com'
|
22
|
+
|
23
|
+
# if there are multiple elements with the same model reference
|
24
|
+
ng_fill_in 'child.name', with: 'Fred', index: 0
|
25
|
+
|
26
|
+
ng_ionic_list_item_click_on 'List Item 1'
|
27
|
+
|
28
|
+
ng_ionic_click_right_nav
|
29
|
+
ng_ionic_click_left_nav
|
30
|
+
|
31
|
+
ng_toggle 'child.split_earnings'
|
32
|
+
```
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "capybara_angular_helpers/version"
|
2
|
-
require 'rspec/
|
2
|
+
require 'rspec/core'
|
3
3
|
|
4
4
|
module CapybaraAngularHelpers
|
5
5
|
def ng_fill_in(target, opts)
|
@@ -7,13 +7,15 @@ module CapybaraAngularHelpers
|
|
7
7
|
opts = opts.to_s
|
8
8
|
end
|
9
9
|
|
10
|
-
if opts.is_a?(String)
|
10
|
+
if opts.is_a?(String) || opts.is_a?(TrueClass) || opts.is_a?(FalseClass)
|
11
11
|
opts = { with: opts }
|
12
12
|
end
|
13
13
|
|
14
|
-
selector =
|
15
|
-
|
16
|
-
|
14
|
+
selector = [
|
15
|
+
"input[ng-model='#{target}']",
|
16
|
+
"textarea[ng-model='#{target}']",
|
17
|
+
"select[ng-model='#{target}']",
|
18
|
+
].join(',')
|
17
19
|
|
18
20
|
if element_index = opts[:index]
|
19
21
|
target_element = all(selector)[element_index]
|
@@ -32,10 +34,19 @@ module CapybaraAngularHelpers
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
37
|
+
def ng_toggle(target)
|
38
|
+
find(:css, "div[ng-model='#{target}'] .toggle").click
|
39
|
+
end
|
40
|
+
|
35
41
|
def ng_click_on(target, opts = {})
|
36
|
-
selector =
|
37
|
-
|
38
|
-
|
42
|
+
selector = [
|
43
|
+
'*[ui-sref]',
|
44
|
+
'*[ng-click]',
|
45
|
+
'*[menu-toggle]',
|
46
|
+
'.tab-item',
|
47
|
+
'button',
|
48
|
+
].join(',')
|
49
|
+
|
39
50
|
if element_index = opts[:index]
|
40
51
|
target_element = all(selector, text: target)[element_index]
|
41
52
|
|
@@ -50,7 +61,13 @@ module CapybaraAngularHelpers
|
|
50
61
|
end
|
51
62
|
|
52
63
|
def ng_ionic_click_left_nav
|
53
|
-
|
64
|
+
left_nav_button = begin
|
65
|
+
find('ion-header-bar .buttons-left button')
|
66
|
+
rescue Capybara::ElementNotFound
|
67
|
+
find('ion-header-bar .back-button')
|
68
|
+
end
|
69
|
+
|
70
|
+
left_nav_button.click
|
54
71
|
end
|
55
72
|
|
56
73
|
def ng_ionic_click_right_nav
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara_angular_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bianco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|