Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. require 'dessert.rb'
  2. require 'byebug'
  3.  
  4. RSpec.configure do |config|
  5. config.filter_run_excluding :disabled => true
  6. end
  7.  
  8. describe Dessert do
  9. describe 'dessert getters and setters' do
  10. before(:each) { @dessert = Dessert.new('cake', 400) }
  11. it 'should set name [10 points]' , points: 10 do
  12. expect(@dessert.name).to eq('cake')
  13. end
  14. it 'should set calories [10 points]' , points: 10 do
  15. expect(@dessert.calories).to eq(400)
  16. end
  17. it 'should be able to change name [10 points]' , points: 10 do
  18. @dessert.name = 'ice cream'
  19. expect(@dessert.name).to eq('ice cream')
  20. end
  21. it 'should be able to change calories [10 points]' , points: 10 do
  22. @dessert.calories = 80
  23. expect(@dessert.calories).to eq(80)
  24. end
  25. end
  26.  
  27. describe 'delicious and healthy' do
  28. describe '-cake' do
  29. before :each do
  30. @dessert = Dessert.new('cake', 400)
  31. end
  32. it 'should be delicious [10 points]' do
  33. expect(@dessert).to be_delicious
  34. end
  35. it 'should not be healthy [10 points]' do
  36. expect(@dessert).not_to be_healthy
  37. end
  38. end
  39.  
  40. describe '-apple' do
  41. before :each do
  42. @subject = Dessert.new('apple', 75)
  43. end
  44. it 'should be delicious [10 points]' do
  45. expect(@subject).to be_delicious
  46. end
  47. it 'should be healthy [10 points]' do
  48. expect(@subject).to be_healthy
  49. end
  50. end
  51. end
  52. end
  53.  
  54. describe JellyBean do
  55. describe 'JellyBean getters and setters' do
  56. before(:each) { @jellybean = JellyBean.new('vanilla') }
  57.  
  58. it 'should contain 5 calories [2.5 points]' do
  59. expect(@jellybean.calories).to be == 5
  60. end
  61. it 'should be named vanilla jelly bean [2.5 points]' do
  62. expect(@jellybean.name).to match(/vanilla jelly bean/i)
  63. end
  64. it 'should set flavor [2.5 points]' do
  65. expect(@jellybean.flavor).to eq('vanilla')
  66. end
  67. it 'should be able to change flavor [2.5 points]' do
  68. @jellybean.flavor = 'cherry'
  69. expect(@jellybean.flavor).to eq('cherry')
  70. end
  71. end
  72.  
  73. describe 'modify delicious' do
  74. describe '-when non-licorice' do
  75. before :each do
  76. @jellybean = JellyBean.new('vanilla')
  77. end
  78.  
  79. it 'should be delicious [5 points]' do
  80. expect(@jellybean).to be_delicious
  81. end
  82. end
  83.  
  84. describe '-when licorice' do
  85. before :each do
  86. @jellybean = JellyBean.new('licorice')
  87. end
  88. it 'should not be delicious [5 points]' do
  89. expect(@jellybean).not_to be_delicious
  90. end
  91. end
  92. end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement