Skip to content

Commit

Permalink
Fix Rspec issue and time issue
Browse files Browse the repository at this point in the history
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 <edouard.chin@shopify.com>
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
  • Loading branch information
alexcameron89 committed Mar 4, 2020
1 parent bccc22e commit cde8b4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -17,6 +17,6 @@ gem 'webpacker'
gem 'turbolinks'

group :development, :test do
gem 'rspec-rails'
gem 'rspec-rails', '>= 4.0.0.beta4'
gem 'factory_bot_rails'
end
40 changes: 20 additions & 20 deletions Gemfile.lock
Expand Up @@ -120,12 +120,12 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.1)
mimemagic (0.3.4)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
nio4r (2.3.1)
nokogiri (1.10.3)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
pg (1.1.4)
pry (0.12.2)
Expand All @@ -144,23 +144,23 @@ GEM
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rake (12.3.2)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.3)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec-support (~> 3.9.0)
rspec-rails (4.0.0.beta4)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.2)
sass-rails (6.0.0.beta3)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.0.1)
Expand Down Expand Up @@ -194,7 +194,7 @@ GEM
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
zeitwerk (2.2.2)
zeitwerk (2.3.0)

PLATFORMS
ruby
Expand All @@ -206,7 +206,7 @@ DEPENDENCIES
puma!
rack!
rails!
rspec-rails
rspec-rails (>= 4.0.0.beta4)
sass-rails
turbolinks
webpacker
Expand Down
1 change: 1 addition & 0 deletions config/environment.rb
@@ -1,3 +1,4 @@
require "active_support/time"
# Load the Rails application.
require_relative 'application'

Expand Down

0 comments on commit cde8b4b

Please sign in to comment.