aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock2
-rw-r--r--guides/source/testing.md7
-rw-r--r--railties/CHANGELOG.md4
-rw-r--r--railties/lib/rails/test_unit/reporter.rb6
-rw-r--r--railties/test/test_unit/reporter_test.rb14
-rw-r--r--tools/test.rb2
6 files changed, 33 insertions, 2 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index 3cc20f1c9c..c6d7ad0926 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -308,4 +308,4 @@ DEPENDENCIES
w3c_validators
BUNDLED WITH
- 1.10.2
+ 1.10.3
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 230e8162f3..2fd54a48fc 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -141,6 +141,13 @@ users(:david).id
email(david.partner.email, david.location_tonight)
```
+To get multiple fixtures at once, you can pass in a list of fixture names. For example:
+
+```ruby
+# this will return an array containing the fixtures david and steve
+users(:david, :steve)
+```
+
### Console Tasks for Running your Tests
Rails comes with a CLI command to run tests.
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 3536929d00..ca07ff349c 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Make it possible to customize the executable inside rerun snippets.
+
+ *Yves Senn*
+
* Add support for API only apps.
Middleware stack was slimmed down and it has only the needed
middleware for API apps & generators generates the right files,
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb
index bfdc9754d4..faf551f381 100644
--- a/railties/lib/rails/test_unit/reporter.rb
+++ b/railties/lib/rails/test_unit/reporter.rb
@@ -1,7 +1,11 @@
+require "active_support/core_ext/class/attribute"
require "minitest"
module Rails
class TestUnitReporter < Minitest::StatisticsReporter
+ class_attribute :executable
+ self.executable = "bin/rails test"
+
def report
return if results.empty?
io.puts
@@ -15,7 +19,7 @@ module Rails
filtered_results.reject!(&:skipped?) unless options[:verbose]
filtered_results.map do |result|
location, line = result.method(result.name).source_location
- "bin/rails test #{relative_path_for(location)}:#{line}"
+ "#{self.executable} #{relative_path_for(location)}:#{line}"
end.join "\n"
end
diff --git a/railties/test/test_unit/reporter_test.rb b/railties/test/test_unit/reporter_test.rb
index 77883612f5..d619a3e515 100644
--- a/railties/test/test_unit/reporter_test.rb
+++ b/railties/test/test_unit/reporter_test.rb
@@ -43,6 +43,20 @@ class TestUnitReporterTest < ActiveSupport::TestCase
assert_rerun_snippet_count 1
end
+ test "allows to customize the executable in the rerun snippet" do
+ original_executable = Rails::TestUnitReporter.executable
+ begin
+ Rails::TestUnitReporter.executable = "bin/test"
+ verbose = Rails::TestUnitReporter.new @output, verbose: true
+ @reporter.record(failed_test)
+ @reporter.report
+
+ assert_match %r{^bin/test .*test/test_unit/reporter_test.rb:6$}, @output.string
+ ensure
+ Rails::TestUnitReporter.executable = original_executable
+ end
+ end
+
private
def assert_rerun_snippet_count(snippet_count)
assert_equal snippet_count, @output.string.scan(%r{^bin/rails test }).size
diff --git a/tools/test.rb b/tools/test.rb
index 50cce2081a..70f295b554 100644
--- a/tools/test.rb
+++ b/tools/test.rb
@@ -8,3 +8,5 @@ module Rails
@root ||= Pathname.new(COMPONENT_ROOT)
end
end
+
+Rails::TestUnitReporter.executable = "bin/test"