rspec-dom-testing 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2d4e5fe014c90325aa00c2a09b712e062a5bd704
4
+ data.tar.gz: 5d5ca1f8d2ae4f2669bf69a3b171cf8e5ec85784
5
+ SHA512:
6
+ metadata.gz: de05c7d361fb6f95576ac231ccd7730524e6937297ec9147ba1186ac384ca3130c6d0ef8f975e0f5a850a8fcdf6d14100f3ad112e6d579133890286431967299
7
+ data.tar.gz: 62e66d372c6f22b1e00100c720c6821fae376ea821d9515b5b34d93bc5248971376564da4a7b1ba07db68bc9618d9e8c865ed98d2f24373222cd706fdd92b2b7
@@ -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
+ /spec/examples.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ cache:
3
+ - bundler
4
+ language: ruby
5
+ rvm:
6
+ - 2.1.8
7
+ - 2.2.4
8
+ - 2.3.1
9
+ - 2.4.0
@@ -0,0 +1,12 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## [Unreleased]
8
+ ### Added
9
+ - initial release.
10
+ - `have_tag` matcher
11
+ - `have_tag` matcher
12
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-dom-testing.gemspec
4
+ gemspec
@@ -0,0 +1,49 @@
1
+ # RSpec::Dom::Testing [![Build Status](https://travis-ci.org/mikz/rspec-dom-testing.svg?branch=master)](https://travis-ci.org/mikz/rspec-dom-testing)
2
+
3
+ This gem wraps [`rails-dom-testing`](https://github.com/rails/rails-dom-testing) helpers as RSpec Matchers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-dom-testing', group: :test
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rspec-dom-testing
20
+ ## Usage
21
+
22
+ First include the matchers into RSpec:
23
+
24
+ ```ruby
25
+ RSpec.configure do |config|
26
+ config.include RSpec::Dom::Testing::Matchers
27
+ end
28
+ ```
29
+
30
+ Then use them:
31
+
32
+ ```ruby
33
+ RSpec.describe 'matchers' do
34
+ it { expect('<li>text</li>').to have_tag('li', text: 'text') }
35
+ it { expect('<p>example</p>').to have_text(text: 'example') }
36
+ end
37
+ ```
38
+
39
+ For all available options check [rails-dom-testing documentation](http://www.rubydoc.info/gems/rails-dom-testing/Rails/Dom/Testing/Assertions/SelectorAssertions#assert_select-instance_method).
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mikz/rspec-dom-testing
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
9
+ rescue LoadError
10
+ # no rspec available
11
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'rspec/dom/testing'
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(__FILE__)
@@ -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 @@
1
+ require 'rspec/dom/testing/matchers'
@@ -0,0 +1,9 @@
1
+ require 'rspec/dom/testing/version'
2
+ require 'rspec/dom/testing/matchers'
3
+
4
+ module RSpec
5
+ module Dom
6
+ module Testing
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,75 @@
1
+ require 'rspec/matchers/dsl'
2
+ require 'rails-dom-testing'
3
+
4
+ module RSpec
5
+ module Dom
6
+ module Testing
7
+ module Matchers
8
+ extend ::RSpec::Matchers::DSL
9
+
10
+ EMPTY_OPTIONS = {}.freeze
11
+
12
+ module Helper
13
+ include ::Rails::Dom::Testing::Assertions::SelectorAssertions
14
+
15
+ def matches?(actual, &block)
16
+ @actual = actual
17
+ @match = :to
18
+
19
+ match(expected, block)
20
+ end
21
+
22
+ def does_not_match?(actual, &block)
23
+ @actual = actual
24
+ @match = :not_to
25
+
26
+ match(expected, block)
27
+ end
28
+
29
+ def wrap(actual)
30
+ case actual
31
+ when String
32
+ ::Nokogiri::HTML::Document.parse("<html>#{actual}</html>")
33
+ else
34
+ nodeset(actual)
35
+ end
36
+ end
37
+
38
+ def document_root_element
39
+ wrap(actual)
40
+ end
41
+
42
+ def assert_operator(n1, op, n2, message)
43
+ expect(n1).public_send(@match, be.public_send(op, n2), message)
44
+ end
45
+
46
+ def assert_equal(a, b, message)
47
+ expect(a).public_send(@match, eq(b), message)
48
+ end
49
+ end
50
+
51
+ define :have_text do
52
+ include Helper
53
+
54
+ def match(expected, _block)
55
+ text, options = expected
56
+ assert_select('*', text: text, **(options || EMPTY_OPTIONS))
57
+ end
58
+ end
59
+
60
+ define :have_tag do
61
+ include Helper
62
+
63
+ def match(expected, block)
64
+ assert_select(*expected) do |matches|
65
+ if block
66
+ scope = block.binding.eval('self')
67
+ scope.instance_exec(matches, &block)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,7 @@
1
+ module Rspec
2
+ module Dom
3
+ module Testing
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/dom/testing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rspec-dom-testing'
8
+ spec.version = Rspec::Dom::Testing::VERSION
9
+ spec.authors = ['Michal Cichra']
10
+ spec.email = ['michal@cichra.cz']
11
+
12
+ spec.summary = 'Provide has_tag and has_tag matchers.'
13
+ spec.description = 'Wraps rails-dom-testing into RSpec matchers.'
14
+ spec.homepage = 'https://github.com/mikz/rspec-dom-testing'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.14'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_dependency 'rails-dom-testing', '>= 1.0', '< 3'
27
+ spec.add_dependency 'rspec-expectations', '~> 3.0'
28
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-dom-testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michal Cichra
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails-dom-testing
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '3'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '1.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '3'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec-expectations
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description: Wraps rails-dom-testing into RSpec matchers.
90
+ email:
91
+ - michal@cichra.cz
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - CHANGELOG.md
100
+ - Gemfile
101
+ - README.md
102
+ - Rakefile
103
+ - bin/console
104
+ - bin/setup
105
+ - lib/rspec-dom-testing.rb
106
+ - lib/rspec/dom/testing.rb
107
+ - lib/rspec/dom/testing/matchers.rb
108
+ - lib/rspec/dom/testing/version.rb
109
+ - rspec-dom-testing.gemspec
110
+ homepage: https://github.com/mikz/rspec-dom-testing
111
+ licenses: []
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.8
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Provide has_tag and has_tag matchers.
133
+ test_files: []