Commit Graph

33 Commits

Author SHA1 Message Date
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
yuuji.yaginuma
daa592293b Use TOPLEVEL_BINDING in rails runner command
Binding to capture the local scope. This means that if a constant with same
name as constant specified by the user exists in local scope, constant
defined in local will use. This is different from what the user expects.
Therefore, fixed to use top-level binding instead of local scope.

Fixes #30644
2017-09-22 10:42:28 +09:00
Matthew Draper
802ce8a239 Run in-app rails commands via fork+load where possible
While this avoids shell argument parsing, we still pass through
everything in our stack.
2017-09-04 20:19:39 +09:30
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Cody Cutrer
ed44b145bd support - as an argument to rails runner
in Rails 4.0, you could use `/dev/stdin` on both Linux and Mac, but with
the switch to Kernel.load in Rails 4.1, this broke on Linux (you get
a LoadError). Instead, explicitly detect `-` as meaning stdin, then
read from stdin explicitly, instead of performing file gymnastics. This
should now work on any platform uniformly.

Passing a script via stdin is useful when you're sshing to a server,
and the script you want to run is stored locally. You could theoretically
pass the entire script on the command line, but in reality you'll run
into problems with the command being too long.
2017-07-17 13:46:44 -06:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Robert Thau
9bc6178e00 Fixup trailing whitespace, per complaints from CodeClimate. 2017-03-22 12:36:27 -04:00
Robert Thau
a06a643e05 Correctly reset ARGV for "rails runner `CODE' arg arg arg..."
The code itself should not be in the ARGV vector.

Fixes #28515
2017-03-22 12:04:19 -04:00
Kasper Timm Hansen
5aea0952e7 Pass rails runner args onto file again.
When making the new command insfrastructure I had missed that
`bin/rails runner some_file.rb some args` would pass the extra
args onto the file in `ARGV`.

Now fixed by allowing the command to take extra args again, and
make sure to remove the file name from `ARGV`.
2016-11-20 16:02:39 +01:00
Aaron Patterson
797f1dd63c
Prevent the test framework from being loaded in production mode
The test framework should not be autoloaded in production mode.  Before
this commit, the testing railtie would extend AS::TestCase.  This caused
AS::TestCase to be preloaded regardless of the environment in which we
were running.

This commit just moves the code that adds line filtering support in to
the test command where we actually execute the test runner.  That allows
us to maintain the line runner feature but only load the minimal amount
of code we need.
2016-10-21 13:10:26 -07:00
Kasper Timm Hansen
6813edc7d9 Initial command structure. 2016-09-25 21:31:35 +02:00
Xavier Noria
f90ee8ce27 applies project convention for string literals 2016-08-07 23:17:24 +02:00
Kasper Timm Hansen
33ec865e7b Merge pull request #24260 from y-yagi/show_error_message_when_error_raised_in_rails_runner
show error message when error raised in rails runner
2016-08-07 17:19:33 +02:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
yuuji.yaginuma
bf71b6a579 show error message when error raised in rails runner 2016-08-03 12:16:16 +09:00
Prathamesh Sonpatki
d93427840e
Remove unused boot_rails method and it's usage
- The `boot_rails` method from abstract_unit.rb is empty after 2abcdfd978fdcd491576a237e8c6b.
- So let's remove it and its usage.
2016-07-04 09:34:21 +05:30
Stephen Blackstone
02d2d3cf69 Provide a better error message if a user mistypes the name of script with runner
Add tests for detecting bad options for runner
2016-01-05 23:13:13 -05:00
Yves Senn
a8f250a22c tests, railties tests should use bin/ executables when possible.
We recommend using the `bin/` executables in our docs and guides.
Let's make sure that our tests execute the same code path.
2015-06-30 11:19:01 +02:00
Jeremy Kemper
5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
2015-03-20 08:14:11 -07:00
Damien Mathieu
d578cbfb5c don't fallback to RACK_ENV when RAILS_ENV is not present 2015-03-19 10:06:28 +01:00
Akira Matsuda
8b0e52556e script => bin 2013-01-18 17:12:47 +09:00
Carlos Antonio da Silva
5a8f25f003 Refactor tests that switch RAILS_ENV and RACK_ENV
This cleanup aims to fix a build failure:
https://travis-ci.org/rails/rails/jobs/3515951/#L482

Since travis always have both ENV vars set to "test", a test is failing
where it's expected to output the default env "development", but "test"
is the result due to RACK_ENV being set when we expect it to not be.

By cleaning this duplication we ensure that changing any of these env
variables will pick the right expected value.
2012-12-06 10:47:14 -02:00
Carlos Antonio da Silva
b6f0978108 Fix duplicated method name
[ci skip]
2012-12-05 15:27:19 -02:00
kennyj
a7695579a5 Add ENV['RACK_ENV'] support to rake runner/console/server. 2012-12-06 02:05:33 +09:00
kennyj
f8e7904dc0 Add support runner hook. 2012-05-29 23:46:08 +09:00
Aaron Patterson
8f309e3105 convert railties to use AS::TestCase 2012-01-05 17:30:17 -08:00
Vijay Dev
880371ef2b make 'rails runner' show usage when run without any options 2011-06-10 18:48:50 +05:30
Jon Leighton
62570e8626 Solve the RAILS_ENV problem in the railties tests in a more generic way 2011-06-06 13:54:05 +01:00
rohit
fd53bc85e7 Send 'rails runner' help message to stdout instead of stderr.
[#5661 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-19 16:45:29 -07:00
rohit
76266a8184 Fix output of 'rails runner --help' [#4249 state:open] 2010-09-18 20:49:33 +02:00
Jeremy Kemper
aeaa4687ea Fix indent 2010-07-02 11:32:18 -07:00
rohit
9be0b50962 Added 4 tests for Rails Runner. 2 failing tests for $0 and $PROGRAM_NAME [#2244 state:open]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-22 15:20:28 +02:00