简体   繁体   中英

Running tagged RSpec tests within Rubymine

I am able to run tagged RSpec tests from the command line by tagging the test as follows:

context "sample test description", :mytag do

     (do some stuff)

end

I execute the command line as follows and this works fine: bundle exec rspec -fd -t mytag

The problem is that I am trying to run from within Rubymine 2017.2.3 and utilize the above tag "mytag".

I've Googled quite a bit but have found no solutions.

The closest I think I have come, is by navigating to Run -> Edit Configurations and trying to specify the tag option in the Runner options field, but haven't gotten it to work. I've tried several variations.

I also just put --h in Runner options and ran and it does bring up the help. But --t / --tags does not seem to be recognized the same as it is in the command line.

Can anyone tell me if they have gotten this to work?

Thanks

Well, I figured it out myself. It appears that you have to use -t, not --tags. Secondly, I was starting the test by right-clicking on a shared example within my rspec. What this seems to do is add its own tagging by performing the right click. However, if I right-click on the file tab at top and then Select 'Run spec 'spec_name' from the menu, then the tagging set in Edit Configurations will work.

The run console will show what tags it ran with. Example below:

Run options: include {:focus=>true, :mytag=>true}

So, in short, add -t {tagname} to Run options field and run the entire RSPEC file.

I think that's because, by default, RubyMine uses a "rails" task, not an rspec task and the parameters are not passed along. When I created an rspec task, I succeeded in passing the parameters I needed to the runner.

Hope this helps! 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM