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 8889845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:21:42+00:00 2026-06-14T22:21:42+00:00

I have this app: require ‘sinatra/base’ require ‘thin’ class WebService < Sinatra::Base get ‘/’

  • 0

I have this app:

require 'sinatra/base'
require 'thin'

class WebService < Sinatra::Base
  get '/' do
    'hello'
  end
end

EM.run do
  EventMachine.add_periodic_timer(1) do
    puts 'hello'
  end

  Thin::Server.start(WebService)
end

which I need to write a testing script for. the usual approach does not work because the tests never get executed:

class WebServiceTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    WebService
  end

  def test
    get '/'
    assert last_response.ok?
  end
end
  • 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-14T22:21:44+00:00Added an answer on June 14, 2026 at 10:21 pm

    You need to separate your web app from your Event Machine code, so that you can require it with out EM blocking the thread:

    webservice.rb:

    require 'sinatra/base'
    
    class WebService < Sinatra::Base
      get '/' do
        'hello'
      end
    end
    

    app.rb:

    require 'thin'
    require './webservice'
    
    EM.run do
      EventMachine.add_periodic_timer(1) do
        puts 'hello'
      end
    
      Thin::Server.start(WebService)
    end
    

    Then in your test file you can require webservice.rb in order to test it:

    require './webservice'
    
    class WebServiceTest < Test::Unit::TestCase
      include Rack::Test::Methods
    
      def app
        WebService
      end
    
      def test
        get '/'
        assert last_response.ok?
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this app require 'tk' class Foo def my_fancy_function puts hello, world!
I have an app file that looks like this ws_app.rb: require 'rubygems' require 'sinatra'
I copied this class from a similar class I have in this app that
I have Backbone App Here are codes : This is Main.coffee : require [App/app,backbone]
So I have this simple require: require(['app/'+url,'dojo/text!content/'+url], function(module,template){ if(module.init){ module.init({ container: panel, containerId: 'contentTabs_'
I have this code in my server.js file at node.js: var app = require('http').createServer(handler),
I have this app (contacts style) in which you can add instances to a
So I have this app which needs to query entities from the Azure Tables
So I have this App in the store, and I would like to release
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make

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.