#238 ✓resolved
Matt Colyer

undefined method `silence_stream'

Reported by Matt Colyer | April 30th, 2009 @ 12:14 PM

When I am attempting to run Webrat 0.4.4 (through Cucumber) in Selenium mode in Merb 1.0.11 with RSpec I get the following error:

undefined method silence_stream'

I believe that Rails might be adding this as a kernel method (http://api.rubyonrails.org/class... so it doesn't appear for most people. I ended up working around it by adding to selenium_session.rb. It's a hack but I wasn't sure of a better way to resolve it.


module Kernel
  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
  end
end

Comments and changes to this ticket

  • Corey Donohoe

    Corey Donohoe May 8th, 2009 @ 04:37 PM

    I have the same problem.

  • gaffo

    gaffo May 10th, 2009 @ 10:31 PM

    • Tag changed from bug, merb, selenium to bug, merb, selenium, verify
    • State changed from “new” to “open”

    Guys, Is this still an issue with webrat? Also it would be quite helpful to have this in the form of a patch or a pull request. Finally, if there was a failing test, it would help us as none of us are merb experts (the code was donated and it typically just "works"). However, thanks for the report!

  • Matt Colyer

    Matt Colyer May 11th, 2009 @ 11:57 PM

    This is still an issue. I am not sure how you want to fix it.

    The code depends on a kernel method that doesn't exist (it's added by Rails). Would you guys like to add your own set of kernel methods? This seems like the wrong solution as it isn't DRY.

  • gaffo

    gaffo May 12th, 2009 @ 11:20 AM

    • State changed from “open” to “awaiting-patch”

    This is used in several spots. It doesn't seem to violate dry to me because it's not really from the Kernel and is something we need. I would say that we implement it ourselves. It's redundant in rails mode but that's about it. We might change the method name though.

    Future note, silence stream is a block method that takes a given IO stream and keeps it from talking, example:

    
            silence_stream(STDOUT) do
              TCPSocket.wait_for_service_with_timeout \
                :host     => Webrat.configuration.application_address,
                :port     => Webrat.configuration.application_port.to_i,
                :timeout  => 30 # seconds
            end
    
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) May 12th, 2009 @ 12:40 PM

    Hey,

    I forked webrat and added a the #silence_stream method. Have a look at the implementation and feel free to pull it in if it fits your needs.

    I tested it in my merb app and it works.

    cheers snusnu

  • gaffo

    gaffo May 12th, 2009 @ 12:44 PM

    • State changed from “awaiting-patch” to “awaiting-merge”

    So this is only a selenium issue? it seemed like this was being used in more that just the selenium spot.

    Brynary, Need to test patch out a bit in other modes.

    snusnu (nice nick by the way), thanks for the patch. We will hopefully get on this soon.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) May 12th, 2009 @ 12:57 PM

    I did a "Find in project" for silence_stream and the only results I got back were selenium related.

    futurama forever :-)

  • gaffo

    gaffo May 12th, 2009 @ 04:21 PM

    I refactored your commit a bit, it's now at:

    http://github.com/gaffo/webrat/t...

    See if that still covers it.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) May 12th, 2009 @ 04:37 PM

    Heh, I initially thought about putting it under core_extensions. Then I thought, hey, it's no core_extension after all!

    Anyways, here's what I get with your latest version:

    undefined method silence_stream' for #<Webrat::Selenium::SeleniumRCServer:0x3b85cec> (NoMethodError)

      ./features/support/selenium.rb:8:in `/^I am not logged in$/'
      features/authentication/login.feature:8:in `Given I am not logged in'
    
    
  • gaffo

    gaffo May 12th, 2009 @ 04:44 PM

    Hrm, I hate to say it but I think we need an integration environment for this so that we can make sure that this environment comes up correctly.

    Could you take a look under specs/integration and see if there is one already?

    That would help me test it much easier.

    Thanks.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) May 12th, 2009 @ 04:58 PM

    Hmm I don't really know what you mean? There is a little merb app under specs/integration, but it doesn't seem to really spec a lot? I also noticed that the spec_helper.rb for the whole specsuite sets the mode to :merb ?

    When I run rake spec in webrat I get

    356 examples, 0 failures, 14 pending

    Unfortunately I have to leave now, but I think I'll be online again in about 2-3 hours probably

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) May 12th, 2009 @ 11:06 PM

    I updated my patch and extracted silence_stream into its own file. I also renamed the module to Webrat::Selenium::SilenceStream. However I didn't put it under core_extensions but under selenium because it's only used inside the selenium support and it simply is no core extension.

    I also decided to require it only if active_support hasn't already defined it. Why do it twice ...

    http://github.com/snusnu/webrat/...

  • Bryan Helmkamp

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

Referenced by

Pages