Skip to content

Commit 4727a0b

Browse files
schaui6tjgrathwell
authored andcommitted
Add grammar fixes, add tdd section, add mini test example
1 parent f06fe59 commit 4727a0b

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

sites/en/testing/testing_frameworks.step

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bundle exec rspec spec/controllers/post_controller_spec.rb
6464
## RSpec Basics
6565

6666
<div class="console"><pre>
67-
1 RSpec.describe Tree do
67+
1 describe Tree do
6868
2 it "is able to age by 1 year increments" do
6969
3 orange_tree = Tree.new
7070
4 orange_tree.age
@@ -91,6 +91,46 @@ Remember in our example on line 5? 'to eq' is a matcher. RSpec has many built-in
9191
Check out the other built-in matchers!
9292
https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
9393

94+
# Mini Test
95+
In case you were curious to see how tests are written in Mini Test. Although Mini Test allows you in 'expectation style' which is very similar to how RSpec tests are written.
96+
97+
<div class="console">
98+
<pre>
99+
class TestTree < Minitest::Test
100+
101+
def setup
102+
@orange_tree = Tree.new
103+
@orange_tree.age
104+
end
105+
106+
def test_age_by_one_year_increments
107+
assert_equal 1, @orange_tree.age
108+
end
109+
end
110+
</pre>
111+
</div>
112+
113+
To run the test enter the following in Terminal/Command Prompt:
114+
115+
<div class="console">
116+
<pre>
117+
ruby tree_test.rb
118+
</pre>
119+
</div>
120+
121+
Once you run the test this is how the test looks like:
122+
<div class="console">
123+
<pre>
124+
$ ruby tree_test.rb
125+
Run options: --seed 30102
126+
127+
#Running:
128+
129+
.
130+
Finished in 0.000980s, 1020.4082 runs/s, 1020.4082 assertions/s.
131+
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
132+
</pre>
133+
</div>
94134

95135
MARKDOWN
96136

sites/en/testing/what_are_tests.step

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ How do we determine if an orange is ripe? Well, we can have oranges age and if i
1515
You could think of tests as a requirement list. Every time a change is made we want to test to see if our code still meets those requirements. For example, as our program becomes increasingly complex and we want to have our tree to have a certain lifespan, would it make sense for our tree to continue to create oranges after exceeding that lifespan?
1616

1717
# Why Is It Important That We Test?
18-
For situations like our tree's lifespan is a prime example of why tests are important. As our program become more complex over time the tests tells us that a basic requirement is not fulfilled and needs to be addressed. Can you imagine looking at pages and pages of code that was written by someone else or many years ago without a way to trace exactly where the bug is? Tests can help!
18+
For situations like our tree's lifespan is a prime example of why tests are important. As our program becomes more complex over time the tests tells us that a basic requirement is not fulfilled and needs to be addressed. Can you imagine looking at pages and pages of code that was written by someone else or many years ago without a way to trace exactly where the bug is? Tests can help!
19+
20+
# Test Driven Development
21+
Test-driven development (TDD) is a development technique where you must first write a test that fails before you write new functional code. TDD is a great way to develop your program! Add a test, run all tests, write code, run tests, and then refactor code!
1922

2023
MARKDOWN
2124

0 commit comments

Comments
 (0)