Permalink
Browse files

Revert bunch of bad commits:

2442d1f
35213b5
804f859
fc938bb

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.
  • Loading branch information...
1 parent 2442d1f commit b415bff884a3c25a058c2600f86da80d4fa28fde Tammer Saleh committed Jun 23, 2008
View
@@ -10,7 +10,7 @@ Assertions:: Many common rails testing idioms have been distilled into a set of
= Usage
-=== Context Helpers (Shoulda::Context)
+=== Context Helpers (ThoughtBot::Shoulda::Context)
Stop killing your fingers with all of those underscores... Name your tests with plain sentences!
@@ -43,7 +43,7 @@ Produces the following test methods:
So readable!
-=== ActiveRecord Tests (Shoulda::ActiveRecord)
+=== ActiveRecord Tests (ThoughtBot::Shoulda::ActiveRecord)
Quick macro tests for your ActiveRecord associations and validations:
@@ -73,7 +73,7 @@ Quick macro tests for your ActiveRecord associations and validations:
Makes TDD so much easier.
-=== Controller Tests (Shoulda::Controller::ClassMethods)
+=== Controller Tests (ThoughtBot::Shoulda::Controller::ClassMethods)
Macros to test the most common controller patterns...
@@ -105,7 +105,7 @@ Test entire controllers in a few lines...
should_be_restful generates 40 tests on the fly, for both html and xml requests.
-=== Helpful Assertions (Shoulda::General)
+=== Helpful Assertions (ThoughtBot::Shoulda::General)
More to come here, but have fun with what's there.
View
@@ -6,7 +6,7 @@ require 'rake/rdoctask'
Rake::TestTask.new do |t|
t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
+ t.pattern = 'test/{unit,functional,other}/**/*_test.rb'
t.verbose = false
end
View
@@ -1,144 +1,43 @@
-require 'shoulda/context'
+require 'shoulda/gem/shoulda'
require 'shoulda/private_helpers'
require 'shoulda/general'
+require 'shoulda/active_record_helpers'
+require 'shoulda/controller_tests/controller_tests.rb'
require 'yaml'
-require 'shoulda/active_record_helpers' if defined?(ActiveRecord)
-require 'shoulda/controller_tests/controller_tests.rb' if defined?(ActionController)
-
-config_files = []
-config_files << "shoulda.conf"
-config_files << File.join("test", "shoulda.conf")
-config_files << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT)
-config_files << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"]
-
shoulda_options = {}
-config_files.each do |file|
- shoulda_options.merge!(YAML.load_file(file).symbolize_keys) if File.exists? file
-end
-require 'shoulda/color' if shoulda_options[:color]
+possible_config_paths = []
+possible_config_paths << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"]
+possible_config_paths << "shoulda.conf"
+possible_config_paths << File.join("test", "shoulda.conf")
+possible_config_paths << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT)
-module Shoulda
- class << self
- attr_accessor :current_context
+possible_config_paths.each do |config_file|
+ if File.exists? config_file
+ shoulda_options = YAML.load_file(config_file).symbolize_keys
+ break
end
+end
- # Should statements are just syntactic sugar over normal Test::Unit test methods. A should block
- # contains all the normal code and assertions you're used to seeing, with the added benefit that
- # they can be wrapped inside context blocks (see below).
- #
- # == Example:
- #
- # class UserTest << Test::Unit::TestCase
- #
- # def setup
- # @user = User.new("John", "Doe")
- # end
- #
- # should "return its full name"
- # assert_equal 'John Doe', @user.full_name
- # end
- #
- # end
- #
- # ...will produce the following test:
- # * <tt>"test: User should return its full name. "</tt>
- #
- # Note: The part before <tt>should</tt> in the test name is gleamed from the name of the Test::Unit class.
-
- def should(name, &blk)
- should_eventually(name) && return unless block_given?
-
- if Shoulda.current_context
- Shoulda.current_context.should(name, &blk)
- else
- context_name = self.name.gsub(/Test/, "")
- context = Shoulda::Context.new(context_name, self) do
- should(name, &blk)
- end
- context.build
- end
- end
+require 'shoulda/color' if shoulda_options[:color]
- # Just like should, but never runs, and instead prints a differed message in the Test::Unit output.
- def should_eventually(name, &blk)
- context_name = self.name.gsub(/Test/, "")
- context = Shoulda::Context.new(context_name, self) do
- should_eventually(name, &blk)
- end
- context.build
- end
+module Test # :nodoc: all
+ module Unit
+ class TestCase
- # A context block groups should statements under a common set of setup/teardown methods.
- # Context blocks can be arbitrarily nested, and can do wonders for improving the maintainability
- # and readability of your test code.
- #
- # A context block can contain setup, should, should_eventually, and teardown blocks.
- #
- # class UserTest << Test::Unit::TestCase
- # context "A User instance" do
- # setup do
- # @user = User.find(:first)
- # end
- #
- # should "return its full name"
- # assert_equal 'John Doe', @user.full_name
- # end
- # end
- # end
- #
- # This code will produce the method <tt>"test: A User instance should return its full name. "</tt>.
- #
- # Contexts may be nested. Nested contexts run their setup blocks from out to in before each
- # should statement. They then run their teardown blocks from in to out after each should statement.
- #
- # class UserTest << Test::Unit::TestCase
- # context "A User instance" do
- # setup do
- # @user = User.find(:first)
- # end
- #
- # should "return its full name"
- # assert_equal 'John Doe', @user.full_name
- # end
- #
- # context "with a profile" do
- # setup do
- # @user.profile = Profile.find(:first)
- # end
- #
- # should "return true when sent :has_profile?"
- # assert @user.has_profile?
- # end
- # end
- # end
- # end
- #
- # This code will produce the following methods
- # * <tt>"test: A User instance should return its full name. "</tt>
- # * <tt>"test: A User instance with a profile should return true when sent :has_profile?. "</tt>
- #
- # <b>Just like should statements, a context block can exist next to normal <tt>def test_the_old_way; end</tt>
- # tests</b>. This means you do not have to fully commit to the context/should syntax in a test file.
+ include ThoughtBot::Shoulda::General
+ include ThoughtBot::Shoulda::Controller
- def context(name, &blk)
- if Shoulda.current_context
- Shoulda.current_context.context(name, &blk)
- else
- context = Shoulda::Context.new(name, self, &blk)
- context.build
+ extend ThoughtBot::Shoulda::ActiveRecord
end
end
end
-module Test # :nodoc: all
- module Unit
- class TestCase
- include Shoulda::General
- include Shoulda::Controller
- extend Shoulda::ActiveRecord
+module ActionController #:nodoc: all
+ module Integration
+ class Session
+ include ThoughtBot::Shoulda::General
end
end
end
-
Oops, something went wrong.

0 comments on commit b415bff

Please sign in to comment.