jnicklas/capybara — Issue #588: Css and related to it selectors fails
Author: jalkoby
Created: 2012-01-03 18:16:22+00:00
State: open

I'm update master branch of capybara and run my requests specs. And fails on everyone, where used has_selector? and related find_link, find, all and etc. The error was:

```ruby
can't convert Array into String
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css/tokenizer.rb:19:in `initialize'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css/tokenizer.rb:19:in `new'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css/tokenizer.rb:19:in `scan_setup'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:61:in `parse'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:79:in `xpath_for'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/nokogiri-1.5.0/lib/nokogiri/css.rb:23:in `xpath_for'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/gems/xpath-0.1.4/lib/xpath.rb:59:in `css'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/selector.rb:34:in `css'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/selector.rb:51:in `call'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/selector.rb:51:in `call'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/query.rb:23:in `initialize'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/node/finders.rb:112:in `new'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/node/finders.rb:112:in `all'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/node/matchers.rb:38:in `has_selector?'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/node/base.rb:46:in `wait_until'
/Users/sergeypchelincev/.rvm/gems/ree-1.8.7-2011.12@fotoshkola/bundler/gems/capybara-363b43acb738/lib/capybara/node/matchers.rb:37:in `has_selector?'

```

After spending some time with source code I find a problem. It was in lib/capybara/selector.rb 34 line

```ruby
31 def css(&block)
33 if block
34 @xpath = xpath { |*args| XPath.css(block.call(*args)) }
35 end
36 @xpath
37 end
```
Instead of putting all params, I'm passed only first and error gone.

Or maybe better remove xpath_options below in method call

```ruby
def call(locator, xpath_options={})
@xpath.call(locator, xpath_options)
end
```
I didn't find where them applied, but them also create warning
```ruby
multiple values for a block parameter (2 for 1)
```