1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/test/other/context_test.rb
Tammer Saleh b415bff884 Revert bunch of bad commits:
2442d1f608
35213b5a1b
804f859435
fc938bb185

Getting the following error when running tests in a real project:

  ...activesupport/lib/active_support/dependencies.rb:276:in `load_missing_constant': uninitialized constant Shoulda::ActiveRecord::Base (NameError)

Think this is because of the namespace changes, but not sure.  Will investigate later.
2008-06-23 12:36:31 -04:00

73 lines
1.7 KiB
Ruby

require File.join(File.dirname(__FILE__), '..', 'test_helper')
class ContextTest < Test::Unit::TestCase # :nodoc:
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
assert_match(/^test: context with setup block/, self.to_s)
end
context "and a subcontext" do
setup do
@blah = "#{@blah} twice"
end
should "be named correctly" do
assert_match(/^test: context with setup block and a subcontext should be named correctly/, self.to_s)
end
should "run the setup methods in order" do
assert_equal @blah, "blah twice"
end
end
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
assert_match(/^test: another context with setup block/, self.to_s)
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
assert_match(/^test: context with method definition/, self.to_s)
end
end
context "another context" do
should "not define @blah" do
assert_nil @blah
end
end
should_eventually "should pass, since it's unimplemented" do
flunk "what?"
end
should_eventually "should not require a block when using should_eventually"
should "should pass without a block, as that causes it to piggyback to should_eventually"
end