File tree Expand file tree Collapse file tree
2_Classes/1_Your_first_class Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class Programmer
2+ end
Original file line number Diff line number Diff line change 1+ require 'rspec'
2+
3+ [ [ 'solution::code' ] ]
4+
5+ describe 'Your code' do
6+ it "defines a class Programmer" do
7+ expect ( Object . const_defined? ( 'Programmer' ) ) . to be true
8+ end
9+
10+ if Object . const_defined? ( 'Programmer' )
11+ describe Programmer do
12+ it "allows instantiating a new Programmer" do
13+ expect { Programmer . new } . not_to raise_error
14+ end
15+
16+ it "defines a Programmer class without any methods" do
17+ expect ( Programmer . public_instance_methods ( false ) ) . to be_empty
18+ expect ( Programmer . singleton_methods ( false ) ) . to be_empty
19+ expect ( subject . protected_methods ( false ) ) . to be_empty
20+ expect ( subject . private_methods ( false ) ) . to be_empty
21+ end
22+ end
23+
24+ end
25+ end
Original file line number Diff line number Diff line change 1+ # Your first class
2+
3+ You can define a class with the * class* keyword followed by the
4+ camelcased name of the class.
5+ Keep in mind to close the class definition with the * end* keyword, e.g.:
6+
7+ ` class ClassName `
8+ ` end `
9+
10+ Camelcasing the class name is not necessary, but is a naming convention in Ruby.
11+
12+ ---
13+
14+ Define a class * Programmer* similar to the example above!
15+
16+ ---
You can’t perform that action at this time.
0 commit comments