Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:04:35+00:00 2026-06-07T16:04:35+00:00

I’m just experiencing weird behavior while testing an Goliath API with RSpec. One of

  • 0

I’m just experiencing weird behavior while testing an Goliath API with RSpec. One of my tests looks like this:

require 'helper'

describe Scales::Dispatch do

  it "should return a 404 if resource was not found" do
    with_api(Scales::Server) do
      get_request(:path => '/') do |client|
        client.response_header.http_status.should == 404
      end
    end
  end

  it "should return a resource" do
    Scales::Storage::Sync.set "/existing", "some content"

    with_api(Scales::Server) do
      get_request(:path => '/existing') do |client|
        client.response_header.http_status.should == 200
        client.response.should == "some content"
      end
    end

    Scales::Storage::Sync.del "/existing"
  end

end

The API basically just looks up a key in a redis with the help of em-synchrony/em-hiredis like this:

module Scales
  module Lookup
    class << self

      def request(env)
        response = Storage::Async.get(path(env))
        response.nil? ? render_not_found : render(response)
      end

      private

      def path(env)
        env["REQUEST_URI"]
      end

      def render_not_found
        [404, {}, ""]
      end

      def render(response)
        [200, {}, response]
      end

    end
  end
end

Both tests run individually, but not together. After the first is executed, the whole system stalls about 10 seconds. The second with_api is then called but the get_request is never executed – and i think it is running in some sort of timeout.

I discovered the same behavior at another, pretty similar test which is pushing and popping a queue like this:

describe Scales::Queue::Async do

  [Scales::Queue::Async::Request, Scales::Queue::Async::Response].each do |queue|
    context queue.name.split("::").last do

      it "should place a few jobs" do
        async do
          queue.add "job 1"
          queue.add "job 2"
          queue.add "job 3"
        end
      end

      it "should take them out blocking" do
        async do
          queue.pop.should == "job 1"
          queue.pop.should == "job 2"
          queue.pop.should == "job 3"
        end
      end

    end
  end

end

The contents of second async do .. is also not executed at all. Without goliath loaded a pretty similar test runs perfectly:

require 'eventmachine'
require 'em-synchrony'
require 'em-synchrony/em-hiredis'

module Helpers

  def async
    if EM.reactor_running?
      yield
    else
      out = nil
      EM.synchrony do
        out = yield
        EM.stop
      end
      out
    end
  end

end

RSpec.configure do |config|
  config.include Helpers
  config.treat_symbols_as_metadata_keys_with_true_values = true
end

describe "em-synchrony/em-hiredis" do

  it "should lpush a job" do
    async do
      redis = EM::Hiredis.connect
      redis.lpush("a_queue", "job1")
    end
  end

  it "should block pop a job" do
    async do
      redis = EM::Hiredis.connect
      redis.brpop("a_queue", 0).last.should == "job1"
    end
  end

end

The async do .. for the previous task is the same RSpec helper.

I was searching the whole day like crazy, but to me it doesn’t make any sense. Because the last test is running completely fine, I guess its neither a em-synchrony nor a em-synchrony/em-hiredis thing.

Maybe goliath is not stopping, occupying the EM somewhat too long or so?

Thanks for your help, this is driving me nuts!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:04:36+00:00Added an answer on June 7, 2026 at 4:04 pm

    Okay, I found the solution.

    I checked to connection right before every request and if it was there I didn’t reestablish it. But it appears as every stopping of the eventmachine closes the connection, so basically for every new request there was a connection timeout that failed silently.

    Thanks for your time!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.