Issue Details (XML | Word | Printable)

Key: WTR-474
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Eric Kolve
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Watir

Watir and Rails 3.0.X incompatible

Created: 16/Mar/11 10:38 PM   Updated: 22/Mar/11 05:10 PM   Resolved: 22/Mar/11 05:10 PM
Component/s: FireWatir
Affects Version/s: 1.7.1
Fix Version/s: Soon

Environment: Fedora Core 13, Rails 3.0.5, commonwatir 1.8.0, firewatir 1.8.0


 Description  « Hide

When creating a new Rails 3.0 project and including firewatir and commonwatir in the list of gems an error is thrown when accessing a controller. Here are the repro steps:

gem install rails
gem install firewatir
gem install commonwatir

> rails new testrails
> cd testrails
> echo 'gem "commonwatir"' >> Gemfile
> echo 'gem "firewatir"' >> Gemfile

> bundle install --deployment

> rails generate controller Pages home

> rails server

From a web browser request the page http://localhost.local:3000/pages/home

The following error is thrown: NoMethodError: undefined method `cache' for :active_support:Symbol

I tracked this down to this file:

commonwatir-1.8.0/lib/watir/core_ext.rb

def underscore
gsub(/\B[A-Z][^A-Z]/, '\&').downcase.gsub(' ', '')
end

The underscore method is added/redefined in the core String class, which Rails also redefines using ActiveSupport::Inflector, but the underscore methods are incompatible. If that method is commented out, the above error is no longer thrown. I'm not sure of a good solution to this. Either rename the method and refactor all the watir code or depend ActiveSupport.



Sort Order: Ascending order - Click to sort in descending order
Jarmo Pertman added a comment - 17/Mar/11 02:44 AM

Adding ActiveSupport dependency is definitely not a solution. We just got rid of it


Bret Pettichord added a comment - 21/Mar/11 03:52 PM

Maybe we could add a guard to our definition of String::underscore, and not define it if it is already defined?


Jarmo Pertman added a comment - 21/Mar/11 04:25 PM

This would work if that other already-defined #underscore method is working the same as Watir's #underscore...


Bret Pettichord added a comment - 21/Mar/11 05:47 PM

My understanding is that we (i.e. me) originally used active support, but that dependency caused problems, so we (i.e. someone else) removed it and instead defined the only method we were using from that library ourselves. This is that method. So by design, it is the same.


Jari Bakken added a comment - 21/Mar/11 08:04 PM

But anyone can define an incompatible String#underscore before loading Watir. I'd look into where it's used in the Watir code base, and either add a #underscore(str) helper to that object, or if it's used in multiple objects, add Watir::Util.underscore(str) or similar.


Jarmo Pertman added a comment - 22/Mar/11 02:16 AM

I agree with Jari that this would be the most sane thing to do. I'll make the needed changes soon if no-one else beats me with that.