Anyone know of a more up-to-date version of a Rails Rspec/Guard/Spork/Growl test suite set up?
These used to be great, but have become outdated as Ruby, Rails and the gems upgraded.
http://ygamretuta.me/2011/08/10/rails-3-setting-up-guard-with-rspec-and-spork-with-growl-notifications-in-osx/
https://eq8scrapbook.heroku.com/equivalents_scrap/on_rspec_spork_guard_configuration
Even the M. Hartl Ruby on Rails Tutorial instructions results in Guard tossing up a ChildProcess error and doesn't load the DRb server.
Here's what I've found to fix my problem above:
rails new app_name --skip-test-framework
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
gem 'rspec', '2.11.0'
gem 'guard', '1.6.2'
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.4.2'
gem 'spork-rails', '3.2.1'
gem 'spork', '1.0.0rc3'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'database_cleaner', '0.7.0'
gem 'launchy', '2.1.0'
gem 'rb-fsevent', :require => false
gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
Then run this:
bundle update; bundle install; rails g rspec:install; guard init rspec; guard init spork; spork --bootstrap
Guardfile
Put the boostrapped spork block before the rspec block
spec_helper.rb
Put the block starting with "ENV["RAILS_ENV"] ||= 'test'" inside the Spork.prefork block
.rspec
add --drb
Run 'guard' and you should be all set.
Related
In updating dependencies, I have come across updating sprockets. However there doe not appear to be a proper dependency for my set of gems. After returning to: 2.11.3, the erorr apepars:
/Users/..../rvm/gems/ruby-2.3.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/engine.rb:11:in `block in <class:Engine>': uninitialized constant Sprockets::Rails::VERSION (NameError)
Gemfile:
source 'http://rubygems.org'
ruby '2.3.0' # '1.9.3'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.2.6'
#gem 'pg', '0.15.1'
gem 'mysql2', '0.4.4'
gem 'bootstrap-sass', '3.3.6'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'geocoder', '1.3.7'
gem 'nested_form', '0.3.2'
gem 'utf8-cleaner', '0.2.4'
gem 'sprockets', '3.6.0' #2.11.3
gem 'json', '1.8.3'
gem 'ffi'
gem 'iconv', '1.0.4'
gem 'chosen-rails', '1.5.2'
gem 'compass-rails', github: 'Compass/compass-rails'
# For image uploads
gem 'carrierwave', '0.11.2'
# For uploading CSV
gem 'roo', '2.4.0'
# DataTables
gem 'jquery-datatables-rails', '3.4.0' # git: 'git://github.com/rweng/jquery-datatables-rails.git'
gem 'jquery-ui-rails', '5.0.5'
# Editing in line:
gem 'best_in_place', '3.1.0'
# Passing data from controller to coffeescript
gem 'gon', '6.0.1'
#gem 'jquery-turbolinks' '2.1.0'
# For searching and webservice queries-NO LONGER USED
#gem 'sunspot_rails', '2.1.0'
#gem 'sunspot_solr', '2.1.0'
gem 'progress_bar', '1.0.5'
gem 'responders', '2.2.0'
# Calendar Date and Validation
gem 'bootstrap-datepicker-rails'
# For Google Maps overlays
gem 'gmaps4rails', '~> 2.1.2'
gem 'underscore-rails', '~> 1.8.3'
group :development, :test do
gem 'rspec-rails', '3.4.2'
gem 'guard-rspec', '4.7.2'
gem 'spork-rails', '4.0.0'
gem 'childprocess', '0.5.9'
gem 'guard-spork', '2.1.0'
end
group :test do
gem 'selenium-webdriver', '2.53.3'
gem 'capybara', '2.7.1'
gem 'factory_girl_rails', '4.7.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.5.0'
group :doc do
gem 'sdoc', '0.4.1', require: false
end
gem 'rails_12factor', '0.0.3'
How can I make this work?
You can fix this problem following steps:
First, you run gem update to update your gems.
And sprockets-rails should be at version 3.0.4
Second, open your Gemfile.lock in your rails project, modify the following line to update sprocket version
sprockets-rails (3.0.4)
Finally, you run bundle install
Above one is the answer,
You can fix this problem following steps:
First, you run gem update to update your gems.
And sprockets-rails should be at version 3.0.4
Second, open your Gemfile.lock in your rails project, modify the following line to update sprocket version
sprockets-rails (3.0.4)
Finally, you run bundle install
When I run rspec spec I get this error:
bundle exec rspec spec/models/spree_user_spec.rb
/Users/martins/.rvm/gems/ruby-2.2.3#solidus/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in `block in replace_gem': rspec-core is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/rspec:22:in `<main>'
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/ruby_executable_hooks:15:in `eval'
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/ruby_executable_hooks:15:in `<main>'
Any idea why? Here you got my Gemfile:
Gemfile
source 'https://rubygems.org'
ruby '2.2.3'
gem 'solidus'
gem 'quiet_assets', group: :development
gem 'dotenv-rails', groups: [:development, :test]
gem 'puma'
gem 'cancancan', '~> 1.10'
group :test do
gem 'factory_girl_rails', '~> 4.5.0'
gem 'capybara', '~> 2.4'
gem 'capybara-screenshot'
gem 'database_cleaner', '~> 1.3'
gem 'email_spec'
gem 'launchy'
gem 'rspec-activemodel-mocks', '~>1.0.2'
gem 'rspec-collection_matchers'
gem 'rspec-its'
gem 'rspec-core'
gem 'rspec-rails', '~> 3.3.0'
gem 'simplecov'
gem 'webmock', '1.8.11'
gem 'poltergeist'
gem 'timecop'
gem 'with_model'
gem 'rspec_junit_formatter'
end
gem 'rails', '4.2.5'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :development, :test do
gem 'rubocop'
gem 'spring-commands-rspec'
gem 'guard-rspec', require: false
end
group :darwin, :test do
gem 'rb-fsevent'
end
group :production do
gem 'exception_notification'
gem 'rails_12factor'
end
A similar problem led me here, except in addition to rspec-core, none of the gems in my test group were installed, because apparently bundler remembers your initial switches.
Updating .bundle/config to not include BUNDLE_WITHOUT: "test" let bundle install add the correct gems.
rspec-core is a runtime dependency for rspec-rails and so you should not need to explicitly add it to your Gemfile. Did you add it as a result of trying to debug this? See the docs here.
When you run bundle install, bundler will go out and retrieve necessary dependencies and include those in your Gemfile.lock, with the specific versions required to support your Gemfile gems.
I recommend you start by removing rspec-core from your Gemfile and running bundle install. Then take a look at your Gemfile.lock. Is rspec-core in there? It should be. If not, it would help if you paste the snippet of your lock file that contains rspec-rails and its dependencies?
My Heroku deploy is failing on the Running: rake assets:precompile step with the follow:
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
My Gemfile has 'sqlite3' only in the development group, as you can see:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.1'
gem 'sass-rails', '~> 4.0.0'
gem "compass-rails", "~> 2.0.alpha.0"
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'devise'
gem 'figaro'
gem 'haml-rails'
gem 'sendgrid'
gem 'simple_form'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem "cancan", :git => "git://github.com/ryanb/cancan.git", :branch => "2.0"
gem 'roadie', '2.4.2'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
gem 'guard-bundler'
gem 'guard-rails'
gem 'guard-rspec'
gem 'guard-livereload'
gem 'html2haml'
gem 'quiet_assets'
gem 'rails_layout'
gem 'rb-fchange', :require=>false
gem 'rb-fsevent', :require=>false
gem 'rb-inotify', :require=>false
gem 'debugger'
end
group :development, :test do
gem 'factory_girl_rails'
gem 'rspec-rails'
gem 'zeus'
gem 'sqlite3'
end
group :test do
gem 'capybara'
gem 'capybara-webkit'
gem 'database_cleaner', '1.0.1'
gem 'email_spec'
end
group :production do
gem 'unicorn'
gem 'passenger'
gem 'rails_12factor'
end
Additionally, I am using the rails_12factor gem and user-env-compile thing... neither helped with the error. I've also added RACK_ENV=production and RAILS_ENV=production config vars to the Heroku environment, to be safe.
Seems like it Heroku is firing up the development environment when precompiling. Any ideas why?
On Heroku, I've never gotten away without having pg in my production group.
group :production do
gem 'pg'
gem 'rails_12factor'
end
Assuming you're using that database in prod, of course.
No matter what "heroku run ..." I do I always get the following error:
/usr/bin/env: ruby1.9.1: No such file or directory
as follows:
user#box:~/path$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.7070
/usr/bin/env: ruby1.9.1: No such file or directory
Here is the version:
user#box:~/path$ heroku run ruby -v
Running `ruby -v` attached to terminal... up, run.8039
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.0'
ruby "1.9.3"
gem 'rails_12factor'
gem 'pg'
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
Try this on your Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.2.0'
gem 'childprocess', '0.3.6'
gem 'spork', '0.9.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
I upgraded to rails 3.1 and I have some problems with my tests now that worked perfectly before.
I get the following warning before the tests:
DEPRECATION WARNING: ActiveRecord::Associations::AssociationCollection is deprecated! Use ActiveRecord::Associations::CollectionProxy instead. (called from at /home/user/rails_projects/project/config/environment.rb:5)
How can I use CollectionProxy instead of AssociationCollection?
Here is my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'jquery-rails'
gem "therubyracer", "~> 0.9.4"
gem 'carrierwave', '0.5.6'
gem 'haml', '~>3.1.2'
gem 'mysql2', '0.3.7'
gem 'rmagick', '2.13.1'
gem 'sitemap_generator', '2.0.1'
gem 'whenever', '0.6.8', :require => false
gem 'will_paginate', '3.0.pre2'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
group :development do
gem 'rspec-rails', '2.6.1'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.9.5', :require => false
gem 'ruby-debug19', '0.11.6'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.3'
gem 'factory_girl_rails', '1.0'
gem 'spork', '~> 0.9.0.rc'
end
This is my environment.rb:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Project::Application.initialize!
Thank you!
I had the same problem and fixed it by upgrading to the latest version of will_paginate. So, change this: gem 'will_paginate', '3.0.pre2'
to this: gem "will_paginate", "~> 3.0.2"
Save your Gemfile then do bundle install.