rspec-html-matchers 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ .rvmrc
5
+ Gemfile.lock
6
+ # documentation:
7
+ html
8
+ doc
9
+ .yardoc
10
+ coverage
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - ree
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --readme README.md
3
+ --files CHANGELOG.md
4
+ --markup rdoc
data/CHANGELOG.md ADDED
@@ -0,0 +1,87 @@
1
+ Changelog
2
+ =========
3
+
4
+ unreleased(TODO)
5
+ ----------------
6
+
7
+ * improve documentation(look at changelog and code!)
8
+ * add description
9
+ * add :without to have\_tag?
10
+
11
+ 0.2.2
12
+ -----
13
+
14
+ * leading and trailing whitespaces are ignored in tags where they should be ignored(#11, and again thanks to [Simon Schoeters](http://github.com/cimm))
15
+ * whitespaces ignoring as browser does in :text matching
16
+ * have_tag backwards compability(thanks to [Felix Tjandrawibawa](https://github.com/cemenghttps://github.com/cemeng), #12)
17
+
18
+ 0.2.1
19
+ -----
20
+
21
+ * make possible use non-string as :text option(#10, thanks for idea to [Simon Schoeters](http://github.com/cimm))
22
+
23
+ 0.2.0
24
+ -----
25
+
26
+ * a little bit refactoring
27
+ * added some html5 inputs
28
+ * added message for should\_not
29
+ * raise exception when wrong parametres specified(:count and :minimum (or :maximum) simultaneously)
30
+ * support all versions of nokogiri since 1.4.4
31
+
32
+ 0.1.6 (nokogiri update)
33
+ -----------------------
34
+
35
+ * updated <strong>nokogiri</strong> to <strong>1.5.0</strong> version, for nokokiri less than 1.5.0 use 0.0.6 release of this gem
36
+
37
+ 0.0.6
38
+ -----
39
+
40
+ * allow for single quotes in content matchers (thanks to [Kelly Felkins](http://github.com/kellyfelkins)).
41
+
42
+ 0.0.5 (trial-trip)
43
+ ------------------
44
+
45
+ * added some experimental matchers:
46
+ * have\_form
47
+ * with\_hidden\_field
48
+ * with\_text\_field
49
+ * with\_password\_field
50
+ * with\_file\_field?
51
+ * with\_text\_area
52
+ * with\_check\_box
53
+ * with\_radio\_button
54
+ * with\_select
55
+ * with\_option
56
+ * with\_submit
57
+
58
+ 0.0.4 (bugfix)
59
+ --------------
60
+
61
+ * additional parameters(:count,:text,:with) rely on each other to match what exactly tester want to match([link to comment](https://github.com/kucaahbe/rspec2-rails-views-matchers/issues#issue/2/comment/848775))
62
+
63
+ 0.0.3
64
+ -----
65
+
66
+ * now following will work:
67
+
68
+ rendered.should have_tag('div') do
69
+ with_tag('p')
70
+ end
71
+
72
+ * tags can be specified via symbol
73
+ * classes can be specified via array or string(class-names separated by spaces), so following will work:
74
+
75
+ '<div class="one two">'.should have_tag('div', :with => { :class => ['two', 'one'] })
76
+ '<div class="one two">'.should have_tag('div', :with => { :class => 'two one' })
77
+
78
+ 0.0.2
79
+ ------
80
+
81
+ * documented source code
82
+ * added changelog
83
+
84
+ 0.0.1
85
+ ------
86
+
87
+ * all needed options and error messages
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ Test views, be true! :) [![Build Status](http://travis-ci.org/kucaahbe/rspec-html-matchers.png)](http://travis-ci.org/kucaahbe/rspec-html-matchers)
2
+ =======================
3
+
4
+ [![Mikhalok](https://github.com/kucaahbe/rspec-html-matchers/raw/master/mikhalok.jpg)](http://www.myspace.com/lyapis "Lyapis Trubetskoy ska-punk band")
5
+
6
+ Why?
7
+ ===
8
+
9
+ * you need to test some complex views
10
+ * and you want to use RSpec2
11
+ * and assert\_select seems is something strange to you
12
+ * have_tag in [rspec-rails](http://github.com/rspec/rspec-rails) are deprecated now
13
+ * you need a user-firendly output in your error messages
14
+
15
+ Being true
16
+ ==========
17
+
18
+ Install
19
+ -------
20
+
21
+ Add to your Gemfile (in the :test group :) ):
22
+
23
+ group :test do
24
+ gem 'rspec-html-matchers'
25
+ end
26
+
27
+ Instructions for [installing Nokogiri](http://nokogiri.org/tutorials/installing_nokogiri.html).
28
+
29
+ Usage
30
+ -----
31
+
32
+ Simple example:
33
+
34
+ view=<<-HTML
35
+ <h1>Simple Form</h1>
36
+ <form action="/users" method="post">
37
+ <p>
38
+ <input type="email" name="user[email]" />
39
+ </p>
40
+ <p>
41
+ <input type="submit" id="special_submit" />
42
+ </p>
43
+ </form>
44
+ HTML
45
+
46
+ view.should have_tag('form', :with => { :action => '/users', :method => 'post' }) do
47
+ with_tag "input", :with => { :name => "user[email]", :type => 'email' }
48
+ with_tag "input#special_submit", :count => 1
49
+ without_tag "h1", :text => 'unneeded tag'
50
+ without_tag "p", :text => /content/i
51
+ end
52
+
53
+ Also included special matchers for form inputs:
54
+ -----------------------------------------------
55
+
56
+ - [have\_form](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:have_form)
57
+ - [with\_checkbox](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_checkbox)
58
+ - [with\_email\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_email_field)
59
+ - [with\_file\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_file_field)
60
+ - [with\_hidden\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_hidden_field)
61
+ - [with\_option](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_option)
62
+ - [with\_password_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_password_field)
63
+ - [with\_radio\_button](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_radio_button)
64
+ - [with\_button](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_button)
65
+ - [with\_select](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_select)
66
+ - [with\_submit](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_submit)
67
+ - [with\_text\_area](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_text_area)
68
+ - [with\_text\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_text_field)
69
+ - [with\_url\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_url_field)
70
+ - [with\_number\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_number_field)
71
+ - [with\_range\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_range_field)
72
+ - [with\_date\_field](http://rdoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers:with_date_field)
73
+
74
+ and of course you can use the `without_` matchers (see the documentation).
75
+
76
+ More info
77
+ ---------
78
+
79
+ You can find more on [RubyDoc](http://rubydoc.info/github/kucaahbe/rspec-html-matchers/master/RSpec/Matchers), take a look at {RSpec::Matchers#have\_tag have\_tag} method.
80
+
81
+ Also, please read {file:CHANGELOG.md CHANGELOG}, it might be helpful.
82
+
83
+ Contribution
84
+ ============
85
+
86
+ 1. Fork the repository
87
+ 2. Add tests for your feature
88
+ 3. Write the code
89
+ 4. Send a pull request
90
+
91
+ Contributors
92
+ ============
93
+
94
+ - [Kelly Felkins](http://github.com/kellyfelkins)
95
+ - [Ryan Wilcox](http://github.com/rwilcox)
96
+ - [Simon Schoeters](https://github.com/cimm)
97
+ - [Felix Tjandrawibawa](https://github.com/cemenghttps://github.com/cemeng)
98
+ - [Szymon Przybył](https://github.com/apocalyptiq)
99
+
100
+ MIT Licensed
101
+ ============
102
+
103
+ Copyright (c) 2011 Dmitry Mjakotny
104
+
105
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
106
+
107
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
108
+
109
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ gemspec = eval(File.read(Dir["*.gemspec"].first))
6
+
7
+ task :default => :spec
8
+
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ t.rspec_opts='--tag ~wip'
11
+ end
12
+
13
+ desc "Validate the gemspec"
14
+ task :gemspec do
15
+ gemspec.validate && puts('gemspec valid')
16
+ end
17
+
18
+ namespace :spec do
19
+ RSpec::Core::RakeTask.new(:wip) do |t|
20
+ t.rspec_opts='--tag wip'
21
+ t.fail_on_error = false
22
+ end
23
+
24
+ RSpec::Core::RakeTask.new(:rcov) do |t|
25
+ t.rspec_opts=['-r simplecov']
26
+ end
27
+ end
data/assets/form.html ADDED
@@ -0,0 +1,139 @@
1
+ <form action="/books" class="formtastic book" id="new_book" method="post">
2
+ <div style="margin:0;padding:0;display:inline">
3
+ <input name="authenticity_token" type="hidden" value="718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=" />
4
+ </div>
5
+
6
+ <fieldset class="inputs">
7
+ <ol>
8
+ <li class="select required" id="book_publisher_input">
9
+ <label for="book_publisher_id">
10
+ Publisher<abbr title="required">*</abbr>
11
+ </label>
12
+ <select id="book_publisher_id" name="book[publisher_id]">
13
+ <option value=""></option>
14
+ <option value="1" selected="selected">The Pragmatic Bookshelf</option>
15
+ <option value="2">sitepoint</option>
16
+ <option value="3">O'Reilly</option>
17
+ </select>
18
+ </li>
19
+
20
+ <li class="string required" id="book_title_input">
21
+ <label for="book_title">
22
+ Title<abbr title="required">*</abbr>
23
+ </label>
24
+ <input id="book_title" maxlength="255" name="book[title]" size="50" type="text" />
25
+ </li>
26
+
27
+ <li class="string required" id="book_author_input">
28
+ <label for="book_author">
29
+ Author<abbr title="required">*</abbr>
30
+ </label>
31
+ <input id="book_author" maxlength="255" name="book[author]" size="50" type="text" value="Authorname" />
32
+ </li>
33
+
34
+ <li class="email optional" id="user_email_input">
35
+ <label for="user_email">
36
+ E-mail address:
37
+ </label>
38
+ <input id="user_email" name="user[email]" size="30" type="email" value="email@example.com" />
39
+ </li>
40
+
41
+ <li class="email_confirmation optional" id="user_email_confirmation_input">
42
+ <label for="user_email_confirmation">
43
+ E-mail address confirmation:
44
+ </label>
45
+ <input id="user_email_confirmation" name="user[email_confirmation]" size="30" type="email" />
46
+ </li>
47
+
48
+ <li class="url optional" id="user_url_input">
49
+ <label for="user_url">
50
+ E-mail address:
51
+ </label>
52
+ <input id="user_url" name="user[url]" size="30" type="url" value="http://user.com" />
53
+ </li>
54
+
55
+ <li class="password optional" id="user_password_input">
56
+ <label for="user_password">
57
+ Password:
58
+ </label>
59
+ <input id="user_password" name="user[password]" size="30" type="password" />
60
+ </li>
61
+
62
+ <li class="file optional" id="form_file_input">
63
+ <label for="form_file">
64
+ File
65
+ </label>
66
+ <input id="form_file" name="form[file]" type="file" />
67
+ </li>
68
+
69
+ <li class="text required" id="book_description_input">
70
+ <label for="book_description">
71
+ Description<abbr title="required">*</abbr>
72
+ </label>
73
+ <textarea cols="40" id="book_description" name="book[description]" rows="20"></textarea>
74
+ </li>
75
+
76
+ <li class="boolean required" id="book_still_in_print_input">
77
+ <label for="book_still_in_print">
78
+ Still in print<abbr title="required">*</abbr>
79
+ </label>
80
+ <input name="book[still_in_print]" type="hidden" value="0" />
81
+ <input id="book_still_in_print" name="book[still_in_print]" type="checkbox" value="1" />
82
+ </li>
83
+ <li class="number required">
84
+ <label for="book_number">
85
+ Still in print<abbr title="required">*</abbr>
86
+ </label>
87
+ <input name="number" type="number" />
88
+ <input name="number_defined" type="number" value="3" />
89
+ </li>
90
+
91
+ <li class="range required">
92
+ <label for="range">
93
+ Still in print<abbr title="required">*</abbr>
94
+ </label>
95
+ <input name="range1" type="range" min="1" max="3" />
96
+ <input name="range2" type="range" min="1" max="3" value="2" />
97
+ </li>
98
+
99
+ <li class="date required">
100
+ <label for="date">
101
+ Something<abbr title="required">*</abbr>
102
+ </label>
103
+ <input name="book_date" type="date" />
104
+ <input name="book_month" type="month" value="5" />
105
+ <input name="book_week" type="week" />
106
+ <input name="book_time" type="time" />
107
+ <input name="book_datetime" type="datetime" />
108
+ <input name="book_datetime_local" type="datetime-local" />
109
+ </li>
110
+
111
+ <li class="radio required" id="form_name_input">
112
+ <fieldset>
113
+ <legend class="label">
114
+ <label>Name<abbr title="required">*</abbr></label>
115
+ </legend>
116
+ <ol>
117
+ <li class="name_true">
118
+ <label for="form_name_true">
119
+ <input id="form_name_true" name="form[name]" type="radio" value="true" /> Yes
120
+ </label>
121
+ </li>
122
+ <li class="name_false">
123
+ <label for="form_name_false">
124
+ <input id="form_name_false" name="form[name]" type="radio" value="false" /> No</label>
125
+ </li>
126
+ </ol>
127
+ </fieldset>
128
+ </li>
129
+ </ol>
130
+ </fieldset>
131
+
132
+ <fieldset class="buttons">
133
+ <ol>
134
+ <li class="commit">
135
+ <input class="create" id="book_submit" name="commit" type="submit" value="Create Book" />
136
+ </li>
137
+ </ol>
138
+ </fieldset>
139
+ </form>
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <body>
3
+ <ol class="menu">
4
+ <li>list item 1</li>
5
+ <li>list item 2</li>
6
+ <li>list item 3</li>
7
+ </ol>
8
+ </body>
9
+ </html>
@@ -0,0 +1,3 @@
1
+ <p>tag one</p>
2
+ <p>tag two</p>
3
+ <p>tag three</p>
@@ -0,0 +1,24 @@
1
+ <div>sample text</div>
2
+ <span>sample with 'single' quotes</span>
3
+ <span>sample with 'single' and "double" quotes</span>
4
+ <p>one</p>
5
+ <p>two</p>
6
+ <p>three </p>
7
+ <p>315</p>
8
+ <p>
9
+ content with ignored spaces around
10
+ </p>
11
+ <p>
12
+ content with ignored spaces in
13
+ </p>
14
+ <p>
15
+ content&nbsp;with&nbsp;nbsp
16
+ </p>
17
+ <p>
18
+ content with&nbsp;nbsp &nbsp;and&nbsp; spaces &nbsp; around
19
+ </p>
20
+ <pre> 1. bla
21
+ 2. bla </pre>
22
+ <!--
23
+ vim:list
24
+ -->
@@ -0,0 +1,9 @@
1
+ <div class="class-one class-two">
2
+ some content
3
+ <div id="div">some other div</div>
4
+ <p class="paragraph">la<strong>lala</strong></p>
5
+ </div>
6
+ <form id="some_form">
7
+ <input id="search" type="text" />
8
+ <input type="submit" value="Save" />
9
+ </form>