Trying to rspec from command line, alias_method error #104

Closed
tjgillies opened this Issue Jun 6, 2011 · 4 comments

Comments

Projects
None yet
4 participants

trying this from command line:

mini:plexus-em tyler$ rspec spec/plexus/twitterusers_spec.rb:57
/Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/http_lib_adapters/em_http_request.rb:62:in `alias_method': undefined method `send_request' for class `EventMachine::WebMockHttpRequest' (NameError)
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/http_lib_adapters/em_http_request.rb:62:in `<class:WebMockHttpRequest>'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/http_lib_adapters/em_http_request.rb:6:in `<module:EventMachine>'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/http_lib_adapters/em_http_request.rb:3:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock.rb:13:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/webmock-1.6.4/lib/webmock/rspec.rb:1:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:33:in `require'
    from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/tyler/plexus-em/spec/spec_helper.rb:1:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/tyler/plexus-em/spec/plexus/twitterusers_spec.rb:7:in `<top (required)>'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/configuration.rb:419:in `load'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/configuration.rb:419:in `map'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/runner.rb:69:in `run'
    from /Users/tyler/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.6.3/lib/rspec/core/runner.rb:11:in `block in autorun'

here is my test:

  describe "#set_feed_url" do
    it "should take the url of the user and return a Feedzirra object" do
      people = [{:id => 'tylergillies', :meta =>{'url' => 'http://www.mashable.com'}},
                {:id => 'dude', :meta => {'url' => 'http://www.google.com'}},
                {:id => 'otherdude', :meta => {'url' => 'http://www.google.com'}}]
      stub_request(:any, /.*/). to_return(:body => %Q^<link rel="alternate" type="application/rss+xml" title="Mashable" href="http://feeds.mashable.com/mashable" />^)
      stub_request(:any, /.*/).with(:body => /feeds/).to_return(:body => test_rss)
      @twitterusers.people = people
      @twitterusers.set_feed_url
      @twitterusers.people.should_not be_empty
      @twitterusers.people.each do |person|
          person[:feed].class.to_s.should =~ /Feedzirra::/
      end
    end
  end

and method:

  def set_feed_url

    EM.synchrony{

      multi = EventMachine::Synchrony::Multi.new
      not_checked = @people.select{|person| person[:checked].nil?}
      not_checked.each do |person|
        request =    EventMachine::HttpRequest.new("http://localhost:8080").apost(:body => {:url => person[:meta]['url']},:redirects => 2, :timeout => 20)
        multi.add :"#{person[:id]}",   request
        p "adding #{person[:id]} with #{person[:meta]['url']}"
      end

      res = multi.perform

      res.responses[:callback].each do |id,client|
        person = @people.select{|person| :"#{person[:id]}" == id}.first
        begin
          feed_url = TruffleHog.parse_feed_urls(client.response).first
        rescue
          next
        end
        person[:feed_url] = feed_url
        person[:checked] = true
      end

      multi2 =  EventMachine::Synchrony::Multi.new

      feed_people = @people.select{|person| person[:feed_url]}
      feed_people.each do |person|
        mult = multi2.add  :"#{person[:id]}", EventMachine::HttpRequest.new("http://localhost:8080").apost(:body => {:url => person[:feed_url] },:redirects => 2, :timeout => 20)
        mult
      end

      res2 =  multi2.perform

      res2.responses[:callback].each do |id,client|
        person = @people.select{|person| :"#{person[:id]}" == id}.first
        feed_titles = @people.select{|person| person[:feed]}.map{|person| person[:feed].title}
        debugger
        p "Client Response: #{client.uri}"
        p feed_titles
        begin
          feed = Feedzirra::Feed.parse(client.response)
          if feed_titles.include? feed.title
            next
          end
        rescue
          next
        end
        person[:feed] = feed
        person
      end

      EM.stop

    }
    @people.reject!{|person| !person[:feed]}

  end
Contributor

stephencelis commented Jul 11, 2011

This appears to be an issue with webmock and em-http-request 1.0.0.beta.3+ (and doesn't appear to be fixed on webmock's em-http-request branch.

Contributor

phiggins commented Jul 12, 2011

The em-http-request branch of WebMock was used to add support for em-http-request 0.3.0. There's a branch with support for 1.0.0.beta.3 here: #111

Owner

bblimke commented Jul 30, 2011

Support for the current em-http-request 1.0.x is now in WebMock master

bblimke closed this Jul 30, 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 7/30/11 3:29 PM, bblimke wrote:

Support for the current em-http-request 1.0.x is now in WebMock
master
hooray!!!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJONLF2AAoJEBdkRsOLHIoui18H/2Avv6SmqlMLMYp//Qm6F2AD
K6bD5dkutvD96mJndb7+l3m1YN8SMsWONFzhJFiOaf1qj9vikwIyabO6RbuxO3sp
DuUDWSJ4DjrXd85ftZqyCdcRt0OiNQK0iWI1jaSg/oOdl0NSrKdGWRzbVFJL3Cam
J8SXau6ckduP/ZP7RfBltPT7YWZjAM+LGWitQO4CI1CnO/fBPE7cwLuyz0Ewv3il
m2xpBJtxM9KwMzq+HaONVNF0ZPMpbSXvOM746MTQL3LDnF/kfxYugvbDiLg9vW7p
v93Ov0mSvAKbUY3zra23k2lw4JeBihic6B/57Swc95GsDVwlrVbdqa5FBXIGOyg=
=5BSz
-----END PGP SIGNATURE-----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment