El jueves, 23 de marzo de 2017 2:41:56 (CET) CCH escribió:
> Hi Sergio
>
> 1. rails g active_scaffold:resource Pms4w10 date:date request_by module
> feature rootcause priority suggestion:text action:text completed:boolean
> date_completed:date released_version priority_id:integer
> rootcause_id:integer
>
> 2. rails db:migrate
>
> 3. run test on pms4w10s_controller_test.rb
>
> *RESULT*
>
> C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe -e
> $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest
> C:/PRJ4RAILS/rnd/test/controllers/pms4w10s_controller_test.rb
> Testing started at 9:35 AM ...
> Started
>
> *Minitest::UnexpectedError: NoMethodError: undefined method `each' for
> nil:NilClass*
> test/controllers/pms4w10s_controller_test.rb:37:in `block in
> <class:Pms4w10sControllerTest>'
> test/controllers/pms4w10s_controller_test.rb:37:in `block in
> <class:Pms4w10sControllerTest>'
>
> Minitest::UnexpectedError: NoMethodError: undefined method `each' for
> nil:NilClass
> test/controllers/pms4w10s_controller_test.rb:20:in `block (2 levels) in
> <class:Pms4w10sControllerTest>'
> test/controllers/pms4w10s_controller_test.rb:19:in `block in
> <class:Pms4w10sControllerTest>'
> test/controllers/pms4w10s_controller_test.rb:20:in `block (2 levels) in
> <class:Pms4w10sControllerTest>'
> test/controllers/pms4w10s_controller_test.rb:19:in `block in
> <class:Pms4w10sControllerTest>'
> Finished in 24.24463s
> 7 tests, 6 assertions, 0 failures, 2 errors, 0 skips
>
> Process finished with exit code 0
>
> test "should update pms4w10" do
> line 37 patch pms4w10_url(@pms4w10), params: { pms4w10: { action:
> @pms4w10.action, completed: @pms4w10.completed, date: @pms4w10.date,
> date_completed: @pms4w10.date_completed, feature: @pms4w10.feature, module:
> @pms4w10.module, priority: @pms4w10.priority, priority_id:
> @pms4w10.priority_id, released_version: @pms4w10.released_version,
> request_by: @pms4w10.request_by, rootcause: @pms4w10.rootcause,
> rootcause_id: @pms4w10.rootcause_id, suggestion: @pms4w10.suggestion } }
> assert_redirected_to pms4w10_url(@pms4w10)
> end
>
>
>
> What can I do to pass the test ?
Replace "params: { pms4w10:" with "params: { record:"
Rails generators creates controllers and tests using model name in params, but
ActiveScaffold uses always record. ActiveScaffold generator inherit from rails
generator
and create controller with own template, but hooks on test_framework generator,
which
creates controller test, so test doesn't pass without some changes because
activescaffold
controllers use different params attributes and instance variables than default
rails
controllers.
To generate controller tests which passes with ActiveScaffold, ActiveScaffold
should
provide template for each test framework, or most used ones at least, such as
test_unit,
minitest and rspec, which may be too much work.
I checked if it would be possible to inherit from existing generators, changing
some
methods which are used for variable and params key, so template is reused.
However it
won't work because templates are using same methods for variables and routes.
An
example:
currently generates:
assert_redirected_to thing_path(assigns(:thing))
I chould change to:
assert_redirected_to record_path(assigns(:record))
But we need:
assert_redirected_to thing_path(assigns(:record))
So only way would be copying template to ActiveScaffold and making changes, if
rails,
minitest-rails or rspec-rails fix or change template, ActiveScaffold won't get
those changes.
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.