I am able to right-click on any of my 3 spec/models but when I right click the spec/models folder and select 'run all tests in models' I get 'Unable to attach test reporter to test framework'.
The first line of my model tests is: require 'spec_helper.rb'
I posted this answer for another question. It may help with this one as well:
On my system, the problem was the "redgreen" gem. It automatically colors the progress marks (dots) and the Test::Unit summary messages based on success or failure. There must be something in RubyMine that's trying to parse the Test::Unit results (the output of "rake test", I imagine), and it's choking on the ANSI sequences.
I commented out "require 'redgreen'" in my test/test_helper.rb, and the problem went away. I really like redgreen for executing "rake test" from the shell, though, so I put this in test_helper to make it work for both "rake test" and within RubyMine:
require 'redgreen' if $stdin.tty?
It may not be redgreen that's causing your problem, but be suspicious of anything which might create unconventional Test::Unit output.
Good luck!
I had the same issue and had to add the following to /etc/launcd.conf (I had to create this file as well):
setenv DYLD_LIBRARY_PATH /usr/local/mysql/lib/
and reboot. There are other ways to do it as well (a plist file, adding this environmental variable to RubyMine, etc… but this was most reliable. Of course, this assumes that you use MySQL.
The answer in the end for my setup was to fiddle around with the IDE settings including the ruby version, making sure it was 1.9.2 and the directories referenced in the config. screens were correct. This plus some restarts resolved the issue.
Related
I'm trying to create a test folder for my rails project using cucumber-rails generator (the gem is here: https://github.com/cucumber/cucumber-rails ).
The problem is that when I run "rails generate cucumber:install" it creates a folder in my project named "features" with the cucumber files inside that folder, which is - in my perspective - not very organized.
I would like all the cucumber files to be inside a folder named "test". Is there a way that allows me to do that? I tried to run the generator inside the "test" folder but it didn't seem to work.
Anyone knows how to do this? Thanks a lot!
There are essentially 3 test libraries in Ruby and corresponding common assumptions:
test is expected to contain Test::Unit or MiniTest tests
spec is expected to contain RSpec tests
features is expected to contain cucumber tests
You should follow these assumptions or you may end up having several troubles in the long run.
In any case, to answer your question, what you want to do is not possible. The features folder is hard-code in the generator and in the cucumber task file. Therefore, unless you want to introduce several hacks and workaround, you'll have to follow the conventions.
I think there is a pretty straight forward solution for this:
In an issue it is pointed out that we can point to different paths for our features in the cucumber.yml
default: features
// becomes
default: test/features
But, then it can't find the step_defintions if you also add your custom path as a required flag then it can pick up the step_defintions as well.
default: features
// becomes
default: test/features -r test/features/step_definitions
if you don't want to use cucumber.yml you can use the cucumber cli to take care of it:
bundle exec cucumber test/features -r test/features/step_definitions
NOTE: I am using this in a docker environment and this works fine for both local and docker implementations.
Is there any way to retest previously broken tests?
So, say, I run rspec and several tests in different files and directories fail.
I fix something and now I have to manually specify all files and folders I want to retest or run tests for whole project again(It takes considerable amount of time for big projets).
What I was looking for is something like a flag
rspec --prev-failed-only
I realize that such flag would require considerable amount of additional actions from rspec, like storing results of previous tests and so on. But I think it would be super convenient to me.
Is there any such(or similar) tool/gem?
rspec-rerun gem does what you want : https://github.com/dblock/rspec-rerun
https://github.com/rspec/rspec-core/issues/456 has a good discussion on the topic of making rspec itself be able to rerun failed tests.
On the Giant Robots podcast, Sam Phippen of the core team mentioned this feature is due to be added to RSpec soon.
In case anyone else finds this, a month after the question was asked (open source <3 ) rspec 3.3 introduced the --only-failures option, also the delightfully handy --next-failure (-n) option. rspec --help for more info.
I am trying to run rails tests in the old fashion i.e. dots as output but think I am missing something. I cant find where to turn off the verbosity mode and every time I run a rake task I get a list of test descriptions which at first look nice but end up being quite boring and not very helpful.
How can I turn off rails test unit verbosity mode and get back to old ....F....E..... ?
Thanks,
Remove the turn gem from your Gemfile.
I wanted to clean up my tests, so I broke a very large one up into multiple files and wanted to store them in a subdirectory inside test/integrations...
However, now rake test does not see them.. How can I tell rake to look in an additional place for test files?
I've had this issue too, and one thing you can do is place a test within the regular subdirectory (either unit, integeration, functional) and add the lines:
system("rake test TEST=test/integration/my_subfolder/test1.rb")
system("rake test TEST=test/integration/my_subfolder/test2.rb")
Etc. It's not the nicest solution, but it works. I can't remember now, but I don't think you can use regex in that singular TEST option.
NetBeans 6.9 provides a custom Runner class for RSpec to be integrated into the IDE. I'm trying to get my Rails 3 applications specs to be correctly displayed inside NetBeans, but RSpec 2 seems no longer to support custom Runner classes in general.
Any ideas how to get the specs into the IDE anyway?
Just in. Oracle has just announced they are withdrawing support for Rails in future version of NetBeans. Time to start looking at other IDE options.
http://news.ycombinator.com/item?id=2148161
So far (NB 6.9.1) the only way I know to run Rspec2 tests from inside NetBeans is by using rake tasks. But I was not able to make it work with UI Test Runner, because of this and few other problems. So the best way is to avoid invoking UI runner, this can be done in many ways:
Disable it via tools -> options -> miscellaneous -> Ruby
modify project.properties file
give other name to task than 'spec', so naming task as 'rspec' will avoid invoking UI runner
This way you will have just test results in output pan, but it is still usable, because you can click anywhere on stack trace, and NB will take you immediately to that file:line.
There is one thing left, auto generated by NB Rakefile has not valid task (for Rails projects, there is NO such problem), to make it work one needs at least:
require 'rspec/core/rake_task'
Rspec::Core::RakeTask.new(:rspec)
I know this is not what you are expecting but you might want to check RubyMine3 out it comes out of the box, you do need to buy a licence but at least you can check it out in the 30 day trial
I am using RVM.
And at the minimum I wanted to be able to run my Ruby 1.9.2 / Rails 3 / RSpec 2 specs from inside the IDE and be able to click on stack traces for Netbeans to open the right files and lines.
I found a work-around for that:
Put somewhere in the project a ruby file that shells out to run the spec suite.
E. g. my ruby file has the following content:
system <<EOF
time ~/.rvm/wrappers/ruby-1.9.2-p290#default/rspec --drb spec
EOF
Change the ruby version and gemset as you need it.
The major limitation:
I cannot just run only a single spec. For that I have to change the "spec" parameter to the target spec file (which isn't such a big deal though).
Netbeans is fairly sluggish running specs (using rspec1 here), would recommend running specs from command line.