rspec2-rails-views-matchers 0.0.1 → 0.0.2

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.
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ # documentation:
4
5
  html
6
+ doc
7
+ .yardoc
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ --readme README.md
3
+ --files docs/CHANGELOG.md
4
+ --markup rdoc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec2-rails-views-matchers (0.0.1)
4
+ rspec2-rails-views-matchers (0.0.2)
5
5
  nokogiri (~> 1.4.4)
6
6
  rspec (>= 2.0.0)
7
7
 
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ Why?
2
+ ===
3
+
4
+ * you need to test some complex views
5
+ * and you want to use rspec2
6
+ * and assert\_select seems is something strange to you
7
+ * [rspec-rails](http://github.com/rspec/rspec-rails) for some reason does not provide instruments for testing views
8
+ * you need user-firendly output in error messages
9
+
10
+ Install
11
+ -------
12
+
13
+ add to your Gemfile(in group :test :) ):
14
+
15
+ gem 'rspec2-rails-views-matchers'
16
+
17
+ Usage
18
+ -----
19
+
20
+ some examples:
21
+
22
+ rendered.should have_tag('form',:with => {:action => user_path, :method => 'post'}) {
23
+ with_tag "input", :with => { :name => "user[email]", :type => 'email' }
24
+ with_tag "input", :with => { :name => "user[password]", :type => 'password' }
25
+ with_tag "input", :with => { :name => "user[password_confirmation]", :type => 'password' }
26
+ with_tag "input#special_submit", :count => 1
27
+ without_tag "h1", :text => 'unneeded tag'
28
+ without_tag "p", :text => /content/i
29
+ }
30
+
31
+ More info
32
+ ---------
33
+
34
+ [On RubyDoc](http://rubydoc.info/gems/rspec2-rails-views-matchers)
data/docs/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ changelog
2
+ =========
3
+
4
+ unreleased(TODO)
5
+ ----------------
6
+
7
+ * add message for should\_not
8
+ * add description
9
+ * raise exception when wrong parametres specified(:count and :minimum simultaneously)
10
+ * organize code
11
+
12
+ 0.0.2
13
+ ------
14
+
15
+ * documented source code
16
+ * added changelog
17
+
18
+ 0.0.1
19
+ ------
20
+
21
+ * all needed options and error messages
@@ -3,6 +3,8 @@ require 'nokogiri'
3
3
  module RSpec
4
4
  module Matchers
5
5
 
6
+ # @api
7
+ # @private
6
8
  class NokogiriMatcher#:nodoc:
7
9
  attr_reader :failure_message
8
10
  attr_reader :parent_scope, :current_scope
@@ -96,19 +98,52 @@ module RSpec
96
98
  end
97
99
  end
98
100
 
99
- # :call-seq:
100
- # rendered.should have_tag(tag,options={},&block)
101
- # rendered.should have_tag(tag,options={},&block) { with_tag(other_tag) }
102
- # string.should have_tag(tag,options={},&block)
101
+ # have_tag matcher
103
102
  #
103
+ # @yield block where you should put with_tag
104
+ #
105
+ # @param [String] tag css selector for tag you want to match
106
+ # @param [Hash] options options hash(see below)
107
+ # @option options [Fixnum] :count count of matched tags(DO NOT USE :count with :minimum(:min) or :maximum(:max)*)
108
+ # @option options [Range] :count count of matched tags should be between range minimum and maximum values
109
+ # @option options [Fixnum] :minimum
110
+ # @option options [Fixnum] :min same as :minimum
111
+ # @option options [Fixnum] :maximum
112
+ # @option options [Fixnum] :max same as :maximum
113
+ #
114
+ #
115
+ # @example
116
+ # rendered.should have_tag('div')
117
+ # rendered.should have_tag('h1.header')
118
+ # rendered.should have_tag('div#footer')
119
+ # rendered.should have_tag('input#email', with => { :name => 'user[email]', :type => 'email' } )
120
+ # rendered.should have_tag('div', :count => 3) # matches exactly 3 'div' tags
121
+ # rendered.should have_tag('div', :count => 3..7) # something like have_tag('div', :minimum => 3, :maximum => 7)
122
+ # rendered.should have_tag('div', :minimum => 3) # matches more(or equal) than 3 'div' tags
123
+ # rendered.should have_tag('div', :maximum => 3) # matches less(or equal) than 3 'div' tags
124
+ # rendered.should have_tag('p', :text => 'some content') # will match "<p>some content</p>"
125
+ # rendered.should have_tag('p', :text => /some content/i) # will match "<p>sOme cOntEnt</p>"
126
+ # "<html>
127
+ # <body>
128
+ # <h1>some html document</h1>
129
+ # </body>
130
+ # </html>".should have_tag('body') { with_tag('h1', :text => 'some html document') }
104
131
  def have_tag tag,options={}, &block
105
132
  @__current_scope_for_nokogiri_matcher = NokogiriMatcher.new(tag, options, &block)
106
133
  end
107
134
 
135
+ # with_tag matcher
136
+ # @yield
137
+ # @see #have_tag
138
+ # @note this should be used within block of have_tag matcher
108
139
  def with_tag tag, options={}, &block
109
140
  @__current_scope_for_nokogiri_matcher.should have_tag(tag, options, &block)
110
141
  end
111
142
 
143
+ # without_tag matcher
144
+ # @yield
145
+ # @see #have_tag
146
+ # @note this should be used within block of have_tag matcher
112
147
  def without_tag tag, options={}, &block
113
148
  @__current_scope_for_nokogiri_matcher.should_not have_tag(tag, options, &block)
114
149
  end
@@ -1,8 +1,12 @@
1
1
  module RSpec#:nodoc:
2
+ # @private
2
3
  module Rails#:nodoc:
4
+ # @private
3
5
  module Views#:nodoc:
6
+ # @private
4
7
  module Matchers#:nodoc:
5
- VERSION = "0.0.1"
8
+ # @private
9
+ VERSION = "0.0.2"
6
10
  end
7
11
  end
8
12
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "rspec/rails/views/matchers/version"
3
+ require "version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rspec2-rails-views-matchers"
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["kucaahbe"]
10
10
  s.email = ["kucaahbe@ukr.net"]
11
- s.homepage = ""
12
- s.summary = %q{collection of rspec2 views matchers for rails}
11
+ s.homepage = "http://github.com/kucaahbe/rspec2-rails-views-matchers"
12
+ s.summary = %q{Nokogiri based 'have_tag' and 'with_tag' for rspec-2 without assert_select dependencies and useful error messages}
13
13
  s.description = s.summary
14
14
 
15
15
  s.rubyforge_project = "rspec2-rails-views-matchers"
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rspec/rails/views/matchers'
1
+ require 'rspec2-rails-views-matchers'
2
2
 
3
3
  # Requires supporting files with custom matchers and macros, etc,
4
4
  # # in ./support/ and its subdirectories.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec2-rails-views-matchers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - kucaahbe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-21 00:00:00 +02:00
18
+ date: 2011-02-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: 1.4.4
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
- description: collection of rspec2 views matchers for rails
53
+ description: Nokogiri based 'have_tag' and 'with_tag' for rspec-2 without assert_select dependencies and useful error messages
54
54
  email:
55
55
  - kucaahbe@ukr.net
56
56
  executables: []
@@ -62,20 +62,22 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
64
  - .rspec
65
+ - .yardopts
65
66
  - Gemfile
66
67
  - Gemfile.lock
67
- - README.rdoc
68
+ - README.md
68
69
  - Rakefile
70
+ - docs/CHANGELOG.md
69
71
  - lib/rspec/rails/views/matchers.rb
70
72
  - lib/rspec/rails/views/matchers/have_tag.rb
71
- - lib/rspec/rails/views/matchers/version.rb
72
73
  - lib/rspec2-rails-views-matchers.rb
74
+ - lib/version.rb
73
75
  - rspec2-rails-views-matchers.gemspec
74
76
  - spec/matchers/have_tag_spec.rb
75
77
  - spec/spec_helper.rb
76
78
  - spec/support/spec_error.rb
77
79
  has_rdoc: true
78
- homepage: ""
80
+ homepage: http://github.com/kucaahbe/rspec2-rails-views-matchers
79
81
  licenses: []
80
82
 
81
83
  post_install_message:
@@ -107,6 +109,6 @@ rubyforge_project: rspec2-rails-views-matchers
107
109
  rubygems_version: 1.5.0
108
110
  signing_key:
109
111
  specification_version: 3
110
- summary: collection of rspec2 views matchers for rails
112
+ summary: Nokogiri based 'have_tag' and 'with_tag' for rspec-2 without assert_select dependencies and useful error messages
111
113
  test_files: []
112
114
 
data/README.rdoc DELETED
@@ -1,24 +0,0 @@
1
- = Why?
2
-
3
- * you need to test some complex views
4
- * and you want to use rspec2
5
- * and assert\_select seems is something strange to you
6
- * rspec-rails[https://github.com/rspec/rspec-rails] for some reason does not provide instruments for testing views
7
- * you need user-firendly output in error messages
8
-
9
- == Install
10
-
11
- add to your Gemfile(in group :test :) ):
12
-
13
- gem 'rspec2-rails-views-matchers'
14
-
15
- == Usage
16
-
17
- descriptive code:
18
-
19
- rendered.should have_tag('form',:with => {:action => user_path, :method => 'post'}) {
20
- with_tag "input", :with => { :name => "user[email]", :type => 'email' }
21
- with_tag "input", :with => { :name => "user[password]", :type => 'password'}
22
- with_tag "input", :with => { :name => "user[password_confirmation]", :type => 'password' }
23
- with_tag "input#special_submit"
24
- }