Chris McMahon wrote:
>> From my perspective, I always start out by requiring and including watir,
>> because I'd rather paste it into the top of a script once than have to type
>> Watir:: several times below.
>>
>> I was planning to say that I'd love to have watir automatically included
>> whenever I require it...but that might have resulted in unneccessary
>> confusion when I first started requiring (and wishing to include) other ruby
>> modules. So in the end I think my vote is to teach include from the
>> beginning, but not to have require automagically include as well...since
>> that's not true for other ruby modules.
>>
>
> +1, well put.
>
I don't understand why we treat the Watir module differently from other
Ruby modules. For example, everyone writes
require 'test/unit'
class MyTest < Test::Unit::TestCase
...
end
rather than
require 'test/unit'
include Test::Unit
class MyTest < TestCase
...
end
or
@soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
rather than
include SOAP
@soap = WSDLDriverFactory.new(wsdl_url).create_rpc_driver
or
xml = REXML::Document.new(File.open("demo.xml"))
rather than
include REXML
xml = Document.new(File.open("demo.xml"))
There are consequences to including modules that people should
understand before they make casual use of it. You are collapsing the
namespace and you need to know that you won't create any unexpected
collisions when you do this. For example, i recently added a class
called Watir::Process, but there is also a standard Ruby library called
Process. You could break a library that uses the Process class (from
win32-process) if you mixin the Watir module into the toplevel context.
That's why using include is not an everyday Ruby practice, but rather
typically used to support mixins, rather than simply saving a few
keystrokes. I just don't think we should be teaching bad ruby practices
to Watir users. We already have too many users who don't realize that
Watir is simply another Ruby library. I'd like us to treat it this way,
instead of encouraging our own special (and dangerous)
I do realize that there are many examples in the Watir source base that
use "include Watir", but i guess it is simply time to remove them.
I make use of mixins a lot in my test suites and on several occasions
have run into bugs due to collisions from mixed-in modules. These are
often very difficult problems to figure out. It is much safer to avoid
using them, especially for such trivial reasons as this.
Bret
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general