-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Rails 6.1 development.rb undefined method `year' for 1:Integer #37391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Milestone
Comments
@schneems Thanks for the sample app and the reproduction steps, it was fun to troubleshoot this error 🤗 |
@schneems I opened a PR but seems like the solution wasn't good enough. Would you like to give me some directions on how should this be solved? I'd like to be able to use |
alexcameron89
pushed a commit
to alexcameron89/awesome-controller
that referenced
this issue
Apr 20, 2020
Related errors below. == Test WrongScopeError Error: ``` Failures: 1) Posts API (Custom Controller) GET /posts returns a list of posts Failure/Error: raise WrongScopeError, "`#{name}` is not available from within an example (e.g. an " \ "`it` block) or from constructs that run in the scope of an " \ "example (e.g. `before`, `let`, etc). It is only available " \ "on an example group (e.g. a `describe` or `context` block)." `name` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block). # /Users/alexkitchens/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:742:in `method_missing' # /Users/alexkitchens/fun/journey/dependencies/rails/actionpack/lib/action_dispatch/testing/assertions/routing.rb:188:in `method_missing' # /Users/alexkitchens/fun/journey/dependencies/rails/actionpack/lib/action_dispatch/testing/integration.rb:422:in `method_missing' # /Users/alexkitchens/fun/journey/dependencies/rails/activerecord/lib/active_record/test_fixtures.rb:101:in `run_in_transaction?' # /Users/alexkitchens/fun/journey/dependencies/rails/activerecord/lib/active_record/test_fixtures.rb:115:in `setup_fixtures' # /Users/alexkitchens/fun/journey/dependencies/rails/activerecord/lib/active_record/test_fixtures.rb:8:in `before_setup' # /Users/alexkitchens/fun/journey/dependencies/rails/actionpack/lib/action_dispatch/testing/integration.rb:331:in `before_setup' # /Users/alexkitchens/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-rails-3.8.2/lib/rspec/rails/adapters.rb:126:in `block (2 levels) in <module:MinitestLifecycleAdapter>' # /Users/alexkitchens/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec' # /Users/alexkitchens/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec' # /Users/alexkitchens/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:373:in `execute_with' # # Showing full backtrace because every line was filtered out. # See docs for RSpec::Configuration#backtrace_exclusion_patterns and # RSpec::Configuration#backtrace_inclusion_patterns for more information. ``` Bisect led to d4367eb72601f6e5bba3206443e9d141e9753af8 Issue opened here: rails/rails#37783 Fix in Rspec Rails here: rspec/rspec-rails#2215 The fix is not in a full release yet, so I've pinned to the latest beta release. ``` commit d4367eb72601f6e5bba3206443e9d141e9753af8 Author: Edouard CHIN <[email protected]> Date: Thu Nov 21 18:39:54 2019 +0100 Modify ActiveRecord::TestFixtures to not rely on AS::TestCase: - ### Problem If one wants to use ActiveRecord::TestFixtures it is mandatory for the test suite to inherit from `ActiveSupport::TestCase`. TestFixtures makes use of specific method from AS::TestCase (`file_fixture_path` and `method_name`). ### Solution This PR fixes that by not making use of method_name and file_fixture_path. ``` == Time Issue Error: ``` Failure/Error: require File.expand_path('../../config/environment', __FILE__) NoMethodError: undefined method `hour' for 1:Integer Run options: include {:locations=>{"./spec/requests/api/posts_spec.rb"=>[10]}} ``` Bisect led to commit 12959dee0f19a8e050dd1236b031c2c690729905 Issue open at rails/rails#37391
4 tasks
guillec
added a commit
to network-for-good/nfg_ui
that referenced
this issue
Sep 8, 2022
There seems to be a bug in the Rails 6.0 version that doesn't load active_support/time in time for configuration files. See rails/rails#37391 This commit requires 'active_support/time' in the test.rb file in order to handle the 1.hour method call. We should be able to remove this require statement in the future.
louis-antonopoulos
added a commit
to thoughtbot/yuri-ita
that referenced
this issue
Aug 21, 2024
rails/rails#37391 ``` Failure/Error: 'Cache-Control' => "public, max-age=#{1.hour}" NoMethodError: undefined method `hour' for 1:Integer 'Cache-Control' => "public, max-age=#{1.hour}" ^^^^^ # ./spec/example_app/config/environments/test.rb:19:in `block in <main>' ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
There is a
1.year
in thedevelopment.rb
file, for some reason the activesupport core extensions aren't yet applied when this file (and other config files) are attempted to be loaded. You can see the commit that introduces the bug here schneems/rails_61_boot_bug@a3d207cThe only other modification I made was
Expected behavior
The app to boot into a console
Actual behavior
An error occurs:
System configuration
Rails version: Master (SHA 921b55d)
Ruby version: 2.6.5
The text was updated successfully, but these errors were encountered: