Skip to content

sf-squirrels-2015/controller-testing-lecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##Testing Battle Plan For Phase 2

###Types of Tests

  • Unit Tests (model) : small and atomic - test the interface of a class. ie Dog.speak() == "woof"
  • Function Testing (controller)
describe ContactsController do
  describe "GET #index" do
    it "populates an array of contacts"
    it "renders the :index view" end
  • Integration Test : Issue http requests to test the flow of data from the client to the server. Expensive and slow.
  • Acceptance Testing : Does the application meet pre-defined business rules / logic

###What technology?

  • Rspec = DSL for testing in Ruby. Has more englishy terms (looks more like Ruby)
  • Rack::Test - API for testing Rack based frameworks (like Sinatra)
  • Shoulda Matchers - library for faster model tests
  • Factory Girl - library to create resources for tests
  • Capybara - integration testing

###A simple sample

###Testing in Sinatra

  • Run the sample app:
    • bundle
    • rake db:create
    • rake db:migrate
    • rake db:test:prepare - create a test database
    • rake run the default rake task which is spec or rake spec
    • You should see passing tests.
    • Look in the spec directory to see these test and write some of your on.

Write Tests

  • No really, write some tests!

##Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published