Skip to content

Commit

Permalink
Parameterize Method.
Browse files Browse the repository at this point in the history
  • Loading branch information
josemotanet committed Jun 4, 2013
1 parent 6315a7a commit fbba5da
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 5 deletions.
Empty file.
Empty file.
5 changes: 0 additions & 5 deletions introduce-parameter-object/test/test.rb

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions parameterize-method/lib/after.rb
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
13 changes: 13 additions & 0 deletions parameterize-method/lib/before.rb
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
33 changes: 33 additions & 0 deletions parameterize-method/test/test.rb
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

0 comments on commit fbba5da

Please sign in to comment.