Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GEM
rspec-support (3.10.2)

PLATFORMS
ruby
x86_64-darwin-20

DEPENDENCIES
Expand Down
30 changes: 18 additions & 12 deletions spec/gilded_rose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@

RSpec.describe GildedRose do
let(:name) { 'Normal Item' }
subject(:gilded_rose) { GildedRose.new }

it "is a gilded rose" do
expect(subject).to be_a(GildedRose)
expect(gilded_rose).to be_a(GildedRose)
end

it "normal item after sell date" do
gr = GildedRose.new(name: "Normal Item", days_remaining: -10, quality: 10)
describe '#tick' do
context 'normal item after sell date' do
it "decrements days by 1 and quality by 2" do
gr = GildedRose.new(name: "Normal Item", days_remaining: -10, quality: 10)

gr.tick
gr.tick

expect(gr.days_remaining).to eq(-11)
expect(gr.quality).to eq(8)
expect(gr.days_remaining).to eq(-11)
expect(gr.quality).to eq(8)
end
end
end

shared_examples :gilded_rose do |name, days_remaining, quality, expected_days_remaining, expected_quality|
Expand All @@ -35,15 +40,16 @@
expect(gr).to have_attributes(days_remaining: 4, quality: 9)
end

it "normal item on sell date" do
context "normal item on sell date" do
gr = GildedRose.new(name: "Normal Item", days_remaining: 0, quality: 10)

expect(gr).to be_instance_of(GildedRose)

gr.tick
# expect(gr).to be_instance_of(GildedRose)
it "decrements days by 1 and quality by 2" do
gr.tick

expect(gr.days_remaining).to eq(-1)
expect(gr.quality).to eq(8)
expect(gr.days_remaining).to eq(-1)
expect(gr.quality).to eq(8)
end
end

it "normal item of zero quality" do
Expand Down