Rails 4 RSpec warning: you should require 'minitest/autorun' instead - rspec-rails

In trying to run RSpec on Rails 4, I immediately get a warning:
you should require 'minitest/autorun' instead
that comes up in the backtrace assigned to the line
require 'rspec/rails'
in spec_helper.rb If I add this before it
require 'minitest/autorun'
the warning goes away. Is this a fix? Should I also remove the line
require 'rspec/autorun'
that follows? Alternatively, the problem goes away without changing the spec_helper.rb file if I add
gem 'minitest'
to the gemfile
It will do this with a single spec file that only contains
require 'spec_helper'
We're running Rails 4.1.0.beta.

Please have a look at this:
https://github.com/rspec/rspec-rails/pull/772
If you use 'shoulda' or 'shoulda-matchers' in your Gemfile, please add 'require: false' to them.

This is still a bug for Rspec 3.0.0 in Rails 4.1.1. It is important to put gem 'minitest' before gem 'rspec-rails' in the Gemfile, otherwise it won't work. If you're using flexmock, minitest needs to go before that too.

Related

What is $experimental-support-for-svg in sass and why is it needed?

I've just upgraded SASS and Compass to fix a problem where the CSS wasn't compiling. All I did was:
gem uninstall sass
gem install sass --no-ri --no-rdoc
gem install compass
After doing that and executing grunt, the CSS now compiles but with the following warning:
WARNING: Compass has changed how browser support is configured. The following configuration
variables are no longer supported: $experimental-support-for-svg.
Details: http://compass-style.org/help/documentation/tuning-vendor-prefixes/
That link isn't any use, it doesn't tell me anything about the variable that is no longer supported.
I don't understand what $experimental-support-for-svg is and I can't understand why this is used in the sass stylesheets that I'm working with.
Can I safely ignore this or is this going to cause a style problem with another browser?
The warning is just a warning: you can ignore it if you want.
Prior to Compass 1.0, the $experimental-support-for-svg was used to determine whether or not an SVG was generated as a fallback for browsers that lack support for gradients. Attempting to reference any of the old variables will generate this warning. If you're not using it, then a library you're using probably does.
If you look at the documentation on gradients, you'll see that there are a new set of configuration variables. If you want to disable generating SVG gradients, it looks like the variable you're looking for is $svg-gradient-shim-threshold (by default, this is set to whatever your $graceful-usage-threshold value is).
Related: Configure compass browser support (Compass 1.x syntax)

Heroku/Zurb Foundation Sass SyntaxError in Rails App

My app is throwing this error when I try to push to Heroku. It looks like the culprit is a rogue !global line in a stylesheet somewhere, but I'm not sure where the source code lives.
rake aborted!
Sass::SyntaxError: Invalid CSS after "...odules, $name) ": expected "}", was "!global;"
(in /tmp/build_6cf14c02-e49b-44e7-819c-871d5da3cf73/app/assets/stylesheets/framework_and_overrides.css.scss:13)
Would greatly appreciate any help.
Change your foundation-rails gem from 5.4.4.0 to 5.4.3.1 in your gem file
gem 'foundation-rails', '5.4.3.1'
then run
bundle update
This should do it for now tell they fix it :)
Additionally:
As for finding the file "bundle show foundation-rails" use the finder "Go to folder" to the path and find "_function.scss" it is under vendor assets stylesheets foundation _function.scss
Both of my answers could be found in the link by gustavo-beathyate
As for heroku error
make sure if your adding any thing to the assets to use
rake assets:precompile RAILS_ENV=production
and then
also when you push use -f
git push -f heroku master
if not only use
git push -f heroku master
Here's a solution:
http://foundation.zurb.com/forum/posts/19222-sass-syntax-error-on-rails
You basically have to open the gem and modify line 13 in _functions.scss, removing the call to !global.
This issue has now been fixed with v5.4.5 of Foundation. See also here for some more background on the issue.
I was getting your exact error after I upgraded to foundation-rails 5.5.0.0. I updated the sass-rails gem per this post: https://stackoverflow.com/a/27807138/1753903 and the error went away.

Integrating Normalize.css with the rails asset pipeline

I followed the super simple direction on how to install the normalize-rails css reset gem outlined here
https://github.com/markmcconachie/normalize-rails
but I keep getting error stating that
"couldn't find file 'normalize-rails'"
when I included
*= require normalize-rails in my application.css file. I ran bundle, bundle update etc, still no dice. Am I installing this incorrectly? What I'm doing wrong?
Check this Steps:
Add gem 'normalize-rails' in your Gemfile
Run bundle install command in your terminal
Check gem is installed or not by running bundle show normalize-rails
in your terminal
restart your rails server
Add *= require normalize-rails in your application.css file before *= require_tree .
If you missed any steps then check it...
NOTE: You must using Rails 3.1+
First, run the following command to see if the gem has been installed
bundle show normalize-rails
And remember to restart your server after installing new gem :)

Ruby unable to find Foundation/foundation-global?

Yesterday I decided to give Foundation a try on one of my web apps. Everything worked fine as I was in localhost, but when I pushed the new changes to my EC2 instance, continuing to follow the Zurb Foundation instructions, I ran into this error:
Sass::SyntaxError in Home#index
Showing /var/www/brain_db/app/views/layouts/application.html.erb where line #18 raised:
File to import not found or unreadable: foundation/foundation-global. Load path: Sass::Rails::Importer(/var/www/brain_db/app/assets/stylesheets/foundation_and_overrides.scss) (in /var/www/brain_db/app/assets/stylesheets/foundation_and_overrides.scss)
As a newbie to Ruby on Rails and Foundation I'm really unsure of how to resolve this problem. I found many people with similar problems through a Google search, but their situations were slightly different which makes this hard for me to diagnose. Any advice?
I was getting this same error, and it turned out that I just needed to restart my local development server.
This is a result of running rails g foundation:install with a different version of foundation than the one you have installed. foundation-global is no longer imported as part of foundation_and_overrides.scss.
Make sure you have the latest version and re-run rails g foundation:install. Just be careful when it offers to overwrite your application layout file - if you had modified that file. Keep the old file somewhere and merge the changes.
If you are using sass then have you renamed your application.css to applications.scss and have you imported the file #import "foundation"; and one more point if you are using the gem 'zurb-foundation', '~> 4.0.0' then you have to place it under assets like this
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
# Add Foundation Here
gem 'zurb-foundation', '~> 4.0.0'
end
I also had this problem with Foundation + Bower + CodeKit.
I fixed it by replacing the following relative paths in app.scss:
BEFORE:
#import "_settings";
#import "foundation";
AFTER:
#import "_settings";
#import "../bower_components/foundation/scss/foundation";`
And also replace this in settings.scss
BEFORE:
#import 'foundation/functions';
AFTER:
#import "../bower_components/foundation/scss/foundation/_functions";
Something is the matter with your zurb-foundation gem installation. There is supposed to be a file called _foundation_global.scss in the gem's directory which contains all the default global variables. You'll get this error if that file is missing.
Reinstalling the gem should fix you right up, in your app's directory run:
gem uninstall zurb-foundation
bundle install
If that fails, manually installing the Gem (gem install zurb-foundation) might work as well.
I experienced this problem today when updating zurb-foundation to version 4. It may be that your EC2 instance has a later version of Foundation installed. If so, I recommend updating your local development environment. My experience doing this might help ...
It seems that the #import 'foundation/foundation_global'; at the head of the foundation_and_overrides.scss, is no longer required. Instead, a single #import 'foundation'; at the foot of the same file is required.
Also, I had to change my application.js file to include only the lines (relevant to foundation);
//= require foundation
$(function(){ $(document).foundation(); });
I had tried to re-run the Foundation generator that is recommended here but it seems to assumes that it is working on a new project and simply appends the new JavaScript method, as opposed to replacing the previous.

Require specific gem version in SASS & Compass

I know this is probably more a Ruby question but I work on several projects where I've used compass plugins. Later on I upgrade these plugins and start new projects. The issue arises when I need to go back and make amends to an older project.
How can I amend my config.rb file to use a specific version of a gem?
For example I often use the Compass plugin: http://rubygems.org/gems/html5-boilerplate/versions
The line in my config.rb file looks like this:
require 'html5-boilerplate'
But I would need 1.0.0 for one project and 2.1.0 in another.
Suggest using rvm (the Ruby enVironment Manager), bundler and gemsets. rvm for managing ruby versions and for allowing you to use gemsets - bundler to specify the versions of the gems you want to use in the project. After you install the bundler gem and have a Gemfile that uses the syntax you have already discovered
gem "html5-boilerplate", "~> 2.1.0"
bundle install will then bring down the gems you need for your project. Read more at http://gembundler.com
gemsets can also be project specific and different gemsets can have the same gems at different versions. you can specify the gemset associated with a project via a .rvmrc file in the project's root.
There are several nice posts out there on how to set up rvm and gemsets. Here's a good example of one to get you going:
http://adamstacoviak.com/posts/super-easy-ruby-gem-management-with-rvm-gemsets/
And here's one that also covers bundler:
http://lindsaar.net/2010/3/31/bundle_me_some_sanity

Resources