Skip to content

Instantly share code, notes, and snippets.

@squarism
Last active April 11, 2018 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squarism/5c984b9f64939f1d843ea86ac1f20053 to your computer and use it in GitHub Desktop.
Save squarism/5c984b9f64939f1d843ea86ac1f20053 to your computer and use it in GitHub Desktop.
create_a_class_the_hard_way.rb
require "rspec/autorun"
Car = Class.new
Car.class_exec {
define_method :start, Proc.new { @started = true }
define_method :started, Proc.new { @started }
}
RSpec.describe Car do
it "starts" do
subject.start
expect(subject.started).to eq true
end
end
# ruby ./create_a_class_the_hard_way.rb
# .
# 1 example, 0 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment