capybara-angular-material 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/capybara-angular-material.gemspec +1 -1
- data/lib/capybara/angular/material.rb +10 -0
- data/lib/capybara/angular/material/rspec.rb +3 -4
- data/spec/features/demos/checkbox_spec.rb +42 -4
- data/spec/spec_helper.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb050dd23710256c348fd45309cf835ff8ac94e
|
4
|
+
data.tar.gz: 550b5142cc87d32bd190cc495f36e23d1e5976e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d0a69ef9995850fda241efd84d20837f1cf16e3b3551a14b40fa38789d940739dda402628d94b89c8744fbcb9733c9ed896a00749829490ae43d8793a119035
|
7
|
+
data.tar.gz: 5a4248ae318b965424e8b58a2b4a4661cc975048f681ba89fd3ea85c3b13734cd049e067e50e210758e0d360151a952365de0a481e9e9069696fadd17f2f725e
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
This includes a number of selectors for testing [Angular Material](https://material.angularjs.org) components.
|
7
7
|
|
8
|
+
This is tested using the capybara/poltergeist driver.
|
9
|
+
|
8
10
|
## Installation
|
9
11
|
|
10
12
|
Add this line to your application's Gemfile:
|
@@ -13,6 +15,28 @@ Add this line to your application's Gemfile:
|
|
13
15
|
|
14
16
|
## Usage
|
15
17
|
|
18
|
+
In your spec helper, include the DSL:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'capybara/angular/material'
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
include Capybara::Angular::Material
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
### Checkboxes
|
29
|
+
|
30
|
+
This tag: `<md-checkbox>Some text</md-checkbox>`
|
31
|
+
|
16
32
|
```
|
17
33
|
have_md_checkbox('Some text')
|
18
34
|
```
|
35
|
+
|
36
|
+
Checked is ignored unless set in options:
|
37
|
+
|
38
|
+
```
|
39
|
+
have_md_checkbox('Other thing', :checked => true)
|
40
|
+
```
|
41
|
+
|
42
|
+
Checked boolean is matched against the `aria-checked` attribute.
|
@@ -2,10 +2,9 @@ module Capybara
|
|
2
2
|
module Angular
|
3
3
|
module Material
|
4
4
|
module RSpecMatchers
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
have_selector('md-checkbox', :text => args[0])
|
5
|
+
def have_md_checkbox(locator, options={})
|
6
|
+
checked = "[@aria-checked='#{options[:checked].to_s}']" if options.has_key?(:checked)
|
7
|
+
HaveSelector.new(:xpath, "//md-checkbox#{checked}[normalize-space(text())='#{locator}']", options.reject {|k,v| k == :checked})
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
@@ -1,8 +1,46 @@
|
|
1
1
|
|
2
2
|
feature 'Angular Material Demos - Checkbox' do
|
3
|
-
scenario 'It has a Checkbox
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
scenario 'It has a Checkbox' do
|
4
|
+
expect('<md-checkbox>cheese</md-checkbox>').to have_md_checkbox 'cheese'
|
5
|
+
end
|
6
|
+
|
7
|
+
scenario 'It normalises space' do
|
8
|
+
expect('<md-checkbox> cheese </md-checkbox>').to have_md_checkbox 'cheese'
|
9
|
+
end
|
10
|
+
|
11
|
+
scenario 'It does not have a Checkbox' do
|
12
|
+
expect('<md-checkbox>apple</md-checkbox>').not_to have_md_checkbox 'orange'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does not match part of the text' do
|
16
|
+
expect('<md-checkbox>this is a checkbox with text in it</md-checkbox>').not_to have_md_checkbox('a checkbox')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'is not checked' do
|
20
|
+
expect('<md-checkbox aria-checked="false">zephod</md-checkbox>').to have_md_checkbox('zephod', :checked => false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'is not checked' do
|
24
|
+
expect('<md-checkbox aria-checked="false">zephod</md-checkbox>').not_to have_md_checkbox('zephod', :checked => true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'is checked' do
|
28
|
+
expect('<md-checkbox aria-checked="true">orange</md-checkbox>').to have_md_checkbox('orange', :checked => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is checked' do
|
32
|
+
expect('<md-checkbox aria-checked="true">orange</md-checkbox>').not_to have_md_checkbox('orange', :checked => false)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'page' do
|
36
|
+
before { visit('/index.html') }
|
37
|
+
|
38
|
+
scenario 'It has a Checkbox' do
|
39
|
+
expect(page).to have_md_checkbox 'A nice checkbox'
|
40
|
+
end
|
41
|
+
|
42
|
+
scenario 'It has no Checkbox' do
|
43
|
+
expect(page).not_to have_md_checkbox 'checkbox that does not exist'
|
44
|
+
end
|
7
45
|
end
|
8
46
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,12 +2,12 @@ require 'rack'
|
|
2
2
|
require 'capybara'
|
3
3
|
require 'capybara/rspec'
|
4
4
|
require 'capybara/poltergeist'
|
5
|
-
require 'capybara/angular/material
|
5
|
+
require 'capybara/angular/material'
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
config.order = :random
|
9
9
|
Capybara.default_driver = :poltergeist
|
10
10
|
Capybara.app = Rack::Directory.new('./')
|
11
11
|
|
12
|
-
include Capybara::Angular::Material
|
12
|
+
include Capybara::Angular::Material
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-angular-material
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rimian Perkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- app/js/app.js
|
87
87
|
- capybara-angular-material.gemspec
|
88
88
|
- index.html
|
89
|
+
- lib/capybara/angular/material.rb
|
89
90
|
- lib/capybara/angular/material/rspec.rb
|
90
91
|
- package.json
|
91
92
|
- spec/features/angular_material_spec.rb
|