Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What Is Rspec?

What Is Rspec?

A beginner's level introduction: what is RSpec and what makes it different from (or better than) traditional unit testing frameworks. If you've heard of RSpec but you have no idea what it is, this talk is for you.

Jon Canady

May 19, 2014
Tweet

More Decks by Jon Canady

Other Decks in Programming

Transcript

  1. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate(“win") ).to eq(true) end end
  2. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate(“win") ).to eq(true) end end
  3. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate(“win") ).to eq(true) end end
  4. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate("win") ).to eq(true) end end
  5. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate("win") ).to eq(true) end end
  6. spec/user_spec.rb describe User do it "authenticates the correct password" do

    expect( User.authenticate("win") ).to eq(true) end end
  7. spec/user_spec.rb ! ).to eq(true) end ! it "rejects an incorrect

    password" do expect( User.authenticate("lose") ).to eq(false) end end
  8. spec/user_spec.rb ! ).to eq(true) end ! it "rejects an incorrect

    password" do expect( User.authenticate("lose") ).to eq(false) end end
  9. spec/user_spec.rb ! ).to eq(true) end ! it "rejects an incorrect

    password" do expect( described_class.authenticate("lose") ).to eq(false) end end
  10. expect( described_class.authenticate("lose") ).to eq(false) end ! ! spec/user_spec.rb it "is

    not an administrator by default" do expect( User.new.admin? ).to eq(false) end end
  11. expect( described_class.authenticate("lose") ).to eq(false) end ! ! spec/user_spec.rb it "is

    not an administrator by default" do expect( User.new.admin? ).to eq(false) end end
  12. expect( described_class.authenticate("lose") ).to eq(false) end ! ! spec/user_spec.rb it "is

    not an administrator by default" do expect( subject.admin? ).to eq(false) end end
  13. describe User do context "when representing an admin" do it

    "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) end it "lets the user delete posts" do spec/user_spec.rb
  14. describe User do context "when representing an admin" do it

    "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) end it "lets the user delete posts" do spec/user_spec.rb
  15. describe User do context "when representing an admin" do it

    "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) end it "lets the user delete posts" do spec/user_spec.rb
  16. describe User do context "when representing an admin" do subject

    do User.new(admin: true) end ! it "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) spec/user_spec.rb
  17. describe User do context "when representing an admin" do subject

    do User.new(admin: true) end ! it "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) spec/user_spec.rb
  18. describe User do context "when representing an admin" do subject

    do described_class.new(admin: true) end ! it "flags the user as an admin" do expect( User.new(admin: true).admin? ).to eq(true) spec/user_spec.rb
  19. describe User do context "when representing an admin" do subject

    do described_class.new(admin: true) end ! it "flags the user as an admin" do expect( subject.admin? ).to eq(true) spec/user_spec.rb