2007-07-14 18:35:51 +00:00
|
|
|
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2007-03-14 18:12:55 +00:00
|
|
|
|
2007-03-14 19:12:11 +00:00
|
|
|
class ContextTest < Test::Unit::TestCase # :nodoc:
|
2007-03-14 18:12:55 +00:00
|
|
|
|
|
|
|
context "context with setup block" do
|
|
|
|
setup do
|
|
|
|
@blah = "blah"
|
|
|
|
end
|
|
|
|
|
|
|
|
should "have @blah == 'blah'" do
|
|
|
|
assert_equal "blah", @blah
|
|
|
|
end
|
|
|
|
|
|
|
|
should "have name set right" do
|
2007-07-20 19:06:28 +00:00
|
|
|
assert_match(/^test: context with setup block/, self.to_s)
|
2007-03-14 18:12:55 +00:00
|
|
|
end
|
2007-03-14 21:28:35 +00:00
|
|
|
|
2007-03-14 23:05:34 +00:00
|
|
|
context "and a subcontext" do
|
2007-03-14 21:28:35 +00:00
|
|
|
setup do
|
|
|
|
@blah = "#{@blah} twice"
|
|
|
|
end
|
|
|
|
|
|
|
|
should "be named correctly" do
|
2007-07-20 19:06:28 +00:00
|
|
|
assert_match(/^test: context with setup block and a subcontext should be named correctly/, self.to_s)
|
2007-03-14 21:28:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
should "run the setup methods in order" do
|
|
|
|
assert_equal @blah, "blah twice"
|
|
|
|
end
|
|
|
|
end
|
2007-03-14 18:12:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context "another context with setup block" do
|
|
|
|
setup do
|
|
|
|
@blah = "foo"
|
|
|
|
end
|
|
|
|
|
|
|
|
should "have @blah == 'foo'" do
|
|
|
|
assert_equal "foo", @blah
|
|
|
|
end
|
|
|
|
|
|
|
|
should "have name set right" do
|
2007-07-20 19:06:28 +00:00
|
|
|
assert_match(/^test: another context with setup block/, self.to_s)
|
2007-03-14 18:12:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "context with method definition" do
|
|
|
|
setup do
|
|
|
|
def hello; "hi"; end
|
|
|
|
end
|
|
|
|
|
|
|
|
should "be able to read that method" do
|
|
|
|
assert_equal "hi", hello
|
|
|
|
end
|
|
|
|
|
|
|
|
should "have name set right" do
|
2007-07-20 19:06:28 +00:00
|
|
|
assert_match(/^test: context with method definition/, self.to_s)
|
2007-03-14 18:12:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-03-14 21:28:35 +00:00
|
|
|
context "another context" do
|
2007-03-14 18:12:55 +00:00
|
|
|
should "not define @blah" do
|
|
|
|
assert_nil @blah
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-07-24 15:13:36 +00:00
|
|
|
should_eventually "should pass, since it's unimplemented" do
|
2007-03-14 18:12:55 +00:00
|
|
|
flunk "what?"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|