Last active
April 11, 2018 17:12
-
-
Save squarism/5c984b9f64939f1d843ea86ac1f20053 to your computer and use it in GitHub Desktop.
create_a_class_the_hard_way.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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