Coder Social home page Coder Social logo

Comments (9)

maxim avatar maxim commented on August 27, 2024

Running rspec with specific path like rspec spec/controllers/my_spec.rb works as well, for the same exact file that should be filtered with "my string".

from spring-commands-rspec.

maxim avatar maxim commented on August 27, 2024

Looks like it's working if you pass spec directory explicitly like rspec -e "my string" spec/. Not sure why this has to be explicit, especially in rails.

from spring-commands-rspec.

maxim avatar maxim commented on August 27, 2024

This is probably the same issue: #7

from spring-commands-rspec.

cupakromer avatar cupakromer commented on August 27, 2024

This issue is caused because when run through spring, the $0 / $PROGRAM_NAME deviate from RSpec's expectations. Here is the output for this global when run via different methods:

  • Via bundler: ~/.rvm/gems/ruby-2.1.2@myapp/bin/rspec
  • Via bundler binstub: bin/rspec
  • Via rake: ~/.rvm/gems/ruby-2.1.2@myapp/gems/rspec-core-3.0.3/exe/rspec
  • Via spring: rspec

However, when you add args, say --require spec_helper this is what I get:

  • Via bundler: ~/.rvm/gems/ruby-2.1.2@myapp/bin/rspec
  • Via bundler binstub: bin/rspec
  • Via spring: rspec --require spec_helper

Note that rake treats CLI different, and does not directly allow passing the CLI args to RSpec. thus it has been removed from the above list.

RSpec checks $0 here to determine if it should add "spec" as a path here:

# lib/rspec/core/configuration.rb

      def files_or_directories_to_run=(*files)
        files = files.flatten
        files << default_path if (command == 'rspec' || Runner.running_in_drb?) && default_path && files.empty?
        @files_or_directories_to_run = files
        @files_to_run = nil
      end

      def command
        $0.split(File::SEPARATOR).last
      end

from spring-commands-rspec.

cupakromer avatar cupakromer commented on August 27, 2024

The simple workaround is to shim the file name into the binstub: $0 = __FILE__. Obviously this isn't a good long term or permanent solution. Per this commit in spring core this process title should most likely just be name. I'm not sure about the history why it is all of the args too, so I'm not comfortable making a fix there.

from spring-commands-rspec.

MarkMurphy avatar MarkMurphy commented on August 27, 2024

Same problem here.

from spring-commands-rspec.

jonleighton avatar jonleighton commented on August 27, 2024

Spring sets $0 here:

https://github.com/rails/spring/blob/master/lib/spring/application.rb#L161

It gets the value from here:

https://github.com/rails/spring/blob/master/lib/spring/command_wrapper.rb#L44-L46

So I think the implementation of that method is wrong, basically.

from spring-commands-rspec.

jstrater avatar jstrater commented on August 27, 2024

I just submitted a PR for Spring: rails/spring#369

from spring-commands-rspec.

jstrater avatar jstrater commented on August 27, 2024

Jon merged the PR, so this should be in the next Spring release.

rails/spring#369

from spring-commands-rspec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.