rspec-html-matchers 0.4.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61c40089154ba9a7a570f4991d6d54bbb58725a3
4
- data.tar.gz: 4246eccfcc5ec3f701714dc0be5d0ffb5305f0b2
3
+ metadata.gz: c6328e772ffb7996623cb71c27d5769a2a321023
4
+ data.tar.gz: 0471f0b792afa788a578b429b76168a28892dd1d
5
5
  SHA512:
6
- metadata.gz: d43888afd5230a76c22b77a5be9a1c5073b95a329455700110ce80640a9e84f3b7555c1aefbe1f1d9223b6fd6493c9dad07693e905de81503a8664eeb5615986
7
- data.tar.gz: bb39df942cb75d2af535de0509a1b603d1b2885a2a7dd1f1c4fe887387f133994994c0acb01dc403ee319b6158bee5c5bb6f667496bc2f5fe791f2c76a149af6
6
+ metadata.gz: 671556c67549c13a77754f096fa180508d68a073c87bba231322cef2962664b7af8aa30c0a85662164bb8507bd278618a7bcacabf7b379f534953547ec852e14
7
+ data.tar.gz: 686ddbb59fa4ea2fc203c7990bdb1e99e813e06f771b8e3da44e6058e44c01e9c0c7b84fb46df30c5319f03e4d7456857e01841d8072c6ad418208ad64680f27
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
+ language: ruby
1
2
  before_script:
2
3
  - "export DISPLAY=:99.0"
3
4
  - "sh -e /etc/init.d/xvfb start"
4
5
  rvm:
5
- - ree
6
- - 1.8.7
7
- - 1.9.2
8
6
  - 1.9.3
9
7
  - 2.0.0
8
+ #- jruby-19mode
9
+ - rbx-19mode
data/CHANGELOG.md CHANGED
@@ -4,18 +4,22 @@ Changelog
4
4
  unreleased(TODO)
5
5
  ----------------
6
6
 
7
- * add :without to have\_tag? like have_tag('div', :without => { :class => 'test' })
8
7
  * with_tag should raise error when used outside have_tag
9
8
  * add ability to have_form('/url', 'PUT') or have_form('/url', :PUT)
10
9
  * inteligent check comments(make sure it is not searching inside comments)
11
10
  * shouldn't show all markup in error message if it is too big
11
+ * order matching
12
12
 
13
- 0.5.0(TODO)
14
- -----------
13
+ 0.5.0
14
+ -----
15
15
 
16
- * order matching
17
16
  * improve documentation, add more usage examples (look at changelog and code!)
18
17
 
18
+ 0.4.2
19
+ -----
20
+
21
+ * added :without to have\_tag? like have_tag('div', :without => { :class => 'test' }) NOTE: currently only classes supported
22
+
19
23
  0.4.1
20
24
  -----
21
25
 
data/README.md CHANGED
@@ -95,6 +95,16 @@ Input could be any html string. Let's take a look at these examples:
95
95
  '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :with => { :class => ['qwe', 'rty'] })
96
96
  ```
97
97
 
98
+ The same works with `:without`:
99
+
100
+ ```ruby
101
+ # all of this are equivalent:
102
+ '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :without => { :class => 'qwe rty' })
103
+ '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :without => { :class => 'rty qwe' })
104
+ '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :without => { :class => ['rty', 'qwe'] })
105
+ '<p class="qwe rty" id="qwerty">Paragraph</p>'.should have_tag('p', :without => { :class => ['qwe', 'rty'] })
106
+ ```
107
+
98
108
  * content matching:
99
109
 
100
110
  ```ruby
@@ -172,7 +182,7 @@ Contributors
172
182
  - [Simon Schoeters](https://github.com/cimm)
173
183
  - [Felix Tjandrawibawa](https://github.com/cemenghttps://github.com/cemeng)
174
184
  - [Szymon Przybył](https://github.com/apocalyptiq)
175
- - [Howard Wilson](https://github.com/watsonbox)
185
+ - [Manuel Meurer](https://github.com/manuelmeurer)
176
186
 
177
187
  MIT Licensed
178
188
  ============
@@ -2,7 +2,7 @@ require 'sinatra/base'
2
2
  require 'capybara/cucumber'
3
3
  require 'rspec-html-matchers'
4
4
 
5
- $ASSETS_DIR = File.expand_path('../../../spec/assets',__FILE__)
5
+ $ASSETS_DIR = File.expand_path('../tmp',__FILE__)
6
6
  $INDEX_HTML = File.join($ASSETS_DIR,'index.html')
7
7
 
8
8
  class SimpleApp < Sinatra::Base
@@ -17,6 +17,10 @@ end
17
17
  Capybara.default_driver = :selenium
18
18
  Capybara.app = SimpleApp
19
19
 
20
+ Before do
21
+ FileUtils.mkdir $ASSETS_DIR
22
+ end
23
+
20
24
  After do
21
- FileUtils.rm $INDEX_HTML
25
+ FileUtils.rm_rf $ASSETS_DIR
22
26
  end
@@ -71,19 +71,21 @@ module RSpec
71
71
  def initialize tag, options={}, &block
72
72
  @tag, @options, @block = tag.to_s, options, block
73
73
 
74
- if attrs = @options.delete(:with)
75
- if classes=attrs.delete(:class)
76
- classes = case classes
77
- when Array
78
- classes.join('.')
79
- when String
80
- classes.gsub("\s",'.')
81
- end
82
- @tag << '.'+classes
74
+ if with_attrs = @options.delete(:with)
75
+ if classes = with_attrs.delete(:class)
76
+ @tag << '.' + classes_to_selector(classes)
77
+ end
78
+ selector = with_attrs.inject('') do |html_attrs_string, (k, v)|
79
+ html_attrs_string << "[#{k}='#{v}']"
80
+ html_attrs_string
81
+ end
82
+ @tag << selector
83
+ end
84
+
85
+ if without_attrs = @options.delete(:without)
86
+ if classes = without_attrs.delete(:class)
87
+ @tag << ":not(.#{classes_to_selector(classes)})"
83
88
  end
84
- html_attrs_string=''
85
- attrs.each_pair { |k,v| html_attrs_string << %Q{[#{k.to_s}='#{v.to_s}']} }
86
- @tag << html_attrs_string
87
89
  end
88
90
 
89
91
  validate_options!
@@ -124,6 +126,15 @@ module RSpec
124
126
 
125
127
  private
126
128
 
129
+ def classes_to_selector(classes)
130
+ case classes
131
+ when Array
132
+ classes.join('.')
133
+ when String
134
+ classes.gsub(/\s+/, '.')
135
+ end
136
+ end
137
+
127
138
  def tag_presents?
128
139
  if @current_scope.first
129
140
  @count = @current_scope.count
@@ -380,6 +391,7 @@ module RSpec
380
391
  should_not_have_input(options)
381
392
  end
382
393
 
394
+ # TODO add ability to explicitly say that value should be empty
383
395
  def with_password_field name, value=nil
384
396
  options = form_tag_options('password',name,value)
385
397
  should_have_input(options)
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'rspec-html-matchers'
6
- s.version = '0.4.1'
6
+ s.version = '0.4.2'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['kucaahbe']
9
9
  s.email = ['kucaahbe@ukr.net']
@@ -26,7 +26,9 @@ DESC
26
26
  s.add_development_dependency 'simplecov'
27
27
  s.add_development_dependency 'cucumber'
28
28
  s.add_development_dependency 'capybara'
29
+ s.add_development_dependency 'selenium-webdriver'
29
30
  s.add_development_dependency 'sinatra'
30
31
  s.add_development_dependency 'rake'
31
32
  s.add_development_dependency 'rspec', '>= 2.11.0' # in order to use new expect().to syntax
33
+ s.add_development_dependency 'travis-lint'
32
34
  end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ <div class="foo bar"></div>
File without changes
@@ -98,6 +98,22 @@ describe 'have_tag' do
98
98
 
99
99
  end
100
100
 
101
+ context "with additional HTML attributes (:without option)" do
102
+ asset 'single_element'
103
+
104
+ it "should find tags that have classes specified via array (or string)" do
105
+ rendered.should_not have_tag('div', :without => { :class => %w(foo bar) })
106
+ rendered.should_not have_tag('div', :without => { :class => 'foo bar' })
107
+ rendered.should_not have_tag('div', :without => { :class => 'foo' })
108
+ rendered.should_not have_tag('div', :without => { :class => 'bar' })
109
+ end
110
+
111
+ it "should not find tags that have classes specified via array (or string)" do
112
+ rendered.should have_tag('div', :without => { :class => %w(foo baz) })
113
+ rendered.should have_tag('div', :without => { :class => 'foo baz' })
114
+ rendered.should have_tag('div', :without => { :class => 'baz' })
115
+ end
116
+ end
101
117
  end
102
118
 
103
119
  context "by count" do
@@ -224,7 +240,7 @@ describe 'have_tag' do
224
240
  end
225
241
 
226
242
  it "should find with unicode text specified" do
227
- expect { rendered.should have_tag('a', :text => "học") }.to_not raise_exception(Encoding::CompatibilityError) if RUBY_VERSION =~ /^1\.9/
243
+ expect { rendered.should have_tag('a', :text => "học") }.not_to raise_error
228
244
  rendered.should have_tag('a', :text => "học")
229
245
  end
230
246
 
data/spec/spec_helper.rb CHANGED
@@ -8,14 +8,19 @@ end
8
8
 
9
9
  require 'rspec-html-matchers'
10
10
 
11
- SPEC_DIR = File.dirname(__FILE__)
12
-
13
11
  module AssetHelpers
14
12
 
13
+ ASSETS = File.expand_path('../fixtures/%s.html',__FILE__)
14
+
15
15
  def asset name
16
- let :rendered do
17
- IO.read File.join(SPEC_DIR,"assets/#{name}.html")
18
- end
16
+ asset_content = fixtures[name] ||= IO.read(ASSETS%name)
17
+ let(:rendered) { asset_content }
18
+ end
19
+
20
+ private
21
+
22
+ def fixtures
23
+ @assets ||= {}
19
24
  end
20
25
 
21
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-html-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kucaahbe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-23 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: selenium-webdriver
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: sinatra
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - '>='
123
137
  - !ruby/object:Gem::Version
124
138
  version: 2.11.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: travis-lint
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: |
126
154
  Nokogiri based 'have_tag' and 'with_tag' matchers for rspec 2.x.x. Does not depend on assert_select matcher, provides useful error messages.
127
155
  email:
@@ -144,12 +172,13 @@ files:
144
172
  - features/support/env.rb
145
173
  - lib/rspec-html-matchers.rb
146
174
  - rspec-html-matchers.gemspec
147
- - spec/assets/form.html
148
- - spec/assets/ordered_list.html
149
- - spec/assets/paragraphs.html
150
- - spec/assets/quotes.html
151
- - spec/assets/search_and_submit.html
152
- - spec/assets/special.html
175
+ - spec/fixtures/form.html
176
+ - spec/fixtures/ordered_list.html
177
+ - spec/fixtures/paragraphs.html
178
+ - spec/fixtures/quotes.html
179
+ - spec/fixtures/search_and_submit.html
180
+ - spec/fixtures/single_element.html
181
+ - spec/fixtures/special.html
153
182
  - spec/matchers/form_matchers_spec.rb
154
183
  - spec/matchers/have_tag_spec.rb
155
184
  - spec/spec_helper.rb
@@ -172,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
201
  version: '0'
173
202
  requirements: []
174
203
  rubyforge_project: rspec-html-matchers
175
- rubygems_version: 2.0.0
204
+ rubygems_version: 2.0.3
176
205
  signing_key:
177
206
  specification_version: 4
178
207
  summary: Nokogiri based 'have_tag' and 'with_tag' matchers for rspec 2.x.x