Closed yuya-takeyama closed 13 years ago
I solved this problem like this.
diff --git a/Gemfile b/Gemfile
index fb1a83e..204abea 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,7 +14,7 @@ gem 'mongoid', "2.0.0"
gem 'bson_ext', :require => "mongo"
# Test requirements
-gem 'rspec', :group => "test"
+gem 'rspec'
gem 'rack-test', :require => "rack/test", :group => "test"
Now i can execute "rake" and "heroku rake" too. Thank you.
Interesting, thanks for the note. Should we make this change in the rspec component? Looks like you just changed
gem 'rspec', :group => "test"
to
gem 'rspec'
Is that right?
Yes. That is all.
haaaaaaaaaaa found!
You forgot to set the environment:
$ PADRINO_ENV=test rake spec
will work like a charm!
remember that when you use :group => 'some'
in Gemfile you need to set the PADRINO_ENV=some
for handle it.
That seems to be a bit confusing, shouldn't we remove that group? Nobody knows to set that env in front and they shouldn't need to IMO.
Groups are useful because you prevent to install (ex: production) tests stuff.
Generally is a great thing use PADRINO_ENV / RACK_ENV because you are sure for example to use the correct database ... in this case the test_database
So you want to be forced to do PADRINO_ENV=test rake spec
for every single test run? I don't normally see this in Rails or plain Sinatra being required to specify the test env in a test rake task. But I will leave it up to you and @achiu to decide what to do here.
generally I use padrino rake spec -e test
@yuya-takeyama are you using the default Padrino generated spec_helper.rb? that should load your PADRINO_ENV for you
@achiu Yes. The default one.
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
RSpec.configure do |conf|
conf.include Rack::Test::Methods
end
def app
##
# You can handle all padrino applications using instead:
# Padrino.application
TestProject.tap { |app| }
end
this is doesn't work on heroku
Yep... I have to agree (sorry DAddyE), that should be changed. It causes issues and violates 'least surprise'
Passing the padrino env is neither intuitive or expected behaviour.
I came by this post because heroku exploded when I tried starting up a rake task wchich works fine in dev on my machine.
I also had problems with this before, see https://github.com/padrino/padrino-framework/commit/f6708d845fbfbeadbff27f6e49b0e09d8717a736
Hi, what's the proper fix on heroku?
On heroku, I set "PADRINO_ENV=production" but running "heroku run rake dm:migrate" still fails with the same "no such file to load -- rspec/core/rake_task"
For now, replacing Gemfile: gem "rspec" does the trick but I have rspec installed in production.
Quick fix for deploying to heroku:
spec/spec.rake
if ENV['PADRINO_ENV'] == 'test'
require 'rspec/core/rake_task'
spec_tasks = Dir['spec/*/'].map { |d| File.basename(d) }
spec_tasks.each do |folder|
RSpec::Core::RakeTask.new("spec:#{folder}") do |t|
t.pattern = "./spec/#{folder}/**/*_spec.rb"
t.rspec_opts = %w(-fs --color)
end
end
desc "Run complete application spec suite"
task 'spec' => spec_tasks.map { |f| "spec:#{f}" }
end
Could the rake tasks in spec/ and test/ be ignored unless env is test?
Hi. I'm enjoying my development with Padrino thank you.
Using RSpec as testing framework, rake command (not "padrino rake") seems to have a problem. And it causes "heroku rake" failure.
I'm using below.
Appears by the following.
Save below as "Rakefile".
padrino rake
Normal rake