Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rspec style

  • Loading branch information...
commit 4575254664a7142da91a319b764b5ffc85aa7db9 1 parent 5229254
@xinuc authored
Showing with 39 additions and 2 deletions.
  1. +39 −2 Session4.md
View
41 Session4.md
@@ -54,9 +54,46 @@ kita buat dengan assertion.
end
```
-kemudian kita jalankan dengan `ruby person_test.rb`.
+atau kita dapat menuliskan test dengan gaya rspec:
+
+```ruby
+ # person_test.rb
+ require './person'
+ require 'minitest/autorun'
+
+ describe Person do
+ before do
+ @person = Person.new "John", "Smith"
+ end
+
+ it "should create a correct fullname" do
+ @person.fullname.must_equal "John Smith"
+ end
+ end
+```
+
+kemudian kita jalankan dengan `ruby person_test.rb`, yang akan
+menghasilkan
+
+```
+Run options: --seed 6446
+
+# Running tests:
+
+.
+
+Finished tests in 0.000741s, 1349.7900 tests/s, 1349.7900 assertions/s.
+
+1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
+```
+
+yang berarti bahwa ada 1 test yang dijalankan tanpa failure.
+
+### Introduction to TDD
+
+TDD (test driven development) adalah
+
-## Introduction to TDD
## Red-Green-Refactor
## Describing a feature
## Verifying expectations
Please sign in to comment.
Something went wrong with that request. Please try again.