0
-require 'shoulda/
context'
0
+require 'shoulda/
gem/shoulda'
0
require 'shoulda/private_helpers'
0
require 'shoulda/general'
0
+require 'shoulda/active_record_helpers'
0
+require 'shoulda/controller_tests/controller_tests.rb'
0
-require 'shoulda/active_record_helpers' if defined?(ActiveRecord)
0
-require 'shoulda/controller_tests/controller_tests.rb' if defined?(ActionController)
0
-config_files << "shoulda.conf"
0
-config_files << File.join("test", "shoulda.conf")
0
-config_files << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT)
0
-config_files << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"]
0
-config_files.each do |file|
0
- shoulda_options.merge!(YAML.load_file(file).symbolize_keys) if File.exists? file
0
-require 'shoulda/color' if shoulda_options[:color]
0
+possible_config_paths = []
0
+possible_config_paths << File.join(ENV["HOME"], ".shoulda.conf") if ENV["HOME"]
0
+possible_config_paths << "shoulda.conf"
0
+possible_config_paths << File.join("test", "shoulda.conf")
0
+possible_config_paths << File.join(RAILS_ROOT, "test", "shoulda.conf") if defined?(RAILS_ROOT)
0
- attr_accessor :current_context
0
+possible_config_paths.each do |config_file|
0
+ if File.exists? config_file
0
+ shoulda_options = YAML.load_file(config_file).symbolize_keys
0
- # Should statements are just syntactic sugar over normal Test::Unit test methods. A should block
0
- # contains all the normal code and assertions you're used to seeing, with the added benefit that
0
- # they can be wrapped inside context blocks (see below).
0
- # class UserTest << Test::Unit::TestCase
0
- # @user = User.new("John", "Doe")
0
- # should "return its full name"
0
- # assert_equal 'John Doe', @user.full_name
0
- # ...will produce the following test:
0
- # * <tt>"test: User should return its full name. "</tt>
0
- # Note: The part before <tt>should</tt> in the test name is gleamed from the name of the Test::Unit class.
0
- def should(name, &blk)
0
- should_eventually(name) && return unless block_given?
0
- if Shoulda.current_context
0
- Shoulda.current_context.should(name, &blk)
0
- context_name = self.name.gsub(/Test/, "")
0
- context = Shoulda::Context.new(context_name, self) do
0
+require 'shoulda/color' if shoulda_options[:color]
0
- # Just like should, but never runs, and instead prints a differed message in the Test::Unit output.
0
- def should_eventually(name, &blk)
0
- context_name = self.name.gsub(/Test/, "")
0
- context = Shoulda::Context.new(context_name, self) do
0
- should_eventually(name, &blk)
0
+module Test # :nodoc: all
0
- # A context block groups should statements under a common set of setup/teardown methods.
0
- # Context blocks can be arbitrarily nested, and can do wonders for improving the maintainability
0
- # and readability of your test code.
0
- # A context block can contain setup, should, should_eventually, and teardown blocks.
0
- # class UserTest << Test::Unit::TestCase
0
- # context "A User instance" do
0
- # @user = User.find(:first)
0
- # should "return its full name"
0
- # assert_equal 'John Doe', @user.full_name
0
- # This code will produce the method <tt>"test: A User instance should return its full name. "</tt>.
0
- # Contexts may be nested. Nested contexts run their setup blocks from out to in before each
0
- # should statement. They then run their teardown blocks from in to out after each should statement.
0
- # class UserTest << Test::Unit::TestCase
0
- # context "A User instance" do
0
- # @user = User.find(:first)
0
- # should "return its full name"
0
- # assert_equal 'John Doe', @user.full_name
0
- # context "with a profile" do
0
- # @user.profile = Profile.find(:first)
0
- # should "return true when sent :has_profile?"
0
- # assert @user.has_profile?
0
- # This code will produce the following methods
0
- # * <tt>"test: A User instance should return its full name. "</tt>
0
- # * <tt>"test: A User instance with a profile should return true when sent :has_profile?. "</tt>
0
- # <b>Just like should statements, a context block can exist next to normal <tt>def test_the_old_way; end</tt>
0
- # tests</b>. This means you do not have to fully commit to the context/should syntax in a test file.
0
+ include ThoughtBot::Shoulda::General
0
+ include ThoughtBot::Shoulda::Controller
0
- def context(name, &blk)
0
- if Shoulda.current_context
0
- Shoulda.current_context.context(name, &blk)
0
- context = Shoulda::Context.new(name, self, &blk)
0
+ extend ThoughtBot::Shoulda::ActiveRecord
0
-module Test # :nodoc: all
0
- include Shoulda::General
0
- include Shoulda::Controller
0
- extend Shoulda::ActiveRecord
0
+module ActionController #:nodoc: all
0
+ include ThoughtBot::Shoulda::General