Commit Graph

83 Commits

Author SHA1 Message Date
yuuji.yaginuma
fb173b6613 Do not show suggestion message when not exist suggestion
**before**

```
$ ./bin/rails g g
Could not find generator 'g'. Maybe you meant nil?
Run `rails generate --help` for more options.
```

**after**

```
$ ./bin/rails g g
Could not find generator 'g'.
Run `rails generate --help` for more options.
```
2018-12-29 18:57:55 +09:00
yuuji.yaginuma
f7fd680a6d Remove unnecessary test
Since #32289, `Spellchecker.suggest` returns only one value, multiple
suggestions not output.
2018-06-03 20:53:05 +09:00
Genadi Samokovarov
cb25f2c989 Use did_you_mean spell checker for option suggestions
Now that we require Ruby over `2.3`, we can replace the current
suggestion methods we have with tooling from the `did_you_mean` gem.

There is a small user visible change and this is that we now offer a
single suggestion for misspelled options. We are suggesting fixes during
generator invocation and during a mistyped rails server rack handler. In
both cases, if we don't make a proper prediction on the first match, we
won't do so in the second or third one, so in my mind, this is okay.
2018-03-23 11:36:03 +02:00
Daniel Colson
82c39e1a0b Use assert_empty and assert_not_empty 2018-01-25 23:32:59 -05:00
Daniel Colson
94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
willnet
424debb096 Fix generator suggestion raise error when I18n.available_locales don’t include :en 2017-11-22 09:27:59 +09:00
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Lisa Ugray
75ccdfed8d Stop creating ApplicationRecord on model generation
When generating models, we created ApplicationRecord in the default
location if no file existed there.  That was annoying for people who
moved it to somewhere else in the autoload path.  At this point, the
vast majority of apps should have either run the upgrade script or
generated a model since upgrading.  For those that haven't the error
message after generating a new model should be helpful:

   NameError: uninitialized constant ApplicationRecord

To ease friction in that case, this also adds a generator for
ApplicationRecord.
2017-07-24 21:22:48 -04: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
bogdanvlviv
6673cf7071
Use require_relative instead of require with full path 2017-06-14 12:10:17 +03:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
yuuji.yaginuma
841dddaf26 Use appropriate type in generators test
This fixes the following thor's warning.

```
Expected string default value for '--generate'; got false (boolean)
```
2017-03-08 12:28:30 +09:00
Michael Grosser
a9aed2ac94
improve error message when include assertions fail
assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message

assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
2016-09-16 12:03:37 -07:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03: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
Ronak Jangir
63a70ad6ff Cleaned up generators tests using internal assertion helper 2015-08-20 09:22:56 +05:30
Ronak Jangir
722a367d4e Remove use of mocha in the railties generators tests 2015-05-22 00:12:58 +05:30
Rafael Mendonça França
b67197ee30 Fix generator tests
In my machine the output is different
2015-05-03 21:26:28 -03:00
Arthur Neves
74f5491ff3
Revert "Fix multiple suggestion test"
This reverts commit 6a7cf515123889360d272e8ab4be045578dfc0fb.
2015-04-25 19:56:33 -04:00
Arthur Neves
6a7cf51512
Fix multiple suggestion test 2015-04-25 19:15:34 -04:00
Josef Šimánek
b3a16b61fa
Add test for multiple suggested generator names. 2015-04-25 19:14:53 -04:00
Akira Matsuda
655c2c8b50 Fix Railties tests that were order dependent 2014-08-13 21:25:11 +09:00
Rafael Mendonça França
fd6aaaa0c3 Stop requiring mocha automatically
We are planning to remove mocha from our test suite because of
performance problems. To make this possible we should stop require mocha
on ActionSupport::TestCase.

This should not affect applications since users still need to add mocha
to Gemfile and this already load mocha.

Added FIXME notes to place that still need mocha removal
2014-07-19 17:35:12 -03:00
schneems
72f45ba292 Emit suggested generator names when not found
When someone types in a generator command it currently outputs all generators. Instead we can attempt to find a subtle mis-spelling by running all generator names through a levenshtein_distance algorithm provided by rubygems. 

So now a failure looks like this:

```ruby
$ rails generate migratioooons
Could not find generator 'migratioooons'. Maybe you meant 'migration' or 'integration_test' or 'generator'
Run `rails generate --help` for more options.
```

If the suggestions are bad we leave the user with the hint to run `rails generate --help` to see all commands.
2014-06-04 16:28:43 -05:00
schneems
e83ce84ef9 print generators on failed generate
Let's say we just ran:

```
$ rails g migrate add_click_to_issue_assignment
```

We will get an error that looks like:

```
Could not find generator migrate.
```

This patch adds all existing migrations to the output to make it easier for a developer to find a valid migration.

```
Could not find generator "migrate". Please select a valid generator:
Rails:
  assets
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  resource
  scaffold
  scaffold_controller
  task
```


It would be nice to do some spelling detection and suggest alternatives, but for now this should  help.
2014-05-26 10:11:07 -05:00
Arun Agrawal
c10a78124c More Warnings removed for ruby trunk
Same as 4d4ff531b8807ee88a3fc46875c7e76f613956fb
2013-11-01 13:47:23 +01:00
Guillermo Iguaran
71f512646a Revert "Isolate railties Generators Tests"
This fixes railties tests in JRuby but break it in MRI
This reverts commit fea99276c7024f183bf72a16ad9f36af4bae1d42.
2013-08-02 21:48:34 -05:00
Alex Tambellini
fea99276c7 Isolate railties Generators Tests
With this change jruby should pass all of the railties tests.
2013-08-02 22:26:58 -04:00
schneems
ec8d8652f3 s/plugin_new/plugin
There are historical reasons that the `plugin` command was `plugin_new`, now those are no longer applicable, we should remove the naming edge case from the project. This PR is based off of comments from #11176

ATP Railties
2013-06-30 22:03:39 -04:00
Vipul A M
c0be6c9811 cleanup railties test; fix typos 2013-03-31 20:50:21 +05:30
Robin Dupret
5ad7f8ab41 Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00
kennyj
414008f98e Fix class_eval without __FILE__ and __LINE__. 2012-07-18 01:16:55 +09:00
Aaron Patterson
b7a4fe18f2 remove duplicate requires of mocha.
Mocha is already required by AS::TestCase, so remove the duplicate
requires.
2012-07-03 14:28:29 -07:00
Arun Agrawal
397e47d807 Unused variable warning removed. 2012-05-30 14:46:17 +05:30
Arun Agrawal
05f88024de More assert_match warnings fixed. 2012-05-30 14:46:08 +05:30
José Valim
6db930cb5b Remove --http. 2012-03-14 22:30:01 +01:00
Carlos Antonio da Silva
570cc89bad Generate special controller and functional test templates for http apps
The main goal is to not generate the format.html block in scaffold
controller, and to generate a different functional test as we don't rely
on redirects anymore, we should test for http responses.

In addition to that, the :edit action is removed from the http
controller and the edit route is not generated by default, as they
usually do not make sense in this scenario.

[Carlos Antonio da Silva & Santiago Pastorino]
2012-03-14 12:46:25 -03:00
Carlos Antonio da Silva
219ff43639 Disable template, helper and assets options when using http_only!
[Carlos Antonio da Silva & Santiago Pastorino]
2012-03-14 12:46:24 -03:00
Carlos Antonio da Silva
c825e9a5ea Create generators http_only! setup and hide some common namespaces for now
[Carlos Antonio da Silva & Santiago Pastorino]
2012-03-14 12:46:24 -03:00
Carlos Antonio da Silva
c6ef45d6c4 Add convenience method to hide a generator from the available ones
It is usually useful to be able to hide a generator when running rails
generate command. Such generators might be used only to dry up
generators code and shouldn't be available to end users.
2012-02-03 10:18:58 -02:00
Colin MacKenzie IV
5745a5e85e treat USAGE as an ERB template 2011-11-02 09:00:18 -04:00
Alexey Gaziev
91bbb8e956 Removed tests for rescue branch for Rails 2.x compatibility 2011-06-20 22:29:30 +04:00
Guillermo Iguaran
ce4afa25b4 load_generators_from_railties was removed, remove failing test_load_generators_from_railties 2011-05-24 22:03:10 -05:00
Akira Matsuda
cce461511b be sure to parenthesize the arguments when the first one is a RegExp literal
this fixes: "warning: ambiguous first argument; put parentheses or even spaces"
because: you need this to tell the parser that you're not calling :/ method (division)
details (Japanese!): http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/42445?42370-43277
2011-05-18 23:20:19 +09:00
Santiago Pastorino
20897a6c2c Allow generators nested in more than one level 2011-01-12 21:42:56 -02:00
Prem Sichanugrist
fd1daf9a8e Make sure that generator's default banner is showing its namespace
This will make `rails g rspec:install --help` shows "rails generate rspec:install [options]" and not "rails generate install  [options]"
2011-01-01 11:58:09 -08:00
José Valim
7b2f2c8b47 Tidy up generators commits. 2010-11-17 23:32:19 +01:00
Xavier Noria
92669b8320 application generation: --skip-testunit and --skip-activerecord renamed to --skip-test-unit and --skip-active-record respectively
Reason is their proper spellings are "Test::Unit" and "Active Record".
Option names and descriptions have been revised, as well as some method
names and minor details here and there.
2010-07-25 22:55:38 +02:00
José Valim
6f0ed7aa52 Update generators test. 2010-05-15 15:21:14 +02:00