GithubHelp home page GithubHelp logo

rspec_tutorials's Introduction

The purpose of this project is to teach you how to use RSpec, a popular testing tool.

Introduction

RSpec is testing tool for the Ruby programming language. Born under the banner of Behaviour-Driven Development, it is designed to make Test-Driven Development a productive and enjoyable experience.

This is a Rails project, by default it use Test::Unit and Fixture. However we use FactoryGirl to set up Ruby objects as test data. It support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.

If we want to use factory_girl with Rails, we need to include factory_girl_rails.

Usage

  1. prepare database

You may change the database.yml setting first.

rake db:create
rake db:migrate
  1. add the following lines to your Gemfile

group :test, :development do
  gem "rspec-rails"
  gem "factory_girl"
  gem "factory_girl_rails"
end

Then run the following rake tasks:
bunlde install
rails generate rspec:install
  1. run all tests

rake spec
  1. run all modles tests

rake spec:models
  1. run single test file

rspec spec/models/user_spec.rb
  1. run single test method within a test file

rspec file_path:line_no

The line_no is the method location in your test file. Such as:

rspec spec/models/user_spec.rb:10

rspec_tutorials's People

Contributors

manageyp avatar

Watchers

 avatar James Cloos avatar

Forkers

guoyu07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.