forked from tutsplus/ruby-refactoring
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6315a7a
commit fbba5da
Showing
7 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Student | ||
GRADES = { | ||
first: 10, | ||
second: 11, | ||
third: 12 | ||
} | ||
|
||
def term_grade index | ||
GRADES[index] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Student | ||
def first_term_grade | ||
10 | ||
end | ||
|
||
def second_term_grade | ||
11 | ||
end | ||
|
||
def third_term_grade | ||
12 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'minitest/autorun' | ||
require 'minitest/spec' | ||
|
||
require 'before' if ENV["BEFORE"] | ||
require 'after' unless ENV["BEFORE"] | ||
|
||
describe Student do | ||
if ENV["BEFORE"] | ||
|
||
it "has a first grade" do | ||
Student.new.first_term_grade.must_equal 10 | ||
end | ||
it "has a second grade" do | ||
Student.new.second_term_grade.must_equal 11 | ||
end | ||
it "has a third grade" do | ||
Student.new.third_term_grade.must_equal 12 | ||
end | ||
|
||
else # AFTER | ||
|
||
it "has a first grade" do | ||
Student.new.term_grade(:first).must_equal 10 | ||
end | ||
it "has a second grade" do | ||
Student.new.term_grade(:second).must_equal 11 | ||
end | ||
it "has a third grade" do | ||
Student.new.term_grade(:third).must_equal 12 | ||
end | ||
|
||
end | ||
end |