-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
10 changed files
with
181 additions
and
91 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Gemfile.lock | ||
*.gem | ||
coverage |
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
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
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
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,23 @@ | ||
require 'test_helper' | ||
|
||
class CallCountTest < Minitest::Spec | ||
before_suite_call_count = 0 | ||
after_suite_call_count = 0 | ||
|
||
before_suite do | ||
before_suite_call_count += 1 | ||
end | ||
|
||
after_suite do | ||
after_suite_call_count += 1 | ||
assert after_suite_call_count == 1 | ||
end | ||
|
||
(1..3).each do |i| | ||
has_run = false | ||
it "is called the appropriate number of times#{i}" do | ||
assert before_suite_call_count == 1 | ||
assert after_suite_call_count == 0 | ||
end | ||
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 'test_helper' | ||
|
||
class InsideDescribeBlocksTest < Minitest::Spec | ||
describe 'a one-level block' do | ||
before_suite do | ||
@var = 'var' | ||
end | ||
|
||
after_suite do | ||
assert @var == 'var' | ||
end | ||
|
||
it 'should share instance variables' do | ||
assert @var == 'var' | ||
end | ||
end | ||
|
||
describe 'a' do | ||
describe 'nested block' do | ||
before_suite do | ||
assert @var2 = 'var2' | ||
end | ||
|
||
after_suite do | ||
assert @var2 == 'var2' | ||
end | ||
|
||
it 'should share instance variables' do | ||
assert @var2 == 'var2' | ||
end | ||
end | ||
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,19 @@ | ||
require 'test_helper' | ||
|
||
class InstanceMethodAccessTest < Minitest::Spec | ||
before_suite do | ||
@instance_method_return_value = instance_method | ||
end | ||
|
||
after_suite do | ||
assert instance_method == 'hi' | ||
end | ||
|
||
it 'has access to instance methods' do | ||
assert true # test handled by callbacks | ||
end | ||
|
||
def instance_method | ||
'hi' | ||
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,15 @@ | ||
require 'test_helper' | ||
|
||
class InstanceVariableScopeTest < Minitest::Spec | ||
before_suite do | ||
@yo = 'yo' | ||
end | ||
|
||
after_suite do | ||
assert @yo == 'yo' | ||
end | ||
|
||
it 'shares instances variables with the tests' do | ||
assert @yo == 'yo' | ||
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,25 @@ | ||
require 'test_helper' | ||
|
||
class OutsideDescribeBlockTest < Minitest::Spec | ||
@before_suite_call_count = 0 | ||
@after_suite_call_count = 0 | ||
|
||
class << self | ||
attr_accessor :before_suite_call_count, :after_suite_call_count | ||
end | ||
|
||
before_suite do | ||
OutsideDescribeBlockTest.before_suite_call_count += 1 | ||
end | ||
|
||
after_suite do | ||
OutsideDescribeBlockTest.after_suite_call_count += 1 | ||
end | ||
|
||
describe 'a describe block' do | ||
it 'should call top-level callbacks the right number of times' do | ||
assert_equal 1, OutsideDescribeBlockTest.before_suite_call_count, 'expected before_suite to be correct' | ||
assert_equal 0, OutsideDescribeBlockTest.after_suite_call_count, 'expected after_suite to be correct' | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.