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

Spec fails only on CI (details included) #2451

Closed
rileytg opened this Issue Jul 29, 2017 · 18 comments

Comments

Projects
None yet
4 participants
@rileytg

rileytg commented Jul 29, 2017

Generate rails routing spec fails only on CircleCi (details included). I can't tell why... Happy to do some more legwork to debug if someone points me in the right direction.

The spec:

require 'rails_helper'

RSpec.describe DocsController, type: :routing do
  describe 'routing' do

    it 'routes to #index' do
      expect(:get => '/docs').to route_to('docs#index')
    end

    it 'routes to #new' do
      expect(:get => '/docs/new').to route_to('docs#new')
    end

    it 'routes to #show' do
      expect(:get => '/docs/1').to route_to('docs#show', :id => '1')
    end

    it 'routes to #edit' do
      expect(:get => '/docs/1/edit').to route_to('docs#edit', :id => '1')
    end

    it 'routes to #create' do
      expect(:post => '/docs').to route_to('docs#create')
    end

    it 'routes to #update via PUT' do
      expect(:put => '/docs/1').to route_to('docs#update', :id => '1')
    end

    it 'routes to #update via PATCH' do
      expect(:patch => '/docs/1').to route_to('docs#update', :id => '1')
    end

    it 'routes to #destroy' do
      expect(:delete => '/docs/1').to route_to('docs#destroy', :id => '1')
    end

  end
end

Failure message

#!/bin/bash -eo pipefail
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                "${TEST_FILES}"
bundler: failed to load command: rspec (/home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec)
NoMethodError: undefined method `captures' for nil:NilClass
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:124:in `parse_id'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1953:in `extract_location'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1892:in `block in get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `each'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1890:in `get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:928:in `files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `load'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `<top (required)>'
The latest bundler is 1.15.3, but you are currently running 1.15.1.
To update, run `gem install bundler`
Exited with code 1

Gems

#!/bin/bash -eo pipefail
bundle install --jobs=4 --retry=3 --path vendor/bundle
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Fetching rake 12.0.0
Fetching concurrent-ruby 1.0.5
Fetching i18n 0.8.6
Installing erubi 1.6.1
Fetching mini_portile2 2.2.0
Fetching rack 2.0.3
Installing mini_portile2 2.2.0
Fetching nio4r 2.1.0
Installing nio4r 2.1.0 with native extensions
Fetching websocket-extensions 0.1.2
Installing rack 2.0.3
Installing websocket-extensions 0.1.2
Fetching mime-types-data 3.2016.0521
Installing mime-types-data 3.2016.0521
Fetching arel 8.0.0
Fetching method_source 0.8.2
Fetching thor 0.19.4
Installing method_source 0.8.2
Installing arel 8.0.0
Installing thor 0.19.4
Using bundler 1.15.1
Fetching pg 0.21.0
Fetching puma 3.9.1
Installing pg 0.21.0 with native extensions
Fetching sass 3.4.25
Installing puma 3.9.1 with native extensions
Installing sass 3.4.25
Fetching tilt 2.0.7
Fetching execjs 2.7.0
Fetching coffee-script-source 1.12.2
Installing execjs 2.7.0
Installing tilt 2.0.7
Installing coffee-script-source 1.12.2
Fetching turbolinks-source 5.0.3
Installing turbolinks-source 5.0.3
Fetching multi_json 1.12.1
Fetching byebug 9.0.6
Installing multi_json 1.12.1
Installing byebug 9.0.6 with native extensions
Fetching public_suffix 2.0.5
Fetching ffi 1.9.18
Installing public_suffix 2.0.5
Fetching rubyzip 1.2.1
Installing rubyzip 1.2.1
Installing ffi 1.9.18 with native extensions
Fetching rspec-support 3.5.0
Installing rspec-support 3.5.0
Fetching diff-lcs 1.3
Fetching dotenv 2.2.1
Fetching bindex 0.5.0
Installing dotenv 2.2.1
Installing bindex 0.5.0 with native extensions
Installing diff-lcs 1.3
Fetching rb-fsevent 0.10.2
Installing rb-fsevent 0.10.2
Fetching ruby_dep 1.5.0
Fetching temple 0.8.0
Fetching erubis 2.7.0
Installing ruby_dep 1.5.0
Installing temple 0.8.0
Fetching sexp_processor 4.10.0
Installing sexp_processor 4.10.0
Installing erubis 2.7.0
Fetching aws-sigv4 1.0.0
Installing aws-sigv4 1.0.0
Fetching jmespath 1.3.1
Installing jmespath 1.3.1
Fetching tzinfo 1.2.3
Fetching nokogiri 1.8.0
Installing tzinfo 1.2.3
Fetching websocket-driver 0.6.5
Installing websocket-driver 0.6.5 with native extensions
Installing nokogiri 1.8.0 with native extensions
Fetching mime-types 3.1
Fetching rack-test 0.6.3
Installing rack-test 0.6.3
Installing mime-types 3.1
Fetching sprockets 3.7.1
Fetching uglifier 3.2.0
Installing sprockets 3.7.1
Installing uglifier 3.2.0
Fetching turbolinks 5.0.1
Fetching coffee-script 2.4.1
Installing turbolinks 5.0.1
Fetching addressable 2.5.1
Installing coffee-script 2.4.1
Fetching rspec-core 3.5.4
Installing addressable 2.5.1
Installing rspec-core 3.5.4
Fetching childprocess 0.7.1
Installing childprocess 0.7.1
Fetching rb-inotify 0.9.10
Installing rb-inotify 0.9.10
Fetching rspec-expectations 3.5.0
Installing rspec-expectations 3.5.0
Fetching rspec-mocks 3.5.0
Installing rspec-mocks 3.5.0
Fetching ruby_parser 3.10.1
Installing ruby_parser 3.10.1
Fetching haml 5.0.1
Installing haml 5.0.1
Fetching aws-sdk-core 2.9.17
Installing aws-sdk-core 2.9.17
Fetching activesupport 5.1.2
Fetching mail 2.6.6
Fetching selenium-webdriver 3.4.3
Installing mail 2.6.6
Installing activesupport 5.1.2
Installing selenium-webdriver 3.4.3
Fetching rspec_junit_formatter 0.3.0
Installing rspec_junit_formatter 0.3.0
Fetching listen 3.1.5
Installing listen 3.1.5
Fetching aws-sdk-resources 2.9.17
Installing aws-sdk-resources 2.9.17
Fetching loofah 2.0.3
Installing loofah 2.0.3
Fetching xpath 2.1.0
Fetching html2haml 2.2.0
Installing xpath 2.1.0
Fetching rails-dom-testing 2.0.3
Installing html2haml 2.2.0
Installing rails-dom-testing 2.0.3
Fetching globalid 0.4.0
Fetching activemodel 5.1.2
Installing globalid 0.4.0
Fetching jbuilder 2.7.0
Installing activemodel 5.1.2
Fetching spring 2.0.2
Installing jbuilder 2.7.0
Installing spring 2.0.2
Fetching aws-sdk 2.9.17
Installing aws-sdk 2.9.17
Fetching rails-html-sanitizer 1.0.3
Installing rails-html-sanitizer 1.0.3
Fetching capybara 2.14.4
Fetching activejob 5.1.2
Fetching spring-watcher-listen 2.0.1
Installing spring-watcher-listen 2.0.1
Installing activejob 5.1.2
Fetching activerecord 5.1.2
Fetching actionview 5.1.2
Installing capybara 2.14.4
Installing activerecord 5.1.2
Installing actionview 5.1.2
Fetching actionpack 5.1.2
Installing actionpack 5.1.2
Fetching actioncable 5.1.2
Fetching actionmailer 5.1.2
Fetching railties 5.1.2
Installing actioncable 5.1.2
Installing actionmailer 5.1.2
Installing railties 5.1.2
Fetching sprockets-rails 3.2.0
Installing sprockets-rails 3.2.0
Fetching rails 5.1.2
Fetching sass-rails 5.0.6
Fetching coffee-rails 4.2.2
Installing rails 5.1.2
Installing coffee-rails 4.2.2
Installing sass-rails 5.0.6
Fetching rspec-rails 3.5.2
Fetching dotenv-rails 2.2.1
Fetching web-console 3.5.1
Installing dotenv-rails 2.2.1
Installing rspec-rails 3.5.2
Fetching haml-rails 1.0.0
Installing web-console 3.5.1
Installing haml-rails 1.0.0
Fetching jquery-rails 4.3.1
Installing jquery-rails 4.3.1
Bundle complete! 22 Gemfile dependencies, 91 gems now installed.
Bundled gems are installed into ./vendor/bundle.
The latest bundler is 1.15.3, but you are currently running 1.15.1.
To update, run `gem install bundler`

Local gems (passing all specs)

rileytg$ bundle | grep rspec
Using rspec-support 3.5.0
Using rspec-core 3.5.4
Using rspec-expectations 3.5.0
Using rspec-mocks 3.5.0
Using rspec_junit_formatter 0.3.0
Using rspec-rails 3.5.2
@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Jul 29, 2017

Member

It's failing while trying to parse the files/directories passed to rspec from the command line, so there's something messed up about what you're passing from the command line. Can you update your script to echo $TEST_FILES so we can see what value that has?

Member

myronmarston commented Jul 29, 2017

It's failing while trying to parse the files/directories passed to rspec from the command line, so there's something messed up about what you're passing from the command line. Can you update your script to echo $TEST_FILES so we can see what value that has?

@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Jul 29, 2017

it's empty...

when i remove the test it starts to pass again.

I removed all specs from the file spec/routing/docs_routing_spec.rb and still failing. I checked that name against: http://rubular.com/r/OMZSAPcAfn and it matches just fine.

updated failure with echo

#!/bin/bash -eo pipefail
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
echo $TEST_FILES

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                "${TEST_FILES}"
spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb
bundler: failed to load command: rspec (/home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec)
NoMethodError: undefined method `captures' for nil:NilClass
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:124:in `parse_id'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1953:in `extract_location'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1892:in `block in get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `each'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1890:in `get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:928:in `files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `load'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `<top (required)>'
The latest bundler is 1.15.3, but you are currently running 1.15.1.
To update, run `gem install bundler`
Exited with code 1

rileytg commented Jul 29, 2017

it's empty...

when i remove the test it starts to pass again.

I removed all specs from the file spec/routing/docs_routing_spec.rb and still failing. I checked that name against: http://rubular.com/r/OMZSAPcAfn and it matches just fine.

updated failure with echo

#!/bin/bash -eo pipefail
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
echo $TEST_FILES

bundle exec rspec --format progress \
                --format RspecJunitFormatter \
                --out /tmp/test-results/rspec.xml \
                --format progress \
                "${TEST_FILES}"
spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb
bundler: failed to load command: rspec (/home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec)
NoMethodError: undefined method `captures' for nil:NilClass
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:124:in `parse_id'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1953:in `extract_location'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1892:in `block in get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `each'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1890:in `get_files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:928:in `files_to_run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `load'
  /home/circleci/repo/vendor/bundle/ruby/2.4.0/bin/rspec:23:in `<top (required)>'
The latest bundler is 1.15.3, but you are currently running 1.15.1.
To update, run `gem install bundler`
Exited with code 1
@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Jul 29, 2017

Excuse me... it wasn't blank... it was spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb

rileytg commented Jul 29, 2017

Excuse me... it wasn't blank... it was spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb

@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Jul 29, 2017

 rileytg$  bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress "spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb"
bundler: failed to load command: rspec (/Users/rileytg/.rbenv/versions/2.4.0/bin/rspec)
LoadError: cannot load such file -- /Users/rileytg/code/edocs/spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /Users/rileytg/.rbenv/versions/2.4.0/bin/rspec:22:in `load'
  /Users/rileytg/.rbenv/versions/2.4.0/bin/rspec:22:in `<top (required)>'
 rileytg$ 

rileytg commented Jul 29, 2017

 rileytg$  bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress "spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb"
bundler: failed to load command: rspec (/Users/rileytg/.rbenv/versions/2.4.0/bin/rspec)
LoadError: cannot load such file -- /Users/rileytg/code/edocs/spec/requests/home_spec.rb spec/routing/docs_routing_spec.rb
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
  /Users/rileytg/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
  /Users/rileytg/.rbenv/versions/2.4.0/bin/rspec:22:in `load'
  /Users/rileytg/.rbenv/versions/2.4.0/bin/rspec:22:in `<top (required)>'
 rileytg$ 
@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Jul 29, 2017

different error locally...

rileytg commented Jul 29, 2017

different error locally...

@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Jul 29, 2017

Member

The local error makes sense; when you quote an argument, it gets treated as a single argument, even though there's a space in it. So rspec "spec/foo_spec.rb spec/bar_spec.rb" is interpreted as running rspec with a single argument (spec/foo_spec.rb spec/bar_spec.rb) which RSpec is treating as a filename and attempting to load.

The problem you're running into isn't a problem with RSpec; it's a problem with your bash script, and we don't generally provide bash support so I'm going to close this.

It would be good for RSpec to not crash in the way it did, but I can't repro locally. Please try RSpec 3.6 as I think it might already give you a better error in this case. If it still crashes with no clear error, please provide a way to repro this and we'll take a stab at improving the failure message in that case.

Member

myronmarston commented Jul 29, 2017

The local error makes sense; when you quote an argument, it gets treated as a single argument, even though there's a space in it. So rspec "spec/foo_spec.rb spec/bar_spec.rb" is interpreted as running rspec with a single argument (spec/foo_spec.rb spec/bar_spec.rb) which RSpec is treating as a filename and attempting to load.

The problem you're running into isn't a problem with RSpec; it's a problem with your bash script, and we don't generally provide bash support so I'm going to close this.

It would be good for RSpec to not crash in the way it did, but I can't repro locally. Please try RSpec 3.6 as I think it might already give you a better error in this case. If it still crashes with no clear error, please provide a way to repro this and we'll take a stab at improving the failure message in that case.

@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Jul 29, 2017

I get it... Ill report to CircleCI also (this is their script)

The help was much appreciated! Lemme know if theres a cleanup ticket (or some kinda project chore) you want me to take care of.

rileytg commented Jul 29, 2017

I get it... Ill report to CircleCI also (this is their script)

The help was much appreciated! Lemme know if theres a cleanup ticket (or some kinda project chore) you want me to take care of.

@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Jul 30, 2017

Member

Lemme know if theres a cleanup ticket (or some kinda project chore) you want me to take care of.

If you're able to come up with an isolated example that triggers the NoMethodError: undefined method 'captures' for nil:NilClass error, and you wanted to take a stab at fixing that code to not fail in that case, that would be wonderful :).

Member

myronmarston commented Jul 30, 2017

Lemme know if theres a cleanup ticket (or some kinda project chore) you want me to take care of.

If you're able to come up with an isolated example that triggers the NoMethodError: undefined method 'captures' for nil:NilClass error, and you wanted to take a stab at fixing that code to not fail in that case, that would be wonderful :).

@Charlie-Hua

This comment has been minimized.

Show comment
Hide comment
@Charlie-Hua

Charlie-Hua Aug 16, 2017

It could be isolated by serving files concatenated with newline \n

I added echo "$TEST_FILES" | cat -vte and in CircleCI result it prints:

spec/api/v2/client_spec.rb$
spec/api/v2/food_spec.rb$
spec/api/v2/job_spec.rb$

which means they are separated by newline.

then on my machine:

TEST_FILES=$'spec/api/v2/food_spec.rb\nspec/api/v2/client_spec.rb'
bundle exec rspec --format progress $TEST_FILES

I got NoMethodError: undefined method 'captures' for nil:NilClass
So I guess it has something to do with newline...

Charlie-Hua commented Aug 16, 2017

It could be isolated by serving files concatenated with newline \n

I added echo "$TEST_FILES" | cat -vte and in CircleCI result it prints:

spec/api/v2/client_spec.rb$
spec/api/v2/food_spec.rb$
spec/api/v2/job_spec.rb$

which means they are separated by newline.

then on my machine:

TEST_FILES=$'spec/api/v2/food_spec.rb\nspec/api/v2/client_spec.rb'
bundle exec rspec --format progress $TEST_FILES

I got NoMethodError: undefined method 'captures' for nil:NilClass
So I guess it has something to do with newline...

@rileytg

This comment has been minimized.

Show comment
Hide comment
@rileytg

rileytg Oct 18, 2017

wow good job, couldnt narrow it down

rileytg commented Oct 18, 2017

wow good job, couldnt narrow it down

@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

Didn't rspec deprecate and remove #captures IIRC?

jasonm23 commented Nov 4, 2017

Didn't rspec deprecate and remove #captures IIRC?

@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Nov 4, 2017

Member

Didn't rspec deprecate and remove #captures IIRC?

What captures method are you referring to? I'm not aware of any captures method RSpec ever provided as part of it's API.

Member

myronmarston commented Nov 4, 2017

Didn't rspec deprecate and remove #captures IIRC?

What captures method are you referring to? I'm not aware of any captures method RSpec ever provided as part of it's API.

@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Nov 4, 2017

Member

Didn't rspec deprecate and remove #captures IIRC?

(Also, what does that have to do with this issue?)

Member

myronmarston commented Nov 4, 2017

Didn't rspec deprecate and remove #captures IIRC?

(Also, what does that have to do with this issue?)

@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

I managed to solve this for my repo, although it's not good if you have spaces in your spec path names:

- run:
    name: run tests
    command: |
      mkdir -p /tmp/test-results
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | tr '\n' ' ' | circleci tests split --split-by=timings)"
      bundle exec rspec --format documentation \
                        --format RspecJunitFormatter \
                        --out /tmp/test-results/rspec.xml \
                        -- ${TEST_FILES}
  1. Replace the linefeeds with spaces. (tr '\n' ' ')
  2. The final ${TEST_FILES} argument of the rspec command needs -- to separate files from flags.
  3. Unquote ${TEST_FILES} so that the spaces are seen as filename delimiters by bash.

Personally I avoid spaces in source filenames so this solution is adequate for my use.

I did try this without replacing linefeeds and leaving ${TEST_FILES} quoted, but rspec seems to treat newlines as part of the filename. (which subsequently throws this captures method error, but I didn't trace into the rspec source at all to fix this, so I'm ignorant of the path that ultimately causes this error.)

jasonm23 commented Nov 4, 2017

I managed to solve this for my repo, although it's not good if you have spaces in your spec path names:

- run:
    name: run tests
    command: |
      mkdir -p /tmp/test-results
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | tr '\n' ' ' | circleci tests split --split-by=timings)"
      bundle exec rspec --format documentation \
                        --format RspecJunitFormatter \
                        --out /tmp/test-results/rspec.xml \
                        -- ${TEST_FILES}
  1. Replace the linefeeds with spaces. (tr '\n' ' ')
  2. The final ${TEST_FILES} argument of the rspec command needs -- to separate files from flags.
  3. Unquote ${TEST_FILES} so that the spaces are seen as filename delimiters by bash.

Personally I avoid spaces in source filenames so this solution is adequate for my use.

I did try this without replacing linefeeds and leaving ${TEST_FILES} quoted, but rspec seems to treat newlines as part of the filename. (which subsequently throws this captures method error, but I didn't trace into the rspec source at all to fix this, so I'm ignorant of the path that ultimately causes this error.)

@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

@myronmarston - sorry, I was parroting something I'd heard about a similar issue a year ago. Consider that comment about captures noise. On thinking for just a moment longer I think it's probably a failing regexp match.

(edit: captures)

jasonm23 commented Nov 4, 2017

@myronmarston - sorry, I was parroting something I'd heard about a similar issue a year ago. Consider that comment about captures noise. On thinking for just a moment longer I think it's probably a failing regexp match.

(edit: captures)

@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

BTW rspec-core 3.7.0 - error thrown when the filename contains newlines is:

bundler: failed to load command: rspec (/usr/local/opt/rbenv/versions/2.4.1/bin/rspec)
NoMethodError: undefined method `captures' for nil:NilClass
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/example.rb:124:in `parse_id'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:2028:in `extract_location'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1967:in `block in get_files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `each'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1965:in `get_files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:978:in `files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1494:in `load_spec_files'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:100:in `setup'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:86:in `run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:71:in `run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:45:in `invoke'
  /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/exe/rspec:4:in `<top (required)>'
  /usr/local/opt/rbenv/versions/2.4.1/bin/rspec:22:in `load'
  /usr/local/opt/rbenv/versions/2.4.1/bin/rspec:22:in `<top (required)>'

jasonm23 commented Nov 4, 2017

BTW rspec-core 3.7.0 - error thrown when the filename contains newlines is:

bundler: failed to load command: rspec (/usr/local/opt/rbenv/versions/2.4.1/bin/rspec)
NoMethodError: undefined method `captures' for nil:NilClass
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/example.rb:124:in `parse_id'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:2028:in `extract_location'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1967:in `block in get_files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `each'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/flat_map.rb:7:in `flat_map'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1965:in `get_files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:978:in `files_to_run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1494:in `load_spec_files'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:100:in `setup'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:86:in `run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:71:in `run'
  /usr/local/Cellar/rbenv/1.1.0/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:45:in `invoke'
  /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/exe/rspec:4:in `<top (required)>'
  /usr/local/opt/rbenv/versions/2.4.1/bin/rspec:22:in `load'
  /usr/local/opt/rbenv/versions/2.4.1/bin/rspec:22:in `<top (required)>'
@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

I made a sed based fix for filenames with spaces.

- run:
    name: run tests
    command: |
      mkdir -p /tmp/test-results
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
      bundle exec rspec --format documentation \
                        --format RspecJunitFormatter \
                        --out /tmp/test-results/rspec.xml \
                        -- $(echo "${TEST_FILES}" | sed -e 's/\n/\\n/' -e 's/ /\ /')

jasonm23 commented Nov 4, 2017

I made a sed based fix for filenames with spaces.

- run:
    name: run tests
    command: |
      mkdir -p /tmp/test-results
      TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
      bundle exec rspec --format documentation \
                        --format RspecJunitFormatter \
                        --out /tmp/test-results/rspec.xml \
                        -- $(echo "${TEST_FILES}" | sed -e 's/\n/\\n/' -e 's/ /\ /')
@jasonm23

This comment has been minimized.

Show comment
Hide comment
@jasonm23

jasonm23 Nov 4, 2017

$(sed -e 's/\n/\\n/' -e 's/ /\ /' <<< "${TEST_FILES}") is a slightly nicer sed syntax if you find the echo pipe ugly!

jasonm23 commented Nov 4, 2017

$(sed -e 's/\n/\\n/' -e 's/ /\ /' <<< "${TEST_FILES}") is a slightly nicer sed syntax if you find the echo pipe ugly!

tazoo added a commit to tazoo/tora that referenced this issue Dec 23, 2017

@jkodu jkodu referenced this issue Jul 9, 2018

Closed

chore: Add .github templates #41

0 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment