Reputation: 822
I'm facing this Failures: in Rspec - with Mongodb as database and devise for user management. Couldn't understand whats the issue.
with this command
bundle exec rspec spec/models/user_spec.rb
FFFF
Failures:
1) User
Failure/Error: email { Faker::Internet.email }
NameError:
uninitialized constant Faker
# ./spec/factories/users.rb:3:in `block (3 levels) in <top (required)>'
# ./spec/models/user_spec.rb:19:in `block (2 levels) in <top (required)>'
2) User
Failure/Error: email { Faker::Internet.email }
NameError:
uninitialized constant Faker
# ./spec/factories/users.rb:3:in `block (3 levels) in <top (required)>'
# ./spec/models/user_spec.rb:19:in `block (2 levels) in <top (required)>'
3) User
Failure/Error: email { Faker::Internet.email }
NameError:
uninitialized constant Faker
# ./spec/factories/users.rb:3:in `block (3 levels) in <top (required)>'
# ./spec/models/user_spec.rb:19:in `block (2 levels) in <top (required)>'
4) User
Failure/Error: email { Faker::Internet.email }
NameError:
uninitialized constant Faker
# ./spec/factories/users.rb:3:in `block (3 levels) in <top (required)>'
# ./spec/models/user_spec.rb:19:in `block (2 levels) in <top (required)>'
Finished in 0.00478 seconds (files took 2.1 seconds to load)
4 examples, 4 failures
Failed examples:
rspec ./spec/models/user_spec.rb:23 # User
rspec ./spec/models/user_spec.rb:24 # User
rspec ./spec/models/user_spec.rb:25 # User
rspec ./spec/models/user_spec.rb:26 # User
with /spec/models/user_spec.rb
require 'spec_helper'
describe User do
before { @user = FactoryGirl.build(:user)}
subject { @user }
it { should respond_to(:email) }
it { should respond_to(:password) }
it { should respond_to(:password_confirmation) }
it { should be_valid }
end
and spec/factories/users.rb
FactoryGirl.define do
factory :user do
email { Faker::Internet.email }
password "12345678"
password_confirmation "12345678"
end
end
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'mongoid', '~> 5.1.0'
#Api gems
gem 'active_model_serializers'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem "factory_girl_rails"
gem 'ffaker'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :test do
gem "rspec-rails"
end
gem "devise"
Upvotes: 0
Views: 1323