Question
RUBY CODE Help: For the following code: require 'dessert.rb' require 'byebug' RSpec.configure do |config| config.filter_run_excluding :disabled => true end describe Dessert do describe 'dessert getters
RUBY CODE Help: For the following code:
require 'dessert.rb' require 'byebug'
RSpec.configure do |config| config.filter_run_excluding :disabled => true end
describe Dessert do describe 'dessert getters and setters' do before(:each) { @dessert = Dessert.new('cake', 400) } it 'should set name [10 points]' , points: 10 do expect(@dessert.name).to eq('cake') end it 'should set calories [10 points]' , points: 10 do expect(@dessert.calories).to eq(400) end it 'should be able to change name [10 points]' , points: 10 do @dessert.name = 'ice cream' expect(@dessert.name).to eq('ice cream') end it 'should be able to change calories [10 points]' , points: 10 do @dessert.calories = 80 expect(@dessert.calories).to eq(80) end end describe 'delicious and healthy', :disabled => true do describe '-cake' do before :each do @dessert = Dessert.new('cake', 400) end it 'should be delicious [10 points]' do expect(@dessert).to be_delicious end it 'should not be healthy [10 points]' do expect(@dessert).not_to be_healthy end end describe '-apple' do before :each do @subject = Dessert.new('apple', 75) end it 'should be delicious [10 points]' do expect(@subject).to be_delicious end it 'should be healthy [10 points]' do expect(@subject).to be_healthy end end end end
describe JellyBean do describe 'JellyBean getters and setters', :disabled => true do before(:each) { @jellybean = JellyBean.new('vanilla') } it 'should contain 5 calories [2.5 points]' do expect(@jellybean.calories).to be == 5 end it 'should be named vanilla jelly bean [2.5 points]' do expect(@jellybean.name).to match(/vanilla jelly bean/i) end it 'should set flavor [2.5 points]' do expect(@jellybean.flavor).to eq('vanilla') end it 'should be able to change flavor [2.5 points]' do @jellybean.flavor = 'cherry' expect(@jellybean.flavor).to eq('cherry') end end describe 'modify delicious', :disabled => true do describe '-when non-licorice' do before :each do @jellybean = JellyBean.new('vanilla') end it 'should be delicious [5 points]' do expect(@jellybean).to be_delicious end end describe '-when licorice' do before :each do @jellybean = JellyBean.new('licorice') end it 'should not be delicious [5 points]' do expect(@jellybean).not_to be_delicious end end end end
1)Remove the , :disabled => true from the 'delicious and healthy' collection in the spec/dessert_spec.rb file. Don't forget to save your changes!
Define instance methods `healthy?`, which returns true if a dessert has less than 200 calories, and `delicious?`, which returns true for all desserts.
Run rspec in the terminal window to test.Everything has to be passing.
2)Remove the , :disabled => true from the 'JellyBean getters and setters' collection in the spec/dessert_spec.rb file. Don't forget to save your changes!
Create the getters and settings for the class JellyBean that inherits from Dessert. It should accept a single argument giving the jelly bean's flavor; a newly-created jelly bean should have 5 calories and its name should be the flavor plus "jelly bean", for example, "strawberry jelly bean".
Run rspec in the terminal window to test. Everything has to be passing.
3)Remove the , :disabled => true from the 'modify delicious' collection in the spec/dessert_spec.rb file. Don't forget to save your changes!
Modify `delicious?` to return false if the flavor is `licorice`, but true for all other flavors. The behavior of `delicious?` for non-jelly-bean desserts should be unchanged.
Run rspec in the terminal window to test.
Use the following code to solve. Thank you!
class Dessert # add code for setters and getters def initialize(name, calories) # your code here end def healthy? # your code here end def delicious? # your code here end end
class JellyBean < Dessert # add code for setters and getters def initialize(flavor) # your code here end end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started