Rubymine (Ruby): Why can't I run rspec from within the IDE? - ruby

If I run the following command from the terminal I am able to run the rspec test cases successfully.
bundle exec rspec spec/requests/api/contacts/v3_get_tags_spec.rb
However if I am in the Rubymine IDE and do:
1- Right click on the file
2- Select "Run"
Then i get the following error message.
"in `require': cannot load such file -- spec_helper (LoadError)"
Also i am seeing a lot of errors related to gems not found, i feel link Rubymine is not configured correctly. What am i missing?
Note: Both the terminal and the IDE are running in the same root directory. I am pretty sure there is a problem with the configuration of the IDE. I checked the preference setting and it is using the same version of ruby as the one I am running in the termina.
Any help on the issue would be greatly appreciated.

Related

Why did my minitest/pride alias break?

Silly, cosmetic question for everyone.
I take pride in my testing. That is, I like to use minitest/pride. Unfortunately, not everyone on my team is a fan, so I have activated it in the past using the command line instead of modifying the code by setting an alias to this:
RUBYOPT=-rminitest/pride bex rake`
(bex is an alias to bundle exec, and the default rake task runs our tests.)
Recently, we updated the ruby version of our project from 1.9.3 to 2.2.0. This has broken my alias, and now when I try to run it, I get this error instead:
/Users/cf5455/.rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- minitest/pride (LoadError)
from /Users/cf5455/.rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
My best guess as to why this is happening is that MiniTest was changed since our last Ruby version and pride has been renamed or moved, but I have not been successfully able to Google its new name or location.
Does someone know a way that I can fix my arguments to get pride working again?
Duplicated your error by switching to ruby 2.3.0. I just ran the tests before installing any gems.
I managed to get the tests running with your alias by simply doing a gem minitest install. Not sure if your problem is caused by the same reason since I'm using rbenv for managing my rubies and gems but it does feel like you are having a package management issue. Hope this helps.

how to use RVM to a ruby app engine?

i wanna make a simple ruby App Engine in rails just like heroku, i'm dealing with a problem now.
My idea was:
1.use rails to establish the App Engine, use a class 'App' to handle all apps.
2.when a user create an ruby app he should offer it's git path
3.when the user deploys it, my app engine will do these things:
clone the git to a path in my server (done
use RVM to designatine the ruby version witch user wanted and make a gemdir for the project (some problems here
create a nginx conf for the project, then include it and reload nginx (i can do it
Problems in the second step:
codes here:
def start_thin
Dir.chdir(proj_path) do
system('rvm use ruby-1.8.7-p352#testname --create')
system('gem env gemdir')
success = system ('thin start -s3 --socket ' + self.proj_sock)
if success
return true
end
end
return false
end
when the code runs here, the log told me "RVM is not a function...blahblah", i know something about the login-shell and non-login-shell, then i try to fix it via editing .bashrc but same problem occurred.
And if i ignore it, the app can't be deployed, because of a Load Error :
myapp.rb:2:in `require': cannot load such file -- sinatra (LoadError)
if i open a terminal in that app directory, i can use thin to start it.
i wanna know how to run cmd just like in a terminal, without all these odd problem?
or how to edit my method to fix it?
Thanks!
Thanks Casper and GhostRider.
The user and rvm settings are correct.
After lots of googles and tests i found it's impossible...
Finally I fixed it by using RVM's ruby api instead of running system command.
Such as :
require 'rvm'
env = RVM.current
env.gemset.create('app1')

Need help with starting RoR: Command "rails server" does not result in "Booting WEBrick"?

I need help to get started with RoR.
I currently follow this guideline:
http://allaboutruby.wordpress.com/2009/07/20/installing-rails-on-windows-3-years-later/#comment-11099
I followed step 1 through 3 w/o problems.
In step 5: I can get the webserver through WEBrick working.
When i put
"rails server"
instead of getting "Booting Webrick", i get "rails new_path option"
thus when i try 127.0.0.1:3000 in the browser... it does work.
Can anyone guide me on this on how to get it up and runnning? (Im a total newb for now...so i need specific explanations! thanks!)
In your tutorial i can't see the command 'bundle install' - it's checking and installing all necessary gems in your system. So why you don't use another great rails tutorial - http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
I'm guessing you are running windows, on which rails can be a little awkward. You'll probably need to run the rails server command by pointing ruby at the server script. On windows, your rails "commmand" is actually just a .bat file that lives in the /bin file of your ruby installation, and that .bat file just passes the arguments to ruby. If you look at the rails gem that is installed on your machine, you'll see the files that correspond to the normal first argument of a rails command (console, generate, server, etc). You might find it helpful to copy these to the /script directory of your application, and when you want to run a rails command you can just run "ruby script\server" from your application's main directory, though there may be more accepted ways of getting the same result.

Textmate cucumber bundle issues - 'Run Feature' producing errors

From a cucumber feature file when I go to 'Run features' Im getting the error below in the popup box that appears.
How do I fix this?
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- /Users/evolve/Projects/i9/Tornelo/.bundle/environment (LoadError) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire' from /Users/evolve/Library/Application Support/TextMate/Bundles/Cucumber.tmbundle/Support/lib/cucumber/mate/../mate.rb:10 from /Users/evolve/Library/Application Support/TextMate/Bundles/Cucumber.tmbundle/Support/lib/cucumber/mate/feature_helper.rb:1:in require' from /Users/evolve/Library/Application Support/TextMate/Bundles/Cucumber.tmbundle/Support/lib/cucumber/mate/feature_helper.rb:1 from /tmp/cucumber-906.rb:2:inrequire' from /tmp/cucumber-906.rb:2
I had the same error. To fix it you need to edited this file:
/Users/richie/Library/Application Support/TextMate/Pristine Copy/Bundles/Cucumber.tmbundle/Support/lib/cucumber
Replace line 10 with the following 2 lines:
environment_file = File.join(ENV['TM_PROJECT_DIRECTORY'], bundle_path, "environment")
require "#{enviroment_file}" if File.exists?("#{environment_file}.rb")
That way it only loads the file if it exists.
I'm using RSpec 2.0 so I also had to modify the rspec require at line 23 (now line 24) to read:
require 'rspec'
This has happened to me since I loaded rvm and gone through the steps listed under packages for textmate.
Now, when I 'run feature' for a cucumber feature from within textmate I get an error '.bundle/environment no such file to load'.
I don't have a .bundle/environment.rb so I created an empty one and the feature gets run but the environment.rb file gets deleted every time! (Making me very keen to see this fixed!)
If you have any feedback to add to your post I'd be very interested to hear it.
Since I posted this, I've reloaded the Textmate cucumber bundle and the problem has gone away.
Beware though - the installation instructions are incorrect - they should read
mkdir -p ~/Library/Application\ Support/TextMate/Bundles/
cd ~/Library/Application\ Support/TextMate/Bundles
rm -rf Cucumber.tmbundle
git clone http://github.com/drnic/cucumber-tmbundle Cucumber.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
You don't need the 'rm -rf Cucumber.tmbundle' line if this is a first install.
No editing of files needed!
You will be able to update from within textmate once you have done this.
I had a lot of problems getting my CMD-R feature to work, but getting it from the latest master from the Cucumber author, went a long way:
https://github.com/aslakhellesoy/cucumber-tmbundle/tree/
For line 10 in this file:
/Users/richie/Library/Application Support/TextMate/Pristine Copy/Bundles/Cucumber.tmbundle/Support/lib/cucumber/mate.rb
Just comment it out! I didn't have a bundle.environment file anyways. But as written above, definitely change the 'require spec' line if you don't have the Gem. Shame the error messages aren't legible in this thing.
And still! There is no longer any "TM_CUCUMBER_BIN" variable, and it turns out that my environment doesn't like "cucumber #{file_name}", but rather "bundle exec cucumber #{file_name}". (Because I also have functioning Rails 2.3.11 environments installed, is why)
In
~Cucumber.tmbundle/Support/lib/cucumber/mate/runner.rb:
Change line 52 from:
#output << %Q{Running: #{full_command = "#{RUBY_BIN} #{command} #{#file.rake_task} #{argv.join(' ')}"} \n}
to
#output << %Q{Running: #{full_command = "bundle exec cucumber #{#file.rake_task} #{argv.join(' ')}"} \n}
One more thing! I have my feature files nested in various subdirectories, so it had no idea where to pull my step definitions from, despite the fact that a Dir.chdir() is called. So I had to add
TM_CUCUMBER_OPTS=-r my_features_dir --format=html
to the Preferences=>Advanced=>ShellVariables settings in TextMate.
Codeape has forked and updated the bundle.
I applied a hack myself with a little help from some guru's.
Try this:
github.com/codeape/cucumber-tmbundle
Let me know how it goes user241560.
I had the same problem and solved it by following these steps :
> mate ~/Library/Application\ Support/TextMate/Bundles/Cucumber.tmbundle/Support/lib/cucumber/mate.rb
Comment or Remove line 20 (or whatever line the error message says) :
> #require 'spec'
It seems like the Textmate Cucumber bundle is currently lagging on development in the main branch.
People seem to be addressing issues as they come up ie Bundler/ Rspec2 /Rails3 / RVM.
Anyone else with problems, I suggest checking the github network map and finding recent branches which talk of issues similar to what you are having.
https://github.com/aslakhellesoy/cucumber-tmbundle/network

Page displays true after running command: 'webby'

I'm running though the webby tutorial and I get to the part where you run the webby command for the first time to generate the website in the /output directory.
I do that, and next I'm told to open output/index.html. I do so, and the only thing that displays is:
true
I view the source...and all that is displayed is
true
This isn't a Budweiser commercial from years past! This is webby!
I wrote down the commands I used to install webby here, but it still doesn't seem to work.
According to the webby -v command... I was doing it correctly. What did I do wrong?
Just to confirm - did you open output/index.html in a browser? And the "true" that you describe is what you see in your browser...?
Before you ran the webby command, did you edit any of the files, especially content/index.txt? Can you paste the contents of content/index.txt here...?
Did you install RedCloth as well as Webby or did it install automatically as a dependency? If you run the following command, you can see whether RedCloth is installed.
gem list RedCloth

Resources