capybara-angular-material 0.0.6 → 0.0.7

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: 75ec08722d0f63b8456159c512414bd3dda90937
4
- data.tar.gz: 07f8a40a6539a414af74942f2cd9a763a4380ea9
3
+ metadata.gz: 5eb050dd23710256c348fd45309cf835ff8ac94e
4
+ data.tar.gz: 550b5142cc87d32bd190cc495f36e23d1e5976e2
5
5
  SHA512:
6
- metadata.gz: b36b891f00d324aaa1aec195bada1fb5b87dd8e2310f71667e6622038ee2301e2d1d816eacec4a9eb0e8f833e05afaa53f2ecf56a3c1dbc1b52bd6f1ca840533
7
- data.tar.gz: 191fbe76527c8b86634dab602a7e7b67de355a01d2895ece9ab79cceca19cac9b569524b3eb7839a4c2cdab30df4e544e2e67f34b45c51cfa236a695496c71b6
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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'capybara-angular-material'
3
- gem.version = '0.0.6'
3
+ gem.version = '0.0.7'
4
4
  gem.license = 'MIT'
5
5
 
6
6
  gem.authors = ['Rimian Perkins']
@@ -0,0 +1,10 @@
1
+ require 'capybara/angular/material/rspec'
2
+
3
+ module Capybara
4
+ module Angular
5
+ module Material
6
+ include Capybara::Angular::Material::RSpecMatchers
7
+ include Capybara::RSpecMatchers
8
+ end
9
+ end
10
+ end
@@ -2,10 +2,9 @@ module Capybara
2
2
  module Angular
3
3
  module Material
4
4
  module RSpecMatchers
5
- include Capybara::RSpecMatchers
6
-
7
- def have_md_checkbox(*args)
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 or Not' do
4
- visit('/index.html')
5
- expect(page).to have_md_checkbox 'A nice checkbox'
6
- expect(page).not_to have_md_checkbox 'A checkbox that does not exist'
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/rspec'
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::RSpecMatchers
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.6
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-16 00:00:00.000000000 Z
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