Ruby developer interview questions on the language beyond Rails

Ruby developer interview questions test how well you know the language under the framework: the object model and method lookup, blocks and lambdas, Enumerable, mutability, metaprogramming and how Ruby handles concurrency. Expect a live coding exercise in plain Ruby, a code review of a messy class, and questions about gems, testing and production behavior. Strong answers write idiomatic Ruby, explain why it works, and know when clever code should stay out of a shared codebase.

By Published 7 min read

Who hires Ruby developers and what they look for

Most Ruby jobs involve Rails, but the title "Ruby developer" usually signals that the team cares about the language as much as the framework. You may work on background job systems, internal command-line tools, API services built on Sinatra or plain Rack, gems shared across services, or a large Rails monolith where the hard problems are in plain Ruby objects. Interviewers want readable, well-tested code, a clear mental model of how Ruby dispatches a method, and judgment about performance. For framework topics such as ActiveRecord associations and the N+1 problem, use the Ruby on Rails interview guide; this page stays with the language and the job around it.

How the interview loop usually looks

  1. Recruiter screenYour Ruby experience, the size of codebases you have worked in, and whether you have shipped gems or services outside Rails.
  2. Technical screenA short coding task in Ruby, sometimes in a shared editor, often with tests expected.
  3. Pairing or take-homeMany Ruby teams prefer pairing on a realistic task, such as parsing a file or refactoring a class, over puzzle-style algorithms.
  4. Code review and designRead a pull request and comment on it, or sketch a small service and its object design.
  5. Team and valuesCollaboration, code review habits, how you handle disagreement and production incidents.

Object model questions

Fundamentals most loops test early
QuestionWhat it testsWhat a strong answer shows
What happens when you call a method on an object?Method lookupRuby checks the singleton class, then the class and its prepended and included modules, then up the superclass chain, and calls method_missing last
What is the difference between include, extend and prepend?Modulesinclude adds instance methods above the class, prepend puts them before the class so they wrap its methods, extend adds them to one object or the class itself
What is a singleton class?Object modelA hidden class per object that holds methods defined on that object only; class methods live on the class's singleton class
How do ==, eql? and equal? differ?Equality== is value equality you can override, eql? is stricter and used with hash for Hash keys, equal? is object identity
Symbols versus strings: when do you use each?BasicsSymbols for identifiers and keys that repeat, strings for text that changes or comes from users
What does super do with and without parentheses?InheritanceBare super passes the current method's arguments along; super() passes none
How does Comparable work?MixinsDefine <=> and include Comparable to get <, >, between? and clamp
What is the difference between dup and clone?CopyingBoth are shallow; clone also keeps the frozen state and singleton methods
Fundamentals most loops test early. Scroll sideways on a small screen.

Blocks, procs, lambdas and Enumerable

Expect to explain closures with code. Know that lambdas check the number of arguments and that return inside a lambda leaves the lambda, while a proc is lenient with arguments and its return leaves the method that defined it.

square = ->(x) { x * x }
square.call(3)        # => 9
# square.call(3, 4)   # ArgumentError: lambdas check arity

loose = proc { |a, b| [a, b] }
loose.call(1)         # => [1, nil]

def first_even(numbers)
  numbers.each { |n| return n if n.even? } # return exits first_even
  nil
end

first_even([3, 5, 8, 9]) # => 8
Arity and return behavior (not executed; checked by hand)

A common follow-up asks you to make your own class enumerable. Define each, include Enumerable, and you get map, select, sort_by, each_slice and the rest. Returning an enumerator when no block is given is the detail that separates a careful answer.

class Playlist
  include Enumerable

  def initialize(*songs)
    @songs = songs
  end

  def each(&block)
    return enum_for(:each) unless block

    @songs.each(&block)
    self
  end
end

list = Playlist.new("Intro", "Blue", "Outro")
list.map(&:upcase)                # => ["INTRO", "BLUE", "OUTRO"]
list.select { |s| s.length > 4 }  # => ["Intro", "Outro"]
list.each.with_index.to_a         # => [["Intro", 0], ["Blue", 1], ["Outro", 2]]
A collection that behaves like a built-in (not executed; checked by hand)
  • When would you use a lazy enumerator? For a long or infinite sequence, or a big file read line by line, where you only need the first few results after a filter.
  • What does &:name do? It calls to_proc on the symbol, producing a block that sends that method to each element.
  • Explain yield and block_given?. yield runs the block passed to the method; block_given? lets you choose a fallback when no block came.
  • How would you reduce a list of orders to totals per customer? Something like group_by on the customer, then sum the amounts per group, or each_with_object with a hash defaulting to zero.

Mutability, memory and performance

  • What does the frozen string literal comment do? It makes string literals in that file frozen, which avoids accidental mutation and lets Ruby reuse the same object. Mutating one raises an error.
  • What is wrong with memoizing with ||= here? If the computed value can be nil or false, ||= recomputes every time. Use an instance_variable_defined? check or a hash with key? instead.
  • A method mutates an argument it was given. Why is that risky? Callers share the object, so the change leaks; prefer returning a new value or document the mutation with a bang method name.
  • How do you find why a job uses so much memory? Measure allocations around the hot path, look for building huge arrays instead of streaming, and check for objects held in class-level caches.
  • How does Ruby's garbage collector affect you in practice? Fewer short-lived allocations mean less GC work; on a hot loop, avoiding temporary strings and arrays can matter more than micro-optimizing logic.
  • What does a JIT change for Ruby code? Recent CRuby releases include a JIT that can speed up hot code; you still measure, since IO-bound apps may see little difference.

Concurrency questions

How Ruby runs work at the same time
QuestionWhat it testsWhat a strong answer shows
What is the global VM lock and what does it mean for threads?Runtime modelIn CRuby only one thread runs Ruby code at a time, but threads release it during most IO, so threads help IO-bound work far more than CPU-bound work
When would you use processes instead of threads?ScalingCPU-heavy work or isolation; app servers and job runners commonly fork worker processes and add threads inside each
What are fibers used for?Cooperative concurrencyLightweight units you switch between explicitly, used by enumerators and by fiber schedulers for non-blocking IO
What are Ractors?ParallelismAn actor-style way to run Ruby code in parallel with isolated objects; describe them as newer and check your Ruby version's status before relying on them
How do you make a shared counter thread-safe?SafetyA Mutex around the update, or avoid shared state by passing messages through a Queue
How Ruby runs work at the same time. Scroll sideways on a small screen.

Metaprogramming, gems and testing

  • If you override method_missing, what else must you do? Define respond_to_missing? so respond_to? and method objects stay honest, and call super for names you do not handle.
  • When is define_method better than method_missing? When the set of methods is known up front; defined methods are faster to call and show up in introspection.
  • When should you avoid metaprogramming? When a plain method or a hash lookup works; magic slows down code review and breaks editor navigation.
  • What is a refinement? A scoped monkey patch that only applies in files that activate it, safer than reopening a core class globally.
  • What does Gemfile.lock do, and should a gem commit it? It pins exact versions so every machine installs the same set; applications commit it, while gem authors define version ranges in the gemspec.
  • What does the ~> version operator mean? A pessimistic constraint that allows updates up to the next significant version, which keeps you on compatible releases.
  • RSpec or Minitest? Name what you have used, show you can write either, and talk about test design: one behavior per example, factories kept small, no reliance on test order.
  • How do you test code that calls an external API? Wrap the client in a small object you can replace, stub at that boundary, and keep a few contract or recorded-response tests.

Fictional example

Answering "Tell me about a refactor you are proud of"
Our billing export was a 600-line class full of conditionals on customer type, with tests that only checked the final file. I first added characterization tests that captured current output for a dozen real customer shapes. Then I pulled each customer type's rules into a small object with a common interface and replaced the conditionals with a lookup. Two new customer types later took a day each instead of a week, and when a bug came in, the failing test pointed to one small class. I kept the change in four reviewable pull requests so the team could follow it.

A two-week practice plan

  1. Days 1 to 4: language coreWrite small scripts for method lookup with ancestors, modules with prepend, closures, and a custom Enumerable class, checking your predictions in irb.
  2. Days 5 to 8: exercisesSolve parsing and data-reshaping problems in idiomatic Ruby with tests, and time yourself explaining each solution.
  3. Days 9 to 11: production topicsRevise concurrency, memory, background jobs and gem management with an example from your own work for each.
  4. Days 12 to 14: review and storiesReview an old pull request as if a stranger wrote it, then prepare stories on a refactor, an incident and a disagreement in review.

Pairing rounds reward thinking aloud, which takes practice. During a mock session, Natively, an AI interview assistant for Mac and Windows, transcribes what you say on your computer and can offer coding help or a clearer explanation of method lookup on request. It can read a practice exercise from a screenshot, and with Pro or the free trial it can use your résumé and the job posting so suggestions reflect the codebases you have worked on. Go back over the transcript and notes afterward to find where your explanation lagged behind your typing.

Questions people ask

What questions are asked in a Ruby developer interview?

Expect questions on method lookup, include versus extend versus prepend, blocks, procs and lambdas, Enumerable, equality methods, mutability, metaprogramming, concurrency under the global VM lock, gems and testing, plus a coding or pairing exercise.

What is the difference between a proc and a lambda in Ruby?

A lambda checks how many arguments it gets and its return exits only the lambda. A proc is lenient with arguments and its return exits the method where the proc was defined.

Do Ruby developer interviews include Rails questions?

Often, because most Ruby jobs use Rails. This page covers the language; revise Rails topics such as ActiveRecord and N+1 queries separately.

How should I prepare for a Ruby coding interview?

Practice idiomatic solutions with tests, explain method lookup and closures out loud, revise concurrency and memory topics, and review a past pull request as if you were the reviewer.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP