Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Updated README to add GitHub Flavoured Markdown #220

Closed
wants to merge 1 commit into from

2 participants

@parndt

The Ruby, it shines!

@drapergeek
Admin

Merged. Thanks!

@drapergeek drapergeek closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 24, 2012
  1. @parndt

    Updated README to add GitHub Flavoured Markdown

    parndt authored
    The Ruby, it shines!
This page is out of date. Refresh to see the latest.
Showing with 42 additions and 30 deletions.
  1. +42 −30 README.md
View
72 README.md
@@ -17,39 +17,47 @@ rspec with shoulda-matchers
This is what thoughtbot currently does. We write tests like:
- describe Post do
- it { should belong_to(:user) }
- it { should validate_presence_of(:title) }
- end
+```ruby
+describe Post do
+ it { should belong_to(:user) }
+ it { should validate_presence_of(:title) }
+end
+```
The belong_to and validate_presence_of methods are the matchers.
All matchers are Rails 3-specific.
Add rspec-rails and shoulda-matchers to the project's Gemfile:
- group :test do
- gem 'rspec-rails'
- gem 'shoulda-matchers'
- end
+```ruby
+group :test do
+ gem 'rspec-rails'
+ gem 'shoulda-matchers'
+end
+```
test/unit with shoulda
----------------------
For the folks who prefer Test::Unit, they'd write tests like:
- class UserTest < Test::Unit::TestCase
- should have_many(:posts)
- should_not allow_value("blah").for(:email)
- end
+```ruby
+class UserTest < Test::Unit::TestCase
+ should have_many(:posts)
+ should_not allow_value("blah").for(:email)
+end
+```
The have_many and allow_value methods are the same kind of matchers
seen in the RSpec example. They come from the shoulda-matchers gem.
Add shoulda to the project's Gemfile:
- group :test do
- gem 'shoulda'
- end
+```ruby
+group :test do
+ gem 'shoulda'
+end
+```
test/unit with shoulda-context
------------------------------
@@ -57,27 +65,31 @@ test/unit with shoulda-context
If you're not testing a Rails project or don't want to use the matchers,
you can use shoulda-context independently to write tests like:
- class CalculatorTest < Test::Unit::TestCase
- context "a calculator" do
- setup do
- @calculator = Calculator.new
- end
+```ruby
+class CalculatorTest < Test::Unit::TestCase
+ context "a calculator" do
+ setup do
+ @calculator = Calculator.new
+ end
- should "add two numbers for the sum" do
- assert_equal 4, @calculator.sum(2, 2)
- end
+ should "add two numbers for the sum" do
+ assert_equal 4, @calculator.sum(2, 2)
+ end
- should "multiply two numbers for the product" do
- assert_equal 10, @calculator.product(2, 5)
- end
- end
+ should "multiply two numbers for the product" do
+ assert_equal 10, @calculator.product(2, 5)
end
+ end
+end
+```
Add shoulda-context to the project's Gemfile:
- group :test do
- gem 'shoulda-context'
- end
+```ruby
+group :test do
+ gem 'shoulda-context'
+end
+```
Credits
-------
Something went wrong with that request. Please try again.