Child before block is wrongly called
Closed this issue · 1 comments
JunichiIto commented
When I run the test below, it failed unexpectedly.
require 'minitest/autorun'
require 'shoulda'
describe 'With context' do
describe 'block 1' do
before do
@x = 1
end
it "should be 1, but 2" do
assert_equal 1, @x
end
context "Block 2-1" do
it "should be 1, but 2" do
assert_equal 1, @x
end
end
context "Block 2-2" do
before do
@x = 2
end
it "should be 2" do
assert_equal 2, @x
end
end
end
end
describe 'With describe' do
describe 'block 1' do
before do
@x = 1
end
it "should be 1" do
assert_equal 1, @x
end
describe "Block 2-1" do
it "should be 1" do
assert_equal 1, @x
end
end
describe "Block 2-2" do
before do
@x = 2
end
it "should be 2" do
assert_equal 2, @x
end
end
end
end
➜ minitest-before-sandbox be rake
Run options: --seed 37961
# Running:
...F.F
Finished in 0.002540s, 2362.5331 runs/s, 2362.5331 assertions/s.
1) Failure:
With context::block 1#test_0002_should be 1, but 2 [/Users/jit/dev/sandbox/minitest-before-sandbox/before_test.rb:16]:
Expected: 1
Actual: 2
2) Failure:
With context::block 1#test_0001_should be 1, but 2 [/Users/jit/dev/sandbox/minitest-before-sandbox/before_test.rb:11]:
Expected: 1
Actual: 2
6 runs, 6 assertions, 2 failures, 0 errors, 0 skips
rake aborted!
Command failed with status (1): [ruby -I"lib" "/Users/jit/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb" "*_test.rb" ]
Tasks: TOP => default => test
(See full trace by running task with --trace)
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
i18n (0.7.0)
json (1.8.2)
minitest (5.6.1)
rake (10.4.2)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.2.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
minitest (= 5.6.1)
rake
shoulda (= 3.5.0)
I think they should be 1. Why?
mcmire commented
Closing this because this is an old issue, and because in the example posted, no usage of Shoulda is present — that's all Minitest::Spec.