Giter Club home page Giter Club logo

rspec-core's Introduction

RSpec Core

Behaviour Driven Development for Ruby

Documentation

The Cucumber features are the most comprehensive and up-to-date docs for end-users.

The RDoc provides additional information for contributors and/or extenders.

All of the documentation is open source and a work in progress. If you find it lacking or confusing, you can help improve it by submitting requests and patches to the rspec-core issue tracker.

Install

gem install rspec      # for rspec-core, rspec-expectations, rspec-mocks
gem install rspec-core # for rspec-core only

Upgrading from rspec-1.x

See features/Upgrade.md

This will install the rspec, rspec-core, rspec-expectations and rspec-mocks gems.

Get Started

Start with a simple example of behavior you expect from your system. Do this before you write any implementation code:

# in spec/calculator_spec.rb
describe Calculator, "add" do
  it "returns the sum of its arguments" do
    Calculator.new.add(1, 2).should eq(3)
  end
end

Run this with the rspec command, and watch it fail:

$ rspec spec/calculator_spec.rb
./spec/calculator_spec.rb:1: uninitialized constant Calculator

Implement the simplest solution:

# in lib/calculator.rb
class Calculator
  def add(a,b)
    a + b
  end
end

Be sure to require the implementation file in the spec:

# in spec/calculator_spec.rb
# - RSpec adds ./lib to the $LOAD_PATH, so you can
#   just require "calculator" directly
require "calculator"

Now run the spec again, and watch it pass:

$ rspec spec/calculator_spec.rb
.

Finished in 0.000315 seconds
1 example, 0 failures

Use the documentation formatter to see the resulting spec:

$ rspec spec/calculator_spec.rb --format doc
Calculator add
  returns the sum of its arguments

Finished in 0.000379 seconds
1 example, 0 failures

Known issues

See http://github.com/rspec/rspec-core/issues

Learn more

While not comprehensive yet, you can learn quite a lot from the Cucumber features in the features directory. If there is a feature that is not documented there, or you find them insufficient to understand how to use a feature, please submit issues to http://github.com/rspec/rspec-core/issues.

Contribute

See http://github.com/rspec/rspec-dev

Also see

rspec-core's People

Contributors

dchelimsky avatar spicycode avatar myronmarston avatar justinko avatar benarmston avatar jimbreen avatar iromeo avatar wincent avatar dnurzynski avatar rsanheim avatar kaiwren avatar grosser avatar alexcrichton avatar gsterndale avatar graaff avatar jarmo avatar joliss avatar jonrowe avatar leshill avatar luislavena avatar ajwalters avatar zargony avatar alindeman avatar bhuga avatar bosko avatar briandunn avatar cowboyd avatar cjheath avatar coreyhaines avatar danp avatar

Stargazers

Erick Tryzelaar avatar

Watchers

Erick Tryzelaar avatar James Cloos avatar  avatar

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.