capybara_angular_helpers 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06664041f0ec7bd33eaa16a2579666b60b709b01
4
- data.tar.gz: bdf9f6049ae121780fea04f556e260f8f8823a60
3
+ metadata.gz: 92df3b8c246265cf954ed7cbd8968eddc64c13da
4
+ data.tar.gz: e5f2905bedb65a5963b3b241207310d9172b3ef3
5
5
  SHA512:
6
- metadata.gz: 2d6f6124e0db154692b2dc6062bba452f566c3382314edf714288130b76e9ea33a2e7244fcaa3a235ca0f7c2aff5bebbe7e1ae603a4b90a04102ba453398b8c7
7
- data.tar.gz: a4ce4f6858dcd1c1b5bc173a1c0796ead111309ba3ca1eb8b00c58311c0ddae15e02b35934f1b907ed24527d772413b9659395a173ee9b4629faa5aa21098379
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
- TODO: Write usage instructions here
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/rails' unless defined?(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 = "input[ng-model='#{target}']," +
15
- "textarea[ng-model='#{target}']," +
16
- "select[ng-model='#{target}']"
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 = '*[ui-sref],' +
37
- '*[ng-click],' +
38
- 'button'
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
- find('ion-header-bar .buttons-left button').click
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
@@ -1,3 +1,3 @@
1
1
  module CapybaraAngularHelpers
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-07 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec