user4219550
user4219550

Reputation: 117

How to get rspec test files, bundled into a new gem, to run on windows w/o having to go into gem directory on windows

I'm currently running Ruby 2.0.0, on a Windows 8.1 machine, and have the following question:-

I've recently created a new Ruby gem, pushed it to my remote git repo and then to test it's functionality, gone into another local directory and done a bundle to download it, and then required the gem within a file to test that it's working ok. Everything up to this point is fine so far.

In my gemspec file, I had included rake and rspec dependencies which when I run bundle should download the respective rake and rspec gems for me to use. The problem comes when I try to run rake in this local directory (C:\git\trial), I get the following error:

C:\git\trial>rake rake aborted No rakefile found (looking for: rakesile, Rakefile, rakefile.rb, Rakefile.rb)

However if I was to cd into the directory on my local machine where my gem had been deposited (C:\ruby21\lib\ruby\gems\2.1.0\bundler\gems\newgem-f0f901223), do a bundle and then run my rake command,

C:\ruby21\lib\ruby\gems\2.1.0\bundler\gems\newgem-f0f901223>rake build Rake file executes correctly.

(I also am using my rake command to run my rspec tests and the same thing occurs i.e. only running correctly inside C:\ruby21\lib\ruby\gems\2.1.0\bundler\gems\newgem-f0f901223.

Can anyone please explain why this occurs and more importantly should I be able to run rake from C:\git\trial and have it execute as expected ?

(Background: I have only recently began building Ruby applications on a Windows machine)

Thanks

Upvotes: 0

Views: 116

Answers (1)

Thermatix
Thermatix

Reputation: 2929

Add an executable as a wrapper to execute your specs. for example if you have your specs set up with rake that has in it's code:

Dir.chdir('get_dir_of_rake_script'){
  exec "rake spec"
}

Upvotes: 0

Related Questions