Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cosmetic: Whitespace

  • Loading branch information...
commit e2ae4a2596169bfbcb192fa3a4fd731cd6ffb69a 1 parent 226f5b8
Joshua Clayton joshuaclayton authored

Showing 27 changed files with 148 additions and 151 deletions. Show diff stats Hide diff stats

  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
10 CONTRIBUTION_GUIDELINES.rdoc
Source Rendered
... ... @@ -1,10 +1,10 @@
1   -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.
  1 +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.
2 2
3 3 * Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master].
4 4 * We prefer git branches over patches, but we can take either.
5   -* 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.
  5 +* 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.
6 6 * If you're submitting patches, please cut each fix or feature into a separate patch.
7   -* 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.
8   -* 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.
9   -* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
  7 +* 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.
  8 +* 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.
  9 +* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
10 10
10 lib/shoulda/action_controller/matchers.rb
@@ -14,24 +14,24 @@ module ActionController # :nodoc:
14 14
15 15 # By using the macro helpers you can quickly and easily create concise and
16 16 # easy to read test suites.
17   - #
  17 + #
18 18 # This code segment:
19   - #
  19 + #
20 20 # describe UsersController, "on GET to show with a valid id" do
21 21 # before(:each) do
22 22 # get :show, :id => User.first.to_param
23 23 # end
24   - #
  24 + #
25 25 # it { should assign_to(:user) }
26 26 # it { should respond_with(:success) }
27 27 # it { should render_template(:show) }
28 28 # it { should not_set_the_flash) }
29   - #
  29 + #
30 30 # it "should do something else really cool" do
31 31 # assigns[:user].id.should == 1
32 32 # end
33 33 # end
34   - #
  34 + #
35 35 # Would produce 5 tests for the show action
36 36 module Matchers
37 37 end
2  lib/shoulda/action_controller/matchers/assign_to_matcher.rb
@@ -63,7 +63,7 @@ def assigned_value?
63 63 "Expected action to assign a value for @#{@variable}"
64 64 false
65 65 else
66   - @negative_failure_message =
  66 + @negative_failure_message =
67 67 "Didn't expect action to assign a value for @#{@variable}, " <<
68 68 "but it was assigned to #{assigned_value.inspect}"
69 69 true
18 lib/shoulda/action_controller/matchers/respond_with_content_type_matcher.rb
@@ -34,7 +34,7 @@ def initialize(content_type)
34 34 def description
35 35 "respond with content type of #{@content_type}"
36 36 end
37   -
  37 +
38 38 def matches?(controller)
39 39 @controller = controller
40 40 if @content_type.is_a?(Regexp)
@@ -43,32 +43,32 @@ def matches?(controller)
43 43 response_content_type == @content_type
44 44 end
45 45 end
46   -
  46 +
47 47 def failure_message
48 48 "Expected #{expectation}"
49 49 end
50   -
  50 +
51 51 def negative_failure_message
52 52 "Did not expect #{expectation}"
53 53 end
54   -
  54 +
55 55 protected
56   -
  56 +
57 57 def response_content_type
58 58 @controller.response.content_type.to_s
59 59 end
60   -
  60 +
61 61 def lookup_by_extension(extension)
62 62 Mime::Type.lookup_by_extension(extension.to_s).to_s
63 63 end
64   -
  64 +
65 65 def expectation
66 66 "content type to be #{@content_type}, " <<
67 67 "but was #{response_content_type}"
68 68 end
69   -
  69 +
70 70 end
71   -
  71 +
72 72 end
73 73 end
74 74 end
24 lib/shoulda/action_controller/matchers/respond_with_matcher.rb
@@ -24,16 +24,16 @@ class RespondWithMatcher # :nodoc:
24 24 def initialize(status)
25 25 @status = symbol_to_status_code(status)
26 26 end
27   -
  27 +
28 28 def matches?(controller)
29 29 @controller = controller
30 30 correct_status_code? || correct_status_code_range?
31 31 end
32   -
  32 +
33 33 def failure_message
34 34 "Expected #{expectation}"
35 35 end
36   -
  36 +
37 37 def negative_failure_message
38 38 "Did not expect #{expectation}"
39 39 end
@@ -41,29 +41,29 @@ def negative_failure_message
41 41 def description
42 42 "respond with #{@status}"
43 43 end
44   -
  44 +
45 45 protected
46   -
  46 +
47 47 def correct_status_code?
48 48 response_code == @status
49 49 end
50   -
  50 +
51 51 def correct_status_code_range?
52 52 @status.is_a?(Range) &&
53 53 @status.include?(response_code)
54 54 end
55   -
  55 +
56 56 def response_code
57 57 @controller.response.response_code
58 58 end
59   -
  59 +
60 60 def symbol_to_status_code(potential_symbol)
61 61 case potential_symbol
62 62 when :success then 200
63 63 when :redirect then 300..399
64 64 when :missing then 404
65 65 when :error then 500..599
66   - when Symbol
  66 + when Symbol
67 67 if defined?(::Rack::Utils::SYMBOL_TO_STATUS_CODE)
68 68 ::Rack::Utils::SYMBOL_TO_STATUS_CODE[potential_symbol]
69 69 else
@@ -73,13 +73,13 @@ def symbol_to_status_code(potential_symbol)
73 73 potential_symbol
74 74 end
75 75 end
76   -
  76 +
77 77 def expectation
78 78 "response to be a #{@status}, but was #{response_code}"
79 79 end
80   -
  80 +
81 81 end
82   -
  82 +
83 83 end
84 84 end
85 85 end
2  lib/shoulda/action_controller/matchers/route_matcher.rb
@@ -71,7 +71,7 @@ def stringify_params!
71 71
72 72 def route_recognized?
73 73 begin
74   - @context.send(:assert_routing,
  74 + @context.send(:assert_routing,
75 75 { :method => @method, :path => @path },
76 76 @params)
77 77
4 lib/shoulda/active_record/helpers.rb
@@ -2,8 +2,8 @@ module Shoulda # :nodoc:
2 2 module ActiveRecord # :nodoc:
3 3 module Helpers
4 4 def pretty_error_messages(obj) # :nodoc:
5   - obj.errors.map do |a, m|
6   - msg = "#{a} #{m}"
  5 + obj.errors.map do |a, m|
  6 + msg = "#{a} #{m}"
7 7 msg << " (#{obj.send(a).inspect})" unless a.to_sym == :base
8 8 end
9 9 end
4 lib/shoulda/active_record/macros.rb
@@ -377,7 +377,7 @@ def should_have_instance_methods(*methods)
377 377 #
378 378 # Ensure that the given columns are defined on the models backing SQL table.
379 379 # Also aliased to should_have_db_column for readability.
380   - # Takes the same options available in migrations:
  380 + # Takes the same options available in migrations:
381 381 # :type, :precision, :limit, :default, :null, and :scale
382 382 #
383 383 # Examples:
@@ -390,7 +390,7 @@ def should_have_instance_methods(*methods)
390 390 #
391 391 def should_have_db_columns(*columns)
392 392 ::ActiveSupport::Deprecation.warn("use: should have_db_column")
393   - column_type, precision, limit, default, null, scale, sql_type =
  393 + column_type, precision, limit, default, null, scale, sql_type =
394 394 get_options!(columns, :type, :precision, :limit,
395 395 :default, :null, :scale, :sql_type)
396 396 columns.each do |name|
10 lib/shoulda/active_record/matchers/association_matcher.rb
@@ -70,10 +70,10 @@ def dependent(dependent)
70 70
71 71 def matches?(subject)
72 72 @subject = subject
73   - association_exists? &&
74   - macro_correct? &&
75   - foreign_key_exists? &&
76   - through_association_valid? &&
  73 + association_exists? &&
  74 + macro_correct? &&
  75 + foreign_key_exists? &&
  76 + through_association_valid? &&
77 77 dependent_correct? &&
78 78 join_table_exists?
79 79 end
@@ -160,7 +160,7 @@ def dependent_correct?
160 160 end
161 161
162 162 def join_table_exists?
163   - if @macro != :has_and_belongs_to_many ||
  163 + if @macro != :has_and_belongs_to_many ||
164 164 ::ActiveRecord::Base.connection.tables.include?(join_table.to_s)
165 165 true
166 166 else
2  lib/shoulda/active_record/matchers/ensure_inclusion_of_matcher.rb
@@ -57,7 +57,7 @@ def matches?(subject)
57 57 @low_message ||= :inclusion
58 58 @high_message ||= :inclusion
59 59
60   - disallows_lower_value &&
  60 + disallows_lower_value &&
61 61 allows_minimum_value &&
62 62 disallows_higher_value &&
63 63 allows_maximum_value
4 lib/shoulda/active_record/matchers/ensure_length_of_matcher.rb
@@ -84,7 +84,7 @@ def description
84 84 def matches?(subject)
85 85 super(subject)
86 86 translate_messages!
87   - disallows_lower_length &&
  87 + disallows_lower_length &&
88 88 allows_minimum_length &&
89 89 ((@minimum == @maximum) ||
90 90 (disallows_higher_length &&
@@ -106,7 +106,7 @@ def translate_messages!
106 106 end
107 107
108 108 def disallows_lower_length
109   - @minimum == 0 ||
  109 + @minimum == 0 ||
110 110 @minimum.nil? ||
111 111 disallows_length_of(@minimum - 1, @short_message)
112 112 end
22 lib/shoulda/active_record/matchers/have_db_column_matcher.rb
@@ -24,12 +24,12 @@ def initialize(macro, column)
24 24 @macro = macro
25 25 @column = column
26 26 end
27   -
  27 +
28 28 def of_type(column_type)
29 29 @column_type = column_type
30 30 self
31 31 end
32   -
  32 +
33 33 def with_options(opts = {})
34 34 @precision = opts[:precision]
35 35 @limit = opts[:limit]
@@ -41,8 +41,8 @@ def with_options(opts = {})
41 41
42 42 def matches?(subject)
43 43 @subject = subject
44   - column_exists? &&
45   - correct_column_type? &&
  44 + column_exists? &&
  45 + correct_column_type? &&
46 46 correct_precision? &&
47 47 correct_limit? &&
48 48 correct_default? &&
@@ -80,7 +80,7 @@ def column_exists?
80 80 false
81 81 end
82 82 end
83   -
  83 +
84 84 def correct_column_type?
85 85 return true if @column_type.nil?
86 86 if matched_column.type.to_s == @column_type.to_s
@@ -91,7 +91,7 @@ def correct_column_type?
91 91 false
92 92 end
93 93 end
94   -
  94 +
95 95 def correct_precision?
96 96 return true if @precision.nil?
97 97 if matched_column.precision.to_s == @precision.to_s
@@ -103,7 +103,7 @@ def correct_precision?
103 103 false
104 104 end
105 105 end
106   -
  106 +
107 107 def correct_limit?
108 108 return true if @limit.nil?
109 109 if matched_column.limit.to_s == @limit.to_s
@@ -115,7 +115,7 @@ def correct_limit?
115 115 false
116 116 end
117 117 end
118   -
  118 +
119 119 def correct_default?
120 120 return true if @default.nil?
121 121 if matched_column.default.to_s == @default.to_s
@@ -127,7 +127,7 @@ def correct_default?
127 127 false
128 128 end
129 129 end
130   -
  130 +
131 131 def correct_null?
132 132 return true if @null.nil?
133 133 if matched_column.null.to_s == @null.to_s
@@ -139,7 +139,7 @@ def correct_null?
139 139 false
140 140 end
141 141 end
142   -
  142 +
143 143 def correct_scale?
144 144 return true if @scale.nil?
145 145 if matched_column.scale.to_s == @scale.to_s
@@ -150,7 +150,7 @@ def correct_scale?
150 150 false
151 151 end
152 152 end
153   -
  153 +
154 154 def matched_column
155 155 model_class.columns.detect { |each| each.name == @column.to_s }
156 156 end
16 lib/shoulda/active_record/matchers/have_db_index_matcher.rb
@@ -27,7 +27,7 @@ def initialize(macro, columns)
27 27 @macro = macro
28 28 @columns = normalize_columns_to_array(columns)
29 29 end
30   -
  30 +
31 31 def unique(unique)
32 32 @unique = unique
33 33 self
@@ -51,11 +51,11 @@ def description
51 51 end
52 52
53 53 protected
54   -
  54 +
55 55 def index_exists?
56 56 ! matched_index.nil?
57 57 end
58   -
  58 +
59 59 def correct_unique?
60 60 return true if @unique.nil?
61 61 if matched_index.unique == @unique
@@ -66,7 +66,7 @@ def correct_unique?
66 66 false
67 67 end
68 68 end
69   -
  69 +
70 70 def matched_index
71 71 indexes.detect { |each| each.columns == @columns }
72 72 end
@@ -74,11 +74,11 @@ def matched_index
74 74 def model_class
75 75 @subject.class
76 76 end
77   -
  77 +
78 78 def table_name
79 79 model_class.table_name
80 80 end
81   -
  81 +
82 82 def indexes
83 83 ::ActiveRecord::Base.connection.indexes(table_name)
84 84 end
@@ -86,7 +86,7 @@ def indexes
86 86 def expectation
87 87 expected = "#{model_class.name} to #{description}"
88 88 end
89   -
  89 +
90 90 def index_type
91 91 case @unique
92 92 when nil
@@ -97,7 +97,7 @@ def index_type
97 97 'unique'
98 98 end
99 99 end
100   -
  100 +
101 101 def normalize_columns_to_array(columns)
102 102 if columns.class == Array
103 103 columns.collect { |each| each.to_s }
6 lib/shoulda/active_record/matchers/validate_format_of_matcher.rb
@@ -25,7 +25,7 @@ def validate_format_of(attr)
25 25 end
26 26
27 27 class ValidateFormatOfMatcher < ValidationMatcher # :nodoc:
28   -
  28 +
29 29 def initialize(attribute)
30 30 super
31 31 end
@@ -34,13 +34,12 @@ def with_message(message)
34 34 @expected_message = message if message
35 35 self
36 36 end
37   -
  37 +
38 38 def with(value)
39 39 raise "You may not call both with and not_with" if @value_to_fail
40 40 @value_to_pass = value
41 41 self
42 42 end
43   -
44 43
45 44 def not_with(value)
46 45 raise "You may not call both with and not_with" if @value_to_pass
@@ -48,7 +47,6 @@ def not_with(value)
48 47 self
49 48 end
50 49
51   -
52 50 def matches?(subject)
53 51 super(subject)
54 52 @expected_message ||= :blank
6 lib/shoulda/active_record/matchers/validate_uniqueness_of_matcher.rb
@@ -67,8 +67,8 @@ def description
67 67 def matches?(subject)
68 68 @subject = subject.class.new
69 69 @expected_message ||= :taken
70   - find_existing &&
71   - set_scoped_attributes &&
  70 + find_existing &&
  71 + set_scoped_attributes &&
72 72 validate_attribute &&
73 73 validate_after_scope_change
74 74 end
@@ -121,7 +121,7 @@ def validate_after_scope_change
121 121 @subject.send("#{scope}=", next_value)
122 122
123 123 if allows_value_of(existing_value, @expected_message)
124   - @negative_failure_message <<
  124 + @negative_failure_message <<
125 125 " (with different value of #{scope})"
126 126 true
127 127 else
1  lib/shoulda/active_record/matchers/validation_matcher.rb
@@ -18,7 +18,6 @@ def matches?(subject)
18 18 @subject = subject
19 19 false
20 20 end
21   -
22 21
23 22 private
24 23
4 lib/shoulda/assertions.rb
@@ -26,7 +26,7 @@ def assert_contains(collection, x, extra_msg = "")
26 26 case x
27 27 when Regexp
28 28 assert(collection.detect { |e| e =~ x }, msg)
29   - else
  29 + else
30 30 assert(collection.include?(x), msg)
31 31 end
32 32 end
@@ -39,7 +39,7 @@ def assert_does_not_contain(collection, x, extra_msg = "")
39 39 case x
40 40 when Regexp
41 41 assert(!collection.detect { |e| e =~ x }, msg)
42   - else
  42 + else
43 43 assert(!collection.include?(x), msg)
44 44 end
45 45 end
40 lib/shoulda/autoload_macros.rb
... ... @@ -1,40 +1,40 @@
1 1 module Shoulda # :nodoc:
2   - # Call autoload_macros when you want to load test macros automatically in a non-Rails
  2 + # Call autoload_macros when you want to load test macros automatically in a non-Rails
3 3 # project (it's done automatically for Rails projects).
4 4 # You don't need to specify ROOT/test/shoulda_macros explicitly. Your custom macros
5 5 # are loaded automatically when you call autoload_macros.
6 6 #
7 7 # The first argument is the path to you application's root directory.
8   - # All following arguments are directories relative to your root, which contain
9   - # shoulda_macros subdirectories. These directories support the same kinds of globs as the
  8 + # All following arguments are directories relative to your root, which contain
  9 + # shoulda_macros subdirectories. These directories support the same kinds of globs as the
10 10 # Dir class.
11   - #
  11 + #
12 12 # Basic usage (from a test_helper):
13 13 # Shoulda.autoload_macros(File.dirname(__FILE__) + '/..')
14   - # will load everything in
15   - # - your_app/test/shoulda_macros
  14 + # will load everything in
  15 + # - your_app/test/shoulda_macros
16 16 #
17   - # To load vendored macros as well:
  17 + # To load vendored macros as well:
18 18 # Shoulda.autoload_macros(APP_ROOT, 'vendor/*')
19   - # will load everything in
20   - # - APP_ROOT/vendor/*/shoulda_macros
21   - # - APP_ROOT/test/shoulda_macros
  19 + # will load everything in
  20 + # - APP_ROOT/vendor/*/shoulda_macros
  21 + # - APP_ROOT/test/shoulda_macros
22 22 #
23   - # To load macros in an app with a vendor directory laid out like Rails':
  23 + # To load macros in an app with a vendor directory laid out like Rails':
24 24 # Shoulda.autoload_macros(APP_ROOT, 'vendor/{plugins,gems}/*')
25 25 # or
26 26 # Shoulda.autoload_macros(APP_ROOT, 'vendor/plugins/*', 'vendor/gems/*')
27   - # will load everything in
28   - # - APP_ROOT/vendor/plugins/*/shoulda_macros
29   - # - APP_ROOT/vendor/gems/*/shoulda_macros
30   - # - APP_ROOT/test/shoulda_macros
  27 + # will load everything in
  28 + # - APP_ROOT/vendor/plugins/*/shoulda_macros
  29 + # - APP_ROOT/vendor/gems/*/shoulda_macros
  30 + # - APP_ROOT/test/shoulda_macros
31 31 #
32   - # If you prefer to stick testing dependencies away from your production dependencies:
  32 + # If you prefer to stick testing dependencies away from your production dependencies:
33 33 # Shoulda.autoload_macros(APP_ROOT, 'vendor/*', 'test/vendor/*')
34   - # will load everything in
35   - # - APP_ROOT/vendor/*/shoulda_macros
36   - # - APP_ROOT/test/vendor/*/shoulda_macros
37   - # - APP_ROOT/test/shoulda_macros
  34 + # will load everything in
  35 + # - APP_ROOT/vendor/*/shoulda_macros
  36 + # - APP_ROOT/test/vendor/*/shoulda_macros
  37 + # - APP_ROOT/test/shoulda_macros
38 38 def self.autoload_macros(root, *dirs)
39 39 dirs << File.join('test')
40 40 complete_dirs = dirs.map{|d| File.join(root, d, 'shoulda_macros')}
22 lib/shoulda/tasks/yaml_to_shoulda.rake
... ... @@ -1,28 +1,28 @@
1 1 namespace :shoulda do
2 2 # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
3 3 # David.Lowenfels@gmail.com
4   - desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
  4 + desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
5 5 task :from_yaml do
6 6 require 'yaml'
7   -
  7 +
8 8 def yaml_to_context(hash, indent = 0)
9 9 indent1 = ' ' * indent
10 10 indent2 = ' ' * (indent + 1)
11 11 hash.each_pair do |context, shoulds|
12   - puts indent1 + "context \"#{context}\" do"
13   - puts
  12 + puts indent1 + "context \"#{context}\" do"
  13 + puts
14 14 shoulds.each do |should|
15 15 yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash )
16   - puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
17   - puts indent2 + "end"
  16 + puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
  17 + puts indent2 + "end"
18 18 puts
19 19 end
20   - puts indent1 + "end"
  20 + puts indent1 + "end"
21 21 end
22   - end
23   -
  22 + end
  23 +
24 24 puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
25   -
  25 +
26 26 yaml_to_context( YAML.load_file( ENV['FILE'] ) )
27 27 end
28   -end
  28 +end
2  rails/init.rb
@@ -2,7 +2,7 @@
2 2 if defined? Spec
3 3 require 'shoulda/rspec'
4 4 else
5   - require 'shoulda/rails'
  5 + require 'shoulda/rails'
6 6 Shoulda.autoload_macros RAILS_ROOT, File.join("vendor", "{plugins,gems}", "*")
7 7 end
8 8 end
44 test/other/context_test.rb
... ... @@ -1,12 +1,12 @@
1 1 require 'test_helper'
2 2
3 3 class ContextTest < ActiveSupport::TestCase # :nodoc:
4   -
  4 +
5 5 def self.context_macro(&blk)
6 6 context "with a subcontext made by a macro" do
7 7 setup { @context_macro = :foo }
8 8
9   - merge_block &blk
  9 + merge_block &blk
10 10 end
11 11 end
12 12
@@ -21,11 +21,11 @@ def self.context_macro(&blk)
21 21 setup do
22 22 @blah = "blah"
23 23 end
24   -
  24 +
25 25 should "run the setup block" do
26 26 assert_equal "blah", @blah
27 27 end
28   -
  28 +
29 29 should "have name set right" do
30 30 assert_match(/^test: context with setup block/, self.to_s)
31 31 end
@@ -34,11 +34,11 @@ def self.context_macro(&blk)
34 34 setup do
35 35 @blah = "#{@blah} twice"
36 36 end
37   -
  37 +
38 38 should "be named correctly" do
39 39 assert_match(/^test: context with setup block and a subcontext should be named correctly/, self.to_s)
40 40 end
41   -
  41 +
42 42 should "run the setup blocks in order" do
43 43 assert_equal @blah, "blah twice"
44 44 end
@@ -64,7 +64,7 @@ def self.context_macro(&blk)
64 64 setup do
65 65 @blah = "foo"
66 66 end
67   -
  67 +
68 68 should "have @blah == 'foo'" do
69 69 assert_equal "foo", @blah
70 70 end
@@ -73,12 +73,12 @@ def self.context_macro(&blk)
73 73 assert_match(/^test: another context with setup block/, self.to_s)
74 74 end
75 75 end
76   -
  76 +
77 77 context "context with method definition" do
78 78 setup do
79 79 def hello; "hi"; end
80 80 end
81   -
  81 +
82 82 should "be able to read that method" do
83 83 assert_equal "hi", hello
84 84 end
@@ -87,52 +87,52 @@ def hello; "hi"; end
87 87 assert_match(/^test: context with method definition/, self.to_s)
88 88 end
89 89 end
90   -
  90 +
91 91 context "another context" do
92 92 should "not define @blah" do
93 93 assert_nil @blah
94 94 end
95 95 end
96   -
  96 +
97 97 context "context with multiple setups and/or teardowns" do
98   -
  98 +
99 99 cleanup_count = 0
100   -
  100 +
101 101 2.times do |i|
102 102 setup { cleanup_count += 1 }
103 103 teardown { cleanup_count -= 1 }
104 104 end
105   -
  105 +
106 106 2.times do |i|
107 107 should "call all setups and all teardowns (check ##{i + 1})" do
108 108 assert_equal 2, cleanup_count
109 109 end
110 110 end
111   -
  111 +
112 112 context "subcontexts" do
113   -
  113 +
114 114 2.times do |i|
115 115 setup { cleanup_count += 1 }
116 116 teardown { cleanup_count -= 1 }
117 117 end
118   -
  118 +
119 119 2.times do |i|
120 120 should "also call all setups and all teardowns in parent and subcontext (check ##{i + 1})" do
121 121 assert_equal 4, cleanup_count
122 122 end
123 123 end
124   -
  124 +
125 125 end
126   -
  126 +
127 127 end
128   -
  128 +
129 129 should_eventually "pass, since it's unimplemented" do
130 130 flunk "what?"
131 131 end
132 132
133 133 should_eventually "not require a block when using should_eventually"
134 134 should "pass without a block, as that causes it to piggyback to should_eventually"
135   -
  135 +
136 136 context "context for testing should piggybacking" do
137 137 should "call should_eventually as we are not passing a block"
138 138 end
@@ -164,7 +164,7 @@ class ::SomeModel; end
164 164 should "return the result of the block as the subject" do
165 165 assert_equal @expected, subject
166 166 end
167   -
  167 +
168 168 context "nested context block without a subject block" do
169 169 should "return the result of the parent context's subject block" do
170 170 assert_equal @expected, subject
2  test/other/convert_to_should_syntax_test.rb
@@ -41,7 +41,7 @@ def non_test_method
41 41
42 42 end
43 43 EOS
44   -
  44 +
45 45 FIXTURE_PATH = "./convert_to_should_syntax_fixture.dat"
46 46
47 47 RUBY = ENV['RUBY'] || 'ruby'
2  test/other/private_helpers_test.rb
@@ -22,7 +22,7 @@ class PrivateHelpersTest < ActiveSupport::TestCase # :nodoc:
22 22 get_options!(args, :one)
23 23 end
24 24 end
25   -
  25 +
26 26 should "return single wanted option" do
27 27 args = [:a, :b, {:class => Object}]
28 28 klass = get_options!(args,:class)
24 test/other/should_test.rb
@@ -4,11 +4,11 @@ class ShouldTest < ActiveSupport::TestCase # :nodoc:
4 4 should "be able to define a should statement outside of a context" do
5 5 assert true
6 6 end
7   -
  7 +
8 8 should "see the name of my class as ShouldTest" do
9 9 assert_equal "ShouldTest", self.class.name
10 10 end
11   -
  11 +
12 12 def self.should_see_class_methods
13 13 should "be able to see class methods" do
14 14 assert true
@@ -27,13 +27,13 @@ def self.should_see_a_context_block_like_a_Test_Unit_class
27 27
28 28 def self.should_see_blah
29 29 should "see @blah through a macro" do
30   - assert @blah
  30 + assert @blah
31 31 end
32 32 end
33 33
34 34 def self.should_not_see_blah
35 35 should "not see @blah through a macro" do
36   - assert_nil @blah
  36 + assert_nil @blah
37 37 end
38 38 end
39 39
@@ -75,12 +75,12 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
75 75 setup do
76 76 @blah = "blah"
77 77 end
78   -
  78 +
79 79 should "have @blah == 'blah'" do
80 80 assert_equal "blah", @blah
81 81 end
82 82 should_see_blah
83   -
  83 +
84 84 should "have name set right" do
85 85 assert_match(/^test: Context with setup block/, self.to_s)
86 86 end
@@ -89,11 +89,11 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
89 89 setup do
90 90 @blah = "#{@blah} twice"
91 91 end
92   -
  92 +
93 93 should "be named correctly" do
94 94 assert_match(/^test: Context with setup block and a subcontext should be named correctly/, self.to_s)
95 95 end
96   -
  96 +
97 97 should "run the setup methods in order" do
98 98 assert_equal @blah, "blah twice"
99 99 end
@@ -105,7 +105,7 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
105 105 setup do
106 106 @blah = "foo"
107 107 end
108   -
  108 +
109 109 should "have @blah == 'foo'" do
110 110 assert_equal "foo", @blah
111 111 end
@@ -115,7 +115,7 @@ def self.should_be_able_to_make_context_macros(prefix = nil)
115 115 end
116 116 should_see_blah
117 117 end
118   -
  118 +
119 119 should_eventually "pass, since it's a should_eventually" do
120 120 flunk "what?"
121 121 end
@@ -152,7 +152,7 @@ def test_should_have_should_hashes_when_given_should_statements
152 152 should "be good" do; end
153 153 should "another" do; end
154 154 end
155   -
  155 +
156 156 names = context.shoulds.map {|s| s[:name]}
157 157 assert_equal ["another", "be good"], names.sort
158 158 end
@@ -164,7 +164,7 @@ def test_should_capture_setup_and_teardown_blocks
164 164 setup do; "setup"; end
165 165 teardown do; "teardown"; end
166 166 end
167   -
  167 +
168 168 assert_equal "setup", context.setup_blocks.first.call
169 169 assert_equal "teardown", context.teardown_blocks.first.call
170 170 end
8 test/rails2_model_builder.rb
... ... @@ -1,11 +1,11 @@
1   -class ActiveSupport::TestCase
  1 +class ActiveSupport::TestCase
2 2
3 3 TMP_VIEW_PATH =
4 4 File.expand_path(File.join(File.dirname(__FILE__), 'rails2_root', 'tmp', 'views')).freeze
5 5
6 6 def create_table(table_name, &block)
7 7 connection = ActiveRecord::Base.connection
8   -
  8 +
9 9 begin
10 10 connection.execute("DROP TABLE IF EXISTS #{table_name}")
11 11 connection.create_table(table_name, &block)
@@ -77,7 +77,7 @@ def build_response(opts = {}, &block)
77 77 klass = define_controller('Examples')
78 78 block ||= lambda { render :nothing => true }
79 79 klass.class_eval { define_method(action, &block) }
80   - define_routes do |map|
  80 + define_routes do |map|
81 81 map.connect 'examples', :controller => 'examples', :action => action
82 82 end
83 83
@@ -100,7 +100,7 @@ def create_view(path, contents)
100 100
101 101 def teardown_with_models
102 102 if @defined_constants
103   - @defined_constants.each do |class_name|
  103 + @defined_constants.each do |class_name|
104 104 Object.send(:remove_const, class_name)
105 105 end
106 106 end
8 test/rails3_model_builder.rb
... ... @@ -1,11 +1,11 @@
1   -class ActiveSupport::TestCase
  1 +class ActiveSupport::TestCase
2 2
3 3 TMP_VIEW_PATH =
4 4 File.expand_path(File.join(File.dirname(__FILE__), 'rails3_root', 'tmp', 'views')).freeze
5 5
6 6 def create_table(table_name, &block)
7 7 connection = ActiveRecord::Base.connection
8   -
  8 +
9 9 begin
10 10 connection.execute("DROP TABLE IF EXISTS #{table_name}")
11 11 connection.create_table(table_name, &block)
@@ -69,7 +69,7 @@ def build_response(opts = {}, &block)
69 69 klass = define_controller('Examples')
70 70 block ||= lambda { render :nothing => true }
71 71 klass.class_eval { layout false; define_method(action, &block) }
72   - define_routes do |map|
  72 + define_routes do |map|
73 73 map.connect 'examples', :controller => 'examples', :action => action
74 74 end
75 75
@@ -94,7 +94,7 @@ def create_view(path, contents)
94 94
95 95 def teardown_with_models
96 96 if @defined_constants
97   - @defined_constants.each do |class_name|
  97 + @defined_constants.each do |class_name|
98 98 Object.send(:remove_const, class_name)
99 99 end
100 100 end
2  test/unit/flea_test.rb
@@ -4,7 +4,7 @@ class FleaTest < ActiveSupport::TestCase
4 4 should_have_and_belong_to_many :dogs
5 5
6 6 context "when a flea is created" do
7   - setup do
  7 + setup do
8 8 Flea.create
9 9 end
10 10

0 comments on commit e2ae4a2

Please sign in to comment.
Something went wrong with that request. Please try again.