wildcard_finders 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bde38ec3c83bf76883f655f17c284530da79c1f
4
+ data.tar.gz: 52e3266429b605a07b270f6361c1ad6a80185fac
5
+ SHA512:
6
+ metadata.gz: 2a76774c03d117502799055fc240800da20ec7e0842e074e669959cc993611ad273e2eacd2f7e233c49ac7b652a9f682b9599387dfdc7adc38094b238ba7b7f2
7
+ data.tar.gz: 8e0950902e8f96a6f1f7a9bb32284ba1ac1d9098283174f0e75d0b32f1b681c4ac98f2bac98fa7a01d9fc169e422d6dfa614061d1eaabc2a671a3fbd9d9fcac2
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm gemset use wildcard_finders
1
+ rvm gemset use wildcard_finders --create
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.0.2
2
+ * CHANGE
3
+ * find_tag_like can also accept proc as matcher or block
4
+
5
+ # 0.0.1
6
+
7
+ first release
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem "rspec-parameterized", github: "tomykaira/rspec-parameterized"
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # wildcard_finders
1
+ # wildcard_finders [![Build Status](https://secure.travis-ci.org/okitan/wildcard_finders.png?branch=master)](http://travis-ci.org/okitan/wildcard_finders) [![Dependency Status](https://gemnasium.com/okitan/wildcard_finders.png)](https://gemnasium.com/okitan/wildcard_finders)
2
2
 
3
3
  For people struggling with non-semantic html.
4
4
 
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+
9
+ task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,10 +5,18 @@ module WildcardFinders
5
5
  METHODS = []
6
6
 
7
7
  # not to add METHODS
8
- def find_tag_like(tag, matcher, opts = {})
8
+ def find_tag_like(tag, matcher = nil, opts = {}, &block)
9
9
  tags = all(tag).select do |e|
10
- hash = matcher.keys.each_with_object({}) {|key, h| h[key] = e[key] }
11
- WildcardMatchers.wildcard_match?(hash, matcher)
10
+ if matcher.is_a?(Hash)
11
+ hash = matcher.keys.each_with_object({}) {|key, h| h[key] = e[key] }
12
+ WildcardMatchers.wildcard_match?(hash, matcher)
13
+ elsif block_given? or matcher.is_a?(Proc)
14
+ WildcardMatchers.wildcard_match?(e, block || matcher)
15
+ elsif matcher # I don't know this behavior
16
+ WildcardMatchers.wildcard_match?(e, matcher)
17
+ else
18
+ raise "no matcher or block is not given"
19
+ end
12
20
  end
13
21
 
14
22
  tags.first # not compatible with capybara 2.x
@@ -20,8 +28,8 @@ module WildcardFinders
20
28
 
21
29
  # I'll never add semantic tags
22
30
  %w[ img a input form link ].each do |name|
23
- define_method("find_#{name}_like") do |matcher, opts = {}|
24
- find_tag_like(name, matcher, opts)
31
+ define_method("find_#{name}_like") do |matcher = nil, opts = {}, &block|
32
+ find_tag_like(name, matcher, opts, &block)
25
33
  end
26
34
  end
27
35
 
@@ -0,0 +1,26 @@
1
+ require "bundler/setup"
2
+
3
+ require "wildcard_finders"
4
+
5
+ require "capybara/rspec"
6
+ require "rspec/parameterized"
7
+
8
+ require "test_app"
9
+
10
+ Capybara.configure do |config|
11
+ config.app = Sinatra::Application
12
+ end
13
+
14
+ RSpec.configure do |config|
15
+ config.treat_symbols_as_metadata_keys_with_true_values = true
16
+ config.run_all_when_everything_filtered = true
17
+ config.filter_run :focus
18
+
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = 'random'
24
+
25
+ config.include Capybara::DSL
26
+ end
data/spec/test_app.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "sinatra"
2
+ require "slim"
3
+
4
+ set :slim, layout: :layout
5
+
6
+ get "/a" do
7
+ slim <<_SLIM_
8
+ a id="href_hoge" href="hoge"
9
+ a id="href_fuga" href="fuga"
10
+ a id="onclick_hoge" onclick="hoge"
11
+ _SLIM_
12
+ end
13
+
14
+ __END__
15
+
16
+ @@ layout
17
+ html
18
+ body
19
+ == yield
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe WildcardFinders::Finders do
4
+ include WildcardFinders::Finders
5
+
6
+ context ".find_anchor_like" do
7
+ where(:attr, :value, :expected_id) do
8
+ [ [ :href, /hoge/, "href_hoge" ],
9
+ [ :href, /fuga/, "href_fuga" ],
10
+ [ :onclick, /hoge/, "onclick_hoge" ],
11
+ ]
12
+ end
13
+
14
+ with_them do
15
+ it "with hash as matcher ({ attr => value }) finds" do
16
+ visit "/a"
17
+ page.find_anchor_like(attr => value)[:id].should == expected_id
18
+ end
19
+
20
+ it "with block as matcher ({|e| value === e[attr] }) finds" do
21
+ visit "/a"
22
+ page.find_anchor_like {|e| value === e[attr] }[:id].should == expected_id
23
+ end
24
+
25
+ it "with proc as matcher (->(e) { value === e[attr] }) finds" do
26
+ visit "/a"
27
+ page.find_anchor_like(->(e) { value === e[attr] })[:id].should == expected_id
28
+ end
29
+ end
30
+ end
31
+ end
@@ -17,4 +17,16 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency "capybara"
19
19
  gem.add_dependency "wildcard_matchers"
20
+
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "rspec-parameterized"
24
+
25
+ # for test app
26
+ gem.add_development_dependency "sinatra"
27
+ gem.add_development_dependency "slim"
28
+
29
+ # for debug
30
+ gem.add_development_dependency "tapp"
31
+ gem.add_development_dependency "pry"
20
32
  end
metadata CHANGED
@@ -1,46 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wildcard_finders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - okitan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-25 00:00:00.000000000 Z
11
+ date: 2013-03-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capybara
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: wildcard_matchers
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-parameterized
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sinatra
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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: slim
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: tapp
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
44
137
  - !ruby/object:Gem::Version
45
138
  version: '0'
46
139
  description: finders for capybara
@@ -52,6 +145,8 @@ extra_rdoc_files: []
52
145
  files:
53
146
  - .gitignore
54
147
  - .rvmrc
148
+ - .travis.yml
149
+ - CHANGELOG.md
55
150
  - Gemfile
56
151
  - LICENSE.txt
57
152
  - README.md
@@ -60,30 +155,34 @@ files:
60
155
  - lib/wildcard_finders.rb
61
156
  - lib/wildcard_finders/finders.rb
62
157
  - lib/wildcard_finders/matchers.rb
158
+ - spec/spec_helper.rb
159
+ - spec/test_app.rb
160
+ - spec/wildcard_finders/finders_spec.rb
63
161
  - wildcard_finders.gemspec
64
162
  homepage: https://github.com/okitan/wildcard_finders
65
163
  licenses: []
164
+ metadata: {}
66
165
  post_install_message:
67
166
  rdoc_options: []
68
167
  require_paths:
69
168
  - lib
70
169
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
170
  requirements:
73
- - - ! '>='
171
+ - - '>='
74
172
  - !ruby/object:Gem::Version
75
173
  version: '0'
76
174
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
175
  requirements:
79
- - - ! '>='
176
+ - - '>='
80
177
  - !ruby/object:Gem::Version
81
178
  version: '0'
82
179
  requirements: []
83
180
  rubyforge_project:
84
- rubygems_version: 1.8.24
181
+ rubygems_version: 2.0.3
85
182
  signing_key:
86
- specification_version: 3
183
+ specification_version: 4
87
184
  summary: finders for people strugling non-semantic doms
88
- test_files: []
89
- has_rdoc:
185
+ test_files:
186
+ - spec/spec_helper.rb
187
+ - spec/test_app.rb
188
+ - spec/wildcard_finders/finders_spec.rb