Add ability to call custom methods defined inside the context
Closed this issue · 1 comments
celesteking commented
There should be written with big red letters 30pt min size in your shoulda-context doc/guide that user should not have more than 3 level deep context, otherwise he would want to use this feature for the sake of hierarchy and encapsulation.
#!/bin/env ruby
require 'rubygems'
require 'test/unit'
require 'shoulda'
class ShouldaTest < Test::Unit::TestCase
context 'cecocec' do
def self.customethod
puts "cucuocu!"
end
def customethod
puts "cacacaca!"
end
should 'test #1' do
puts 'test #1'
customethod
end
end
end
LC_ALL=C ruby ./test/unit/shoulda_test2.rb
Loaded suite ./test/unit/shoulda_test2
Started
test #1
E
Finished in 0.000197 seconds.
1) Error:
test: cecocec should test #1. (ShouldaTest):
NameError: undefined local variable or method `customethod' for #<ShouldaTest:0x7fb78d214368>
./test/unit/shoulda_test2.rb:19:in `__bind_1338242319_881688'
X/gems/shoulda-context-1.0.0/lib/shoulda/context/context.rb:398:in `call'
X/gems/shoulda-context-1.0.0/lib/shoulda/context/context.rb:398:in `test: cecocec should test #1. '
1 tests, 0 assertions, 0 failures, 1 errors
travisjeffery commented
Feel free to submit a patch otherwise I'm good with people putting their test helper methods as privates at the bottom of the file, or refactoring into factories/common helpers in a place like a test_helper.rb.