I am trying to output "59, bien sur", by modifying age method in class FrancePresident. I need to do this using #{catchphrase}. I have tried many ways including calling self.age . See Rspec below code.
module Presidential
attr_accessor :name, :age, :citizenship
def initialize(name, age)
@name, @age, @citizenship = name, age, self.class.citizenship
end
end
class UnitedStatesPresident
include Presidential
def self.citizenship
"The United States of America"
end
end
class FrancePresident
include Presidential
def name
name + ", #{catchphrase}"
end
def age
end
def citizenship
"#{self.class.citizenship}, #{catchphrase}"
end
def self.citizenship
"La France"
end
def catchphrase
"bien sur"
end
end
RSPEC
describe FrancePresident do
describe "catchphrase" do
it "sounds just right" do
expect( FrancePresident.citizenship ).to eq("La France")
sarcozy = FrancePresident.new("Nicolas Sarkozy", 59)
expect( sarcozy.citizenship ).to eq("La France, bien sur")
expect( sarcozy.age ).to eq("59, bien sur")
expect( sarcozy.name ).to eq("Nicolas Sarkozy, bien sur")
end
end
describe "inheritance" do
it "should not inherit from President" do
expect( FrancePresident.superclass.to_s ).not_to eq('President')
end
end
end