Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cosmetic: Whitespace

  • Loading branch information...
commit e2ae4a2596169bfbcb192fa3a4fd731cd6ffb69a 1 parent 226f5b8
@joshuaclayton joshuaclayton authored
Showing with 148 additions and 151 deletions.
  1. +5 −5 CONTRIBUTION_GUIDELINES.rdoc
  2. +5 −5 lib/shoulda/action_controller/matchers.rb
  3. +1 −1  lib/shoulda/action_controller/matchers/assign_to_matcher.rb
  4. +9 −9 lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
  5. +12 −12 lib/shoulda/action_controller/matchers/respond_with_matcher.rb
  6. +1 −1  lib/shoulda/action_controller/matchers/route_matcher.rb
  7. +2 −2 lib/shoulda/active_record/helpers.rb
  8. +2 −2 lib/shoulda/active_record/macros.rb
  9. +5 −5 lib/shoulda/active_record/matchers/association_matcher.rb
  10. +1 −1  lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
  11. +2 −2 lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
  12. +11 −11 lib/shoulda/active_record/matchers/have_db_column_matcher.rb
  13. +8 −8 lib/shoulda/active_record/matchers/have_db_index_matcher.rb
  14. +2 −4 lib/shoulda/active_record/matchers/validate_format_of_matcher.rb
  15. +3 −3 lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
  16. +0 −1  lib/shoulda/active_record/matchers/validation_matcher.rb
  17. +2 −2 lib/shoulda/assertions.rb
  18. +20 −20 lib/shoulda/autoload_macros.rb
  19. +11 −11 lib/shoulda/tasks/yaml_to_shoulda.rake
  20. +1 −1  rails/init.rb
  21. +22 −22 test/other/context_test.rb
  22. +1 −1  test/other/convert_to_should_syntax_test.rb
  23. +1 −1  test/other/private_helpers_test.rb
  24. +12 −12 test/other/should_test.rb
  25. +4 −4 test/rails2_model_builder.rb
  26. +4 −4 test/rails3_model_builder.rb
  27. +1 −1  test/unit/flea_test.rb
View
10 CONTRIBUTION_GUIDELINES.rdoc
@@ -1,10 +1,10 @@
-We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
+We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master].
* We prefer git branches over patches, but we can take either.
-* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
+* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
* If you're submitting patches, please cut each fix or feature into a separate patch.
-* There should be an issue[http://github.com/thoughtbot/shoulda/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
-* Please <b>don't send pull requests</b> Just update the issue with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
-* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
+* There should be an issue[http://github.com/thoughtbot/shoulda/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
+* Please <b>don't send pull requests</b> Just update the issue with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
+* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
View
10 lib/shoulda/action_controller/matchers.rb
@@ -14,24 +14,24 @@ module ActionController # :nodoc:
# By using the macro helpers you can quickly and easily create concise and
# easy to read test suites.
- #
+ #
# This code segment:
- #
+ #
# describe UsersController, "on GET to show with a valid id" do
# before(:each) do
# get :show, :id => User.first.to_param
# end
- #
+ #
# it { should assign_to(:user) }
# it { should respond_with(:success) }
# it { should render_template(:show) }
# it { should not_set_the_flash) }
- #
+ #
# it "should do something else really cool" do
# assigns[:user].id.should == 1
# end
# end
- #
+ #
# Would produce 5 tests for the show action
module Matchers
end
View
2  lib/shoulda/action_controller/matchers/assign_to_matcher.rb
@@ -63,7 +63,7 @@ def assigned_value?
"Expected action to assign a value for @#{@variable}"
false
else
- @negative_failure_message =
+ @negative_failure_message =
"Didn't expect action to assign a value for @#{@variable}, " <<
"but it was assigned to #{assigned_value.inspect}"
true
View
18 lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
@@ -34,7 +34,7 @@ def initialize(content_type)
def description
"respond with content type of #{@content_type}"
end
-
+
def matches?(controller)
@controller = controller
if @content_type.is_a?(Regexp)
@@ -43,32 +43,32 @@ def matches?(controller)
response_content_type == @content_type
end
end
-
+
def failure_message
"Expected #{expectation}"
end
-
+
def negative_failure_message
"Did not expect #{expectation}"
end
-
+
protected
-
+
def response_content_type
@controller.response.content_type.to_s
end
-
+
def lookup_by_extension(extension)
Mime::Type.lookup_by_extension(extension.to_s).to_s
end
-
+
def expectation
"content type to be #{@content_type}, " <<
"but was #{response_content_type}"
end
-
+
end
-
+
end
end
end
View
24 lib/shoulda/action_controller/matchers/respond_with_matcher.rb
@@ -24,16 +24,16 @@ class RespondWithMatcher # :nodoc:
def initialize(status)
@status = symbol_to_status_code(status)
end
-
+
def matches?(controller)
@controller = controller
correct_status_code? || correct_status_code_range?
end
-
+
def failure_message
"Expected #{expectation}"
end
-
+
def negative_failure_message
"Did not expect #{expectation}"
end
@@ -41,29 +41,29 @@ def negative_failure_message
def description
"respond with #{@status}"
end
-
+
protected
-
+
def correct_status_code?
response_code == @status
end
-
+
def correct_status_code_range?
@status.is_a?(Range) &&
@status.include?(response_code)
end
-
+
def response_code
@controller.response.response_code
end
-
+
def symbol_to_status_code(potential_symbol)
case potential_symbol
when :success then 200
when :redirect then 300..399
when :missing then 404
when :error then 500..599
- when Symbol
+ when Symbol
if defined?(::Rack::Utils::SYMBOL_TO_STATUS_CODE)
::Rack::Utils::SYMBOL_TO_STATUS_CODE[potential_symbol]
else
@@ -73,13 +73,13 @@ def symbol_to_status_code(potential_symbol)
potential_symbol
end
end
-
+
def expectation
"response to be a #{@status}, but was #{response_code}"
end
-
+
end
-
+
end
end
end
View
2  lib/shoulda/action_controller/matchers/route_matcher.rb
@@ -71,7 +71,7 @@ def stringify_params!
def route_recognized?
begin
- @context.send(:assert_routing,
+ @context.send(:assert_routing,
{ :method => @method, :path => @path },
@params)
View
4 lib/shoulda/active_record/helpers.rb
@@ -2,8 +2,8 @@ module Shoulda # :nodoc:
module ActiveRecord # :nodoc:
module Helpers
def pretty_error_messages(obj) # :nodoc:
- obj.errors.map do |a, m|
- msg = "#{a} #{m}"
+ obj.errors.map do |a, m|
+ msg = "#{a} #{m}"
msg << " (#{obj.send(a).inspect})" unless a.to_sym == :base
end
end
View
4 lib/shoulda/active_record/macros.rb
@@ -377,7 +377,7 @@ def should_have_instance_methods(*methods)
#
# Ensure that the given columns are defined on the models backing SQL table.
# Also aliased to should_have_db_column for readability.
- # Takes the same options available in migrations:
+ # Takes the same options available in migrations:
# :type, :precision, :limit, :default, :null, and :scale
#
# Examples:
@@ -390,7 +390,7 @@ def should_have_instance_methods(*methods)
#
def should_have_db_columns(*columns)
::ActiveSupport::Deprecation.warn("use: should have_db_column")
- column_type, precision, limit, default, null, scale, sql_type =
+ column_type, precision, limit, default, null, scale, sql_type =
get_options!(columns, :type, :precision, :limit,
:default, :null, :scale, :sql_type)
columns.each do |name|
View
10 lib/shoulda/active_record/matchers/association_matcher.rb
@@ -70,10 +70,10 @@ def dependent(dependent)
def matches?(subject)
@subject = subject
- association_exists? &&
- macro_correct? &&
- foreign_key_exists? &&
- through_association_valid? &&
+ association_exists? &&
+ macro_correct? &&
+ foreign_key_exists? &&
+ through_association_valid? &&
dependent_correct? &&
join_table_exists?
end
@@ -160,7 +160,7 @@ def dependent_correct?
end
def join_table_exists?
- if @macro != :has_and_belongs_to_many ||
+ if @macro != :has_and_belongs_to_many ||
::ActiveRecord::Base.connection.tables.include?(join_table.to_s)
true
else
View
2  lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
@@ -57,7 +57,7 @@ def matches?(subject)
@low_message ||= :inclusion
@high_message ||= :inclusion
- disallows_lower_value &&
+ disallows_lower_value &&
allows_minimum_value &&
disallows_higher_value &&
allows_maximum_value
View
4 lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
@@ -84,7 +84,7 @@ def description
def matches?(subject)
super(subject)
translate_messages!
- disallows_lower_length &&
+ disallows_lower_length &&
allows_minimum_length &&
((@minimum == @maximum) ||
(disallows_higher_length &&
@@ -106,7 +106,7 @@ def translate_messages!
end
def disallows_lower_length
- @minimum == 0 ||
+ @minimum == 0 ||
@minimum.nil? ||
disallows_length_of(@minimum - 1, @short_message)
end
View
22 lib/shoulda/active_record/matchers/have_db_column_matcher.rb
@@ -24,12 +24,12 @@ def initialize(macro, column)
@macro = macro
@column = column
end
-
+
def of_type(column_type)
@column_type = column_type
self
end
-
+
def with_options(opts = {})
@precision = opts[:precision]
@limit = opts[:limit]
@@ -41,8 +41,8 @@ def with_options(opts = {})
def matches?(subject)
@subject = subject
- column_exists? &&
- correct_column_type? &&
+ column_exists? &&
+ correct_column_type? &&
correct_precision? &&
correct_limit? &&
correct_default? &&
@@ -80,7 +80,7 @@ def column_exists?
false
end
end
-
+
def correct_column_type?
return true if @column_type.nil?
if matched_column.type.to_s == @column_type.to_s
@@ -91,7 +91,7 @@ def correct_column_type?
false
end
end
-
+
def correct_precision?
return true if @precision.nil?
if matched_column.precision.to_s == @precision.to_s
@@ -103,7 +103,7 @@ def correct_precision?
false
end
end
-
+
def correct_limit?
return true if @limit.nil?
if matched_column.limit.to_s == @limit.to_s
@@ -115,7 +115,7 @@ def correct_limit?
false
end
end
-
+
def correct_default?
return true if @default.nil?
if matched_column.default.to_s == @default.to_s
@@ -127,7 +127,7 @@ def correct_default?
false
end
end
-
+
def correct_null?
return true if @null.nil?
if matched_column.null.to_s == @null.to_s
@@ -139,7 +139,7 @@ def correct_null?
false
end
end
-
+
def correct_scale?
return true if @scale.nil?
if matched_column.scale.to_s == @scale.to_s
@@ -150,7 +150,7 @@ def correct_scale?
false
end
end
-
+
def matched_column
model_class.columns.detect { |each| each.name == @column.to_s }
end
View
16 lib/shoulda/active_record/matchers/have_db_index_matcher.rb
@@ -27,7 +27,7 @@ def initialize(macro, columns)
@macro = macro
@columns = normalize_columns_to_array(columns)
end
-
+
def unique(unique)
@unique = unique
self
@@ -51,11 +51,11 @@ def description
end
protected
-
+
def index_exists?
! matched_index.nil?
end
-
+
def correct_unique?
return true if @unique.nil?
if matched_index.unique == @unique
@@ -66,7 +66,7 @@ def correct_unique?
false
end
end
-
+
def matched_index
indexes.detect { |each| each.columns == @columns }
end
@@ -74,11 +74,11 @@ def matched_index
def model_class
@subject.class
end
-
+
def table_name
model_class.table_name
end
-
+
def indexes
::ActiveRecord::Base.connection.indexes(table_name)
end
@@ -86,7 +86,7 @@ def indexes
def expectation
expected = "#{model_class.name} to #{description}"
end
-
+
def index_type
case @unique
when nil
@@ -97,7 +97,7 @@ def index_type
'unique'
end
end
-
+
def normalize_columns_to_array(columns)
if columns.class == Array
columns.collect { |each| each.to_s }
View
6 lib/shoulda/active_record/matchers/validate_format_of_matcher.rb
@@ -25,7 +25,7 @@ def validate_format_of(attr)
end
class ValidateFormatOfMatcher < ValidationMatcher # :nodoc:
-
+
def initialize(attribute)
super
end
@@ -34,13 +34,12 @@ def with_message(message)
@expected_message = message if message
self
end
-
+
def with(value)
raise "You may not call both with and not_with" if @value_to_fail
@value_to_pass = value
self
end
-
def not_with(value)
raise "You may not call both with and not_with" if @value_to_pass
@@ -48,7 +47,6 @@ def not_with(value)
self
end
-
def matches?(subject)
super(subject)
@expected_message ||= :blank
View
6 lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
@@ -67,8 +67,8 @@ def description
def matches?(subject)
@subject = subject.class.new
@expected_message ||= :taken
- find_existing &&
- set_scoped_attributes &&
+ find_existing &&
+ set_scoped_attributes &&
validate_attribute &&
validate_after_scope_change
end
@@ -121,7 +121,7 @@ def validate_after_scope_change
@subject.send("#{scope}=", next_value)
if allows_value_of(existing_value, @expected_message)
- @negative_failure_message <<
+ @negative_failure_message <<
" (with different value of #{scope})"
true
else
View
1  lib/shoulda/active_record/matchers/validation_matcher.rb
@@ -18,7 +18,6 @@ def matches?(subject)
@subject = subject
false
end
-
private
View
4 lib/shoulda/assertions.rb
@@ -26,7 +26,7 @@ def assert_contains(collection, x, extra_msg = "")
case x
when Regexp
assert(collection.detect { |e| e =~ x }, msg)
- else
+ else
assert(collection.include?(x), msg)
end
end
@@ -39,7 +39,7 @@ def assert_does_not_contain(collection, x, extra_msg = "")
case x
when Regexp
assert(!collection.detect { |e| e =~ x }, msg)
- else
+ else
assert(!collection.include?(x), msg)
end
end
View
40 lib/shoulda/autoload_macros.rb
@@ -1,40 +1,40 @@
module Shoulda # :nodoc:
- # Call autoload_macros when you want to load test macros automatically in a non-Rails
+ # Call autoload_macros when you want to load test macros automatically in a non-Rails
# project (it's done automatically for Rails projects).
# You don't need to specify ROOT/test/shoulda_macros explicitly. Your custom macros
# are loaded automatically when you call autoload_macros.
#
# The first argument is the path to you application's root directory.
- # All following arguments are directories relative to your root, which contain
- # shoulda_macros subdirectories. These directories support the same kinds of globs as the
+ # All following arguments are directories relative to your root, which contain
+ # shoulda_macros subdirectories. These directories support the same kinds of globs as the
# Dir class.
- #
+ #
# Basic usage (from a test_helper):
# Shoulda.autoload_macros(File.dirname(__FILE__) + '/..')
- # will load everything in
- # - your_app/test/shoulda_macros
+ # will load everything in
+ # - your_app/test/shoulda_macros
#
- # To load vendored macros as well:
+ # To load vendored macros as well:
# Shoulda.autoload_macros(APP_ROOT, 'vendor/*')
- # will load everything in
- # - APP_ROOT/vendor/*/shoulda_macros
- # - APP_ROOT/test/shoulda_macros
+ # will load everything in
+ # - APP_ROOT/vendor/*/shoulda_macros
+ # - APP_ROOT/test/shoulda_macros
#
- # To load macros in an app with a vendor directory laid out like Rails':
+ # To load macros in an app with a vendor directory laid out like Rails':
# Shoulda.autoload_macros(APP_ROOT, 'vendor/{plugins,gems}/*')
# or
# Shoulda.autoload_macros(APP_ROOT, 'vendor/plugins/*', 'vendor/gems/*')
- # will load everything in
- # - APP_ROOT/vendor/plugins/*/shoulda_macros
- # - APP_ROOT/vendor/gems/*/shoulda_macros
- # - APP_ROOT/test/shoulda_macros
+ # will load everything in
+ # - APP_ROOT/vendor/plugins/*/shoulda_macros
+ # - APP_ROOT/vendor/gems/*/shoulda_macros
+ # - APP_ROOT/test/shoulda_macros
#
- # If you prefer to stick testing dependencies away from your production dependencies:
+ # If you prefer to stick testing dependencies away from your production dependencies:
# Shoulda.autoload_macros(APP_ROOT, 'vendor/*', 'test/vendor/*')
- # will load everything in
- # - APP_ROOT/vendor/*/shoulda_macros
- # - APP_ROOT/test/vendor/*/shoulda_macros
- # - APP_ROOT/test/shoulda_macros
+ # will load everything in
+ # - APP_ROOT/vendor/*/shoulda_macros
+ # - APP_ROOT/test/vendor/*/shoulda_macros
+ # - APP_ROOT/test/shoulda_macros
def self.autoload_macros(root, *dirs)
dirs << File.join('test')
complete_dirs = dirs.map{|d| File.join(root, d, 'shoulda_macros')}
View
22 lib/shoulda/tasks/yaml_to_shoulda.rake
@@ -1,28 +1,28 @@
namespace :shoulda do
# From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
# David.Lowenfels@gmail.com
- desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
+ desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
task :from_yaml do
require 'yaml'
-
+
def yaml_to_context(hash, indent = 0)
indent1 = ' ' * indent
indent2 = ' ' * (indent + 1)
hash.each_pair do |context, shoulds|
- puts indent1 + "context \"#{context}\" do"
- puts
+ puts indent1 + "context \"#{context}\" do"
+ puts
shoulds.each do |should|
yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash )
- puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
- puts indent2 + "end"
+ puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
+ puts indent2 + "end"
puts
end
- puts indent1 + "end"
+ puts indent1 + "end"
end
- end
-
+ end
+
puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
-
+
yaml_to_context( YAML.load_file( ENV['FILE'] ) )
end
-end
+end
View
2  rails/init.rb
@@ -2,7 +2,7 @@
if defined? Spec
require 'shoulda/rspec'
else
- require 'shoulda/rails'
+ require 'shoulda/rails'
Shoulda.autoload_macros RAILS_ROOT, File.join("vendor", "{plugins,gems}", "*")
end
end
View
44 test/other/context_test.rb
@@ -1,12 +1,12 @@
require 'test_helper'
class ContextTest < ActiveSupport::TestCase # :nodoc:
-
+
def self.context_macro(&blk)
context "with a subcontext made by a macro" do
setup { @context_macro = :foo }
- merge_block &blk
+ merge_block &blk
end
end
@@ -21,11 +21,11 @@ def self.context_macro(&blk)
setup do
@blah = "blah"
end
-
+
should "run the setup block" do
assert_equal "blah", @blah
end
-
+
should "have name set right" do
assert_match(/^test: context with setup block/, self.to_s)
end
@@ -34,11 +34,11 @@ def self.context_macro(&blk)
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 blocks in order" do
assert_equal @blah, "blah twice"
end
@@ -64,7 +64,7 @@ def self.context_macro(&blk)
setup do
@blah = "foo"
end
-
+
should "have @blah == 'foo'" do
assert_equal "foo", @blah
end
@@ -73,12 +73,12 @@ def self.context_macro(&blk)
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
@@ -87,52 +87,52 @@ def hello; "hi"; end
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
-
+
context "context with multiple setups and/or teardowns" do
-
+
cleanup_count = 0
-
+
2.times do |i|
setup { cleanup_count += 1 }
teardown { cleanup_count -= 1 }
end
-
+
2.times do |i|
should "call all setups and all teardowns (check ##{i + 1})" do
assert_equal 2, cleanup_count
end
end
-
+
context "subcontexts" do
-
+
2.times do |i|
setup { cleanup_count += 1 }
teardown { cleanup_count -= 1 }
end
-
+
2.times do |i|
should "also call all setups and all teardowns in parent and subcontext (check ##{i + 1})" do
assert_equal 4, cleanup_count
end
end
-
+
end
-
+
end
-
+
should_eventually "pass, since it's unimplemented" do
flunk "what?"
end
should_eventually "not require a block when using should_eventually"
should "pass without a block, as that causes it to piggyback to should_eventually"
-
+
context "context for testing should piggybacking" do
should "call should_eventually as we are not passing a block"
end
@@ -164,7 +164,7 @@ class ::SomeModel; end
should "return the result of the block as the subject" do
assert_equal @expected, subject
end
-
+
context "nested context block without a subject block" do
should "return the result of the parent context's subject block" do
assert_equal @expected, subject
View
2  test/other/convert_to_should_syntax_test.rb
@@ -41,7 +41,7 @@ def non_test_method
end
EOS
-
+
FIXTURE_PATH = "./convert_to_should_syntax_fixture.dat"
RUBY = ENV['RUBY'] || 'ruby'
View
2  test/other/private_helpers_test.rb
@@ -22,7 +22,7 @@ class PrivateHelpersTest < ActiveSupport::TestCase # :nodoc:
get_options!(args, :one)
end
end
-
+
should "return single wanted option" do
args = [:a, :b, {:class => Object}]
klass = get_options!(args,:class)
View
24 test/other/should_test.rb
@@ -4,11 +4,11 @@ class ShouldTest < ActiveSupport::TestCase # :nodoc:
should "be able to define a should statement outside of a context" do
assert true
end
-
+
should "see the name of my class as ShouldTest" do
assert_equal "ShouldTest", self.class.name
end
-
+
def self.should_see_class_methods
should "be able to see class methods" do
assert true
@@ -27,13 +27,13 @@ def self.should_see_a_context_block_like_a_Test_Unit_class
def self.should_see_blah
should "see @blah through a macro" do
- assert @blah
+ assert @blah
end
end
def self.should_not_see_blah
should "not see @blah through a macro" do
- assert_nil @blah
+ assert_nil @blah
end
end
@@ -75,12 +75,12 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
setup do
@blah = "blah"
end
-
+
should "have @blah == 'blah'" do
assert_equal "blah", @blah
end
should_see_blah
-
+
should "have name set right" do
assert_match(/^test: Context with setup block/, self.to_s)
end
@@ -89,11 +89,11 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
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
@@ -105,7 +105,7 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
setup do
@blah = "foo"
end
-
+
should "have @blah == 'foo'" do
assert_equal "foo", @blah
end
@@ -115,7 +115,7 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
end
should_see_blah
end
-
+
should_eventually "pass, since it's a should_eventually" do
flunk "what?"
end
@@ -152,7 +152,7 @@ def test_should_have_should_hashes_when_given_should_statements
should "be good" do; end
should "another" do; end
end
-
+
names = context.shoulds.map {|s| s[:name]}
assert_equal ["another", "be good"], names.sort
end
@@ -164,7 +164,7 @@ def test_should_capture_setup_and_teardown_blocks
setup do; "setup"; end
teardown do; "teardown"; end
end
-
+
assert_equal "setup", context.setup_blocks.first.call
assert_equal "teardown", context.teardown_blocks.first.call
end
View
8 test/rails2_model_builder.rb
@@ -1,11 +1,11 @@
-class ActiveSupport::TestCase
+class ActiveSupport::TestCase
TMP_VIEW_PATH =
File.expand_path(File.join(File.dirname(__FILE__), 'rails2_root', 'tmp', 'views')).freeze
def create_table(table_name, &block)
connection = ActiveRecord::Base.connection
-
+
begin
connection.execute("DROP TABLE IF EXISTS #{table_name}")
connection.create_table(table_name, &block)
@@ -77,7 +77,7 @@ def build_response(opts = {}, &block)
klass = define_controller('Examples')
block ||= lambda { render :nothing => true }
klass.class_eval { define_method(action, &block) }
- define_routes do |map|
+ define_routes do |map|
map.connect 'examples', :controller => 'examples', :action => action
end
@@ -100,7 +100,7 @@ def create_view(path, contents)
def teardown_with_models
if @defined_constants
- @defined_constants.each do |class_name|
+ @defined_constants.each do |class_name|
Object.send(:remove_const, class_name)
end
end
View
8 test/rails3_model_builder.rb
@@ -1,11 +1,11 @@
-class ActiveSupport::TestCase
+class ActiveSupport::TestCase
TMP_VIEW_PATH =
File.expand_path(File.join(File.dirname(__FILE__), 'rails3_root', 'tmp', 'views')).freeze
def create_table(table_name, &block)
connection = ActiveRecord::Base.connection
-
+
begin
connection.execute("DROP TABLE IF EXISTS #{table_name}")
connection.create_table(table_name, &block)
@@ -69,7 +69,7 @@ def build_response(opts = {}, &block)
klass = define_controller('Examples')
block ||= lambda { render :nothing => true }
klass.class_eval { layout false; define_method(action, &block) }
- define_routes do |map|
+ define_routes do |map|
map.connect 'examples', :controller => 'examples', :action => action
end
@@ -94,7 +94,7 @@ def create_view(path, contents)
def teardown_with_models
if @defined_constants
- @defined_constants.each do |class_name|
+ @defined_constants.each do |class_name|
Object.send(:remove_const, class_name)
end
end
View
2  test/unit/flea_test.rb
@@ -4,7 +4,7 @@ class FleaTest < ActiveSupport::TestCase
should_have_and_belong_to_many :dogs
context "when a flea is created" do
- setup do
+ setup do
Flea.create
end
Please sign in to comment.
Something went wrong with that request. Please try again.