Concise guide to testing and RSpec basics for new programmers. Gives a good overview of how to test Ruby models with RSpec and steps beginners should take to continue improving their testing skills.
the name" do watch = Product.new(name: "Timex Weekender", price: 100) slug = watch.slug expect(slug).to eq("timex-weekender") end end describe "#discount_price" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end # takes the discount % as a parameter (ex: 0.3) # expect it to return the discounted price # has a default discount of 0.2 #product_spec.rb
the name" do watch = Product.new(name: "Timex Weekender", price: 100) slug = watch.slug expect(slug).to eq("timex-weekender") end end describe "#discount_price" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end # takes the discount % as a parameter (ex: 0.3) # expect it to return the discounted price # has a default discount of 0.2 #product_spec.rb
the name" do watch = Product.new(name: "Timex Weekender", price: 100) slug = watch.slug expect(slug).to eq("timex-weekender") end end describe "#discount_price" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end # takes the discount % as a parameter (ex: 0.3) # expect it to return the discounted price # has a default discount of 0.2 #product_spec.rb
it "returns the price discounted by the default 20%" do end end context "when a discount is given" do it "returns the correct discounted price" do end end end #product_spec.rb
it "returns the price discounted by the default 20%" do end end context "when a discount is given" do it "returns the correct discounted price" do end end end #product_spec.rb
it "returns the price discounted by the default 20%" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price expect(discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end #product_spec.rb
it "returns the price discounted by the default 20%" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price expect(discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end #product_spec.rb
it "returns the price discounted by the default 20%" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price expect(discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end #product_spec.rb
it "returns the price discounted by the default 20%" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price expect(discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end #product_spec.rb
Product.new(name: "Timex Weekender", price: 100) slug = watch.slug expect(slug).to eq("timex-weekender") end end describe "#discount_price" do context "when no discount is given" do it "returns the price discounted 20%" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price expect(discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) discount_price = watch.discount_price(discount: 0.3) expect(discount_price).to eq(70) end end end #product_spec.rb
Product.new(name: "Timex Weekender", price: 100) expect(watch.slug).to eq("timex-weekender") end end describe "#discount_price" do context "when no discount is given" do it "returns the price discounted 20%" do watch = Product.new(name: "Timex Weekender", price: 100) expect(watch.discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) expect(watch.discount_price(discount: 0.3)).to eq(70) end end end #product_spec.rb
do watch = Product.new(name: "Timex Weekender", price: 100) expect(watch.slug).to eq("timex-weekender") end end describe "#discount_price" do context "when no discount is given" do it "returns the price discounted 20%" do watch = Product.new(name: "Timex Weekender", price: 100) expect(watch.discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do watch = Product.new(name: "Timex Weekender", price: 100) expect(watch.discount_price(discount: 0.3)).to eq(70) end end end end #product_spec.rb
} describe "#slug" do it "slugifies the name" do expect(watch.slug).to eq("timex-weekender") end end describe "#discount_price" do context "when no discount is given" do it "returns the price discounted 20%" do expect(watch.discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do expect(watch.discount_price(discount: 0.3)).to eq(70) end end end end #product_spec.rb
} describe "#slug" do it "slugifies the name" do expect(watch.slug).to eq("timex-weekender") end end describe "#discount_price" do context "when no discount is given" do it "returns the price discounted 20%" do expect(watch.discount_price).to eq(80) end end context "when a discount is given" do it "returns the correct discounted price" do expect(watch.discount_price(discount: 0.3)).to eq(70) end end end end #product_spec.rb