NameError: uninitialized constant Faker:: - ruby-on-rails

Before(:all) do
puts "HELLO ALL :D"
end
I have some problem with my code:
/spec/factories.rb
require 'faker'
FactoryGirl.define do
factory :booking_error do
booking_id { Faker::Number.number(3).to_i }
error_type_cd BookingError.error_types.values.shuffle.first
process_name Enums::FlightEnum::PROCESSES.keys.shuffle.first
description "DESCRIPTION"
old_value "OLD_STRING"
new_value "NEW_STRING"
end
end
/spec/models/booking_error_spec.rb
require 'spec_helper'
describe BookingError do
before(:all) do
#booking_error = FactoryGirl.build(:booking_error)
#booking_error_types = BookingError.error_types
end
it 'Validating BookingError save.' do
#booking_error.save.should be_true
end
end
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'mysql2' , '0.3.11'
gem 'devise' , '2.2.0.rc'
gem 'devise-encryptable' , '0.1.1'
gem 'unicorn' , '4.5.0'
gem 'kaminari' , '0.14.1'
gem 'memcache-client' , '1.8.5'
gem 'simple_enum' , '1.6.4'
gem 'resque' , '1.23.0' , :require => "resque/server"
gem 'resque-logger' , '0.1.0'
gem 'resque-workers-lock'
gem 'whenever' , '0.8.1' , :require => false
gem 'httparty' , '0.9.0'
gem 'newrelic_rpm' , '3.6.1.88'
gem 'cancan' , '1.6.8'
gem 'rolify' , '3.2.0'
gem 'json-schema' , '1.1.1'
gem 'faker' , '1.1.2'
gem 'ruby-enum' , '0.2.1'
gem 'mail' , '2.5.4'
gem 'daemons-rails'
group :develop, :test do
gem 'capistrano' , '2.13.5'
gem 'capistrano-unicorn' , '0.1.6' , :require => false
gem 'capistrano-resque' , '~> 0.1.0' , :require => false
gem 'rvm-capistrano' , '1.2.7'
gem 'capistrano-ext'
gem 'rspec-rails' , '2.12.0'
gem 'debugger' , '1.5.0'
gem 'thin' , '1.5.0'
gem 'annotate' , '2.5.0'
gem 'factory_girl_rails' , '4.1.0'
gem 'yard' , '0.8.5.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'therubyracer' , '0.10.2'
gem 'coffee-rails' , '3.2.2'
gem 'uglifier' , '1.3.0'
gem 'twitter-bootstrap-rails' , '2.1.9'
gem 'sass' , '3.2.4'
gem 'jquery-ui-rails' , '3.0.0'
gem 'less-rails' , '2.2.6'
end
gem 'jquery-rails' , '2.1.4'
When i run:
$ rspec spec/models/booking_error_spec.rb
I get the error that is in the title:
NameError: uninitialized constant Faker::Number

Number didn't exist in Faker at the version you are using (1.1.2). Update to version 1.2.0 and it will work.

Related

No connection pool with 'primary' found

I am using rails 5.2.3 and ruby 2.5.2 version , In my work i have two active job classes that will perform two jobs parallel , I am using MSSQL database and having "No connection pool with 'primary' found" issue when it started working in parallel .
Can anyone help me to resolve this .
#source 'https://rubygems.org'
source 'http://production.cf.rubygems.org'
#source 'http://rubygems.org'
gem 'rails', '5.2.3'
gem 'log4r'
gem 'will_paginate'
gem 'bcrypt'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activesupport'
gem 'activerecord-sqlserver-adapter'
gem 'tiny_tds'
gem 'sequel'
gem 'mysql2', '~> 0.5.2 '
gem 'bootsnap'
gem 'capybara'
gem 'poltergeist', :group => [:development, :test]
gem "rspec-rails", :group => [:development, :test]
gem 'public_suffix'
gem 'xpath'
gem 'nokogiri'
gem 'byebug', '~> 11.1', '>= 11.1.1'
gem 'activewarehouse-etl', '~> 1.0'
gem 'table_print'
gem 'sidekiq'
#gem 'pg'
gem 'adapter_extensions', '~> 0.9.5.rc1'
gem 'test-unit'
gem "iconv", "~> 1.0.3"
gem 'fileutils'
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
gem 'stupidedi'
gem 'sass-rails'
gem 'sass'
gem 'coffee-rails'
gem 'mailfactory'
gem 'rake'
gem 'rack-cache'
gem 'listen'
gem 'thor'
gem 'openssl'
gem 'rb-inotify'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyrhino'
gem 'uglifier'
group :assets do
end
gem 'rubyzip', '>= 1.0.0'
gem 'axlsx'
gem "axlsx_rails"
gem 'prawn'
gem 'typhoeus'
gem 'tlsmail'
gem 'net_http_ssl_fix'
gem 'simple_xlsx_reader'
gem 'spreadsheet'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'

active job with rails rspec

I have installed a gem rspec-rails. Everything is working fine except ActiveJob.
I have tried to implement the ActiveJob in RSpec with:
include ActiveJob::TestHelper
and here's the code for the RSsec Job Controller:
describe "#perform_later" do
it "Send Invoice Reminder" do
ActiveJob::Base.queue_adapter = :test
InvoiceReminderJob.perform_later
expect(InvoiceReminderJob).to have_enqueued_job
end
end
spec_helper.rb:
require 'rails_helper'
RSpec.describe InvoiceReminderJob, type: :job do
include ActiveJob::TestHelper
# pending "add some examples to (or delete) #{__FILE__}"
describe "#perform_later" do
it "Send Invoice Reminder" do
ActiveJob::Base.queue_adapter = :test
InvoiceReminderJob.perform("test")
expect(InvoiceReminderJob).to have_enqueued_job
end
end
end
invoice_reminder_job_spec.rb:
require 'rails_helper'
RSpec.describe InvoiceReminderJob, type: :job do
# include ActiveJob::TestHelper
# pending "add some examples to (or delete) #{__FILE__}"
describe "#perform_later" do
it "Send Invoice Reminder" do
ActiveJob::Base.queue_adapter = :test
InvoiceReminderJob.perform_later
expect(InvoiceReminderJob).to have_enqueued_job
end
end
end
When I am trying to run rspec with the command rspec I am getting the following error:
uninitialized constant ActiveJob (NameError)
Here is my Gemfile:
Here is the gemfile included for my project:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'acts-as-taggable-on', '~> 3.4'
gem 'acts_as_tenant'
gem 'audited', '~> 4.0'
gem 'audited-activerecord'
gem 'aws-sdk', '~> 1.6'
gem 'axlsx'
gem 'best_in_place', '~> 3.0.1'
gem 'bootstrap-generators'
gem 'bootstrap-sass'
gem 'bullet', group: 'development'
gem 'cancancan', '~> 1.10'
gem 'clockwork'
gem 'coffee-rails', '~> 4.1.0'
gem 'daemons'
gem 'delayed_job_active_record'
gem 'devise'
gem 'eefgilm'
gem 'exception_notification'
gem 'figaro'
gem 'font-awesome-rails'
gem 'i18n-js', '>= 3.0.0.rc11'
gem 'jbuilder', '~> 2.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'mailman'
gem 'net-ssh'
gem 'paperclip', '~> 4.2'
gem 'pg'
gem 'protected_attributes'
gem 'puma'
gem 'rails', '4.1.5'
gem 'rails-console-tweaks'
gem 'rails-i18n'
gem 'rails_best_practices'
gem 'redcarpet'
gem 'rest-client'
gem 'roo'
gem 'roo-google'
gem 'roo-xls'
gem 'rubocop', require: false
gem 'sass-rails', '~> 5.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'seed_dump'
gem 'simple_form'
gem 'therubyracer', platforms: :ruby
gem 'traceroute'
gem 'twitter-bootstrap-rails'
gem 'uglifier', '>= 1.3.0'
gem 'whenever', :require => false
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
gem 'zip'
group :development do
gem 'capistrano'
gem 'capistrano3-puma'
gem 'capistrano-bundler', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-rvm'
gem 'rails-erd'
gem 'capistrano-rails-console', require: false
gem 'capistrano-maintenance', '~> 1.0', require: false
gem 'letter_opener'
gem 'rspec-rails'
gem 'faker'
end
group :production do
gem 'rails_12factor'
end
group :test do
gem 'shoulda-matchers'
gem 'database_cleaner'
gem 'simplecov'
end
group :development, :test do
gem 'byebug'
gem 'hirb'
gem 'mocha'
gem 'activejob'
gem 'factory_bot_rails'
end
And here is the output of bundle show activejob:
/Users/221/.rvm/gems/ruby-2.1.2/gems/activejob-0
I have tried to search with lots of solution but I am not able to resolve this issue. If anyone could help me with it, I would be really grateful.
You are using rails 4.1.5, ActiveJob is introduced in rails 4.2
This issue is resolved by using the gem "gem 'activejob_backport'

Couldn't find file 'bootstrap-transition'

Error message, when I open project: couldn't find file 'bootstrap-transition'
(in /home/ubuntu/workspace/app/assets/javascripts/w.js.coffee:3)
In file w.js.coffee line 3 is #= require bootstrap-transition.
Which gem do I need to download or what needs to be customized in a rails project?
Gem file:
source 'https://rubygems.org'
gem 'rails', '~>3.2.12'
gem 'mysql2', '0.3.13'
gem 'haml-rails'
gem 'haml-contrib'
gem 'jquery-rails', '~>2.0.2'
gem 'paperclip', '~>3.4.0'
# gem 'authlogic'
gem 'devise', '~>2.2.3'
gem 'devise-encryptable'
gem 'devise-async'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-vkontakte'
gem 'dynamic_form'
gem 'simple_form'
gem 'russian'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'will_paginate'
gem 'state_machine'
gem 'settingslogic'
gem 'meta_search'
# gem 'meta_where', '1.0.1' # -> Using Rails 3.1? You want to take a look at Squeel instead
gem 'squeel'
gem 'ancestry'
gem 'retina_tag'
gem 'strong_parameters'
gem 'role-rails'
gem 'dropzonejs-rails'
gem 'daemons'
gem 'delayed_paperclip'
# gem 'rufus-scheduler', '2.0.10'
gem 'whenever', :require => false
gem 'thinking-sphinx', '~>2.0.14'
# gem 'ts-delayed-delta', :require => 'thinking_sphinx/deltas/delayed_delta'
gem 'resque', :require => 'resque/server'
gem 'resque-scheduler', '2.0.1'
gem 'resque-retry'
gem 'redis-namespace', '1.3.0'
gem 'ts-resque-delta', '~>1.2.4'
gem 'RedCloth'
gem 'rails_autolink'
gem 'acts-as-taggable-on'
gem 'acts_as_list'
gem 'tzinfo'
# gem 'aws-s3', :require => 'aws/s3'
gem 'aws-sdk', '~> 1.5.7'
gem 'aws-ses', :require => 'aws/ses'
gem 'newrelic_rpm'
gem "airbrake"
gem 'draper'
gem 'redis-rails'
# gem 'robokassa', git: 'git://github.com/glebtv/robokassa.git'
gem 'rest-client'
gem 'asset_sync'
gem 'private_pub'
gem 'thin'
# gem 'emoji4rails'
gem 'rails_emoji'
gem 'rumoji', git: 'git://github.com/mwunsch/rumoji'
gem 'escape_utils'
gem 'cocoon'
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'compass-rails'
gem 'bootstrap-sass', '2.1.1.0'
gem 'therubyracer'
gem 'execjs'
gem 'uglifier', '>= 1.0.3'
gem 'oily_png'
# gem 'font-awesome-rails'
gem 'turbo-sprockets-rails3'
end
group :development, :test do
gem 'rspec-rails', '2.5.0'
gem 'factory_girl'
gem 'factory_girl_rails'
gem 'rails3-generators', '0.17.4'
gem 'timecop', '0.3.5'
gem 'quiet_assets'
gem 'capybara'
gem 'database_cleaner'
gem 'capybara-user_agent'
gem 'pry-byebug'
end
group :development do
gem 'capistrano', '~>2.15.4', require: false
gem 'capistrano-ext', require: false
gem 'rvm-capistrano', require: false
gem 'wirble'
# gem 'hirb'
gem 'git'
gem 'letter_opener'
gem 'rack-mini-profiler'
gem 'mailcatcher'
end
group :production do
gem 'unicorn'
end
gem 'tinymce-rails'
gem 'tinymce-rails-langs'
gem 'backup'
After installing gem bootstrap-sass restart server.

Access to Rails.application.routes.url_helpers in views missing after Rails upgrade

I am attempting to upgrade an application from Rails 2.3 to 3.2. The issue I am currently stuck with is that Rails.application.routes.url_helpers is missing in views.
So, for example, my routes.rb file contains (in part):
MyApp::Application.routes.draw do
resources :users
end
and running rake routes shows me that I have the following:
users GET /users(.:format) users#index
POST /users(.:format) users#create
However, when I try to use the users_path in a HAML view, such as in the following example:
- if logged_in?
%ul.nav
- if user_can?(:see_users?)
%li.users= link_to "Users", users_path
Then I get the following error:
undefined local variable or method `users_path' for #<#<Class:0x000001045eda80>:0x000001030f6bb8>
However, if the ApplicationController is changed to include:
include Rails.application.routes.url_helpers
then everything is okay. The question is, why is that helper not automatically available in the views after the upgrade?
Update: As requested in comment below, the Gemfile is:
source 'http://rubygems.org'
source 'http://gems.github.com'
gem 'rails', '3.2.13'
gem 'rake', '10.0.4'
gem 'haml', '3.1.4'
gem 'responders', '0.9.3'
gem 'inherited_resources', '1.4.0'
gem 'formtastic', '2.2.1'
# Note: validation_reflection coming from git for now as it has the fix for
# https://github.com/redinger/validation_reflection/pull/13 in it, while the
# current official 1.0.0 release does not have the fix. Can be changed back
# to a version number if 1.0.1 is released.
gem 'validation_reflection', :git => 'git://github.com/redinger/validation_reflection.git'
gem 'treetop'
gem 'authlogic', '3.1.2'
gem 'param_protected', '2.0.0'
gem 'chronic', '0.2.3'
gem 'amon', '0.12.0'
gem 'aws-sdk', '1.9.5'
gem 'paperclip', '3.4.1'
gem 'json', '~> 1.4.3'
gem 'airbrake', '~> 3.0.5'
gem 'bluecloth', '>= 2.0.0'
gem 'less'
gem 'therubyracer'
gem 'mysql'
gem 'rdoc'
gem 'thin', '1.3.1'
gem 'delayed_job', '3.0.5'
gem 'delayed_job_active_record'
gem 'will_paginate', '3.0.4'
gem 'newrelic_rpm'
gem 'tiny_mce'
gem 'geocoder'
gem 'safe_attributes'
group :development do
gem 'capistrano', "~> 2.13.5"
gem 'capistrano-ext'
gem 'rvm-capistrano'
gem 'ci_reporter', '1.6.5'
end
group :development, :test, :cucumber do
gem 'pry'
gem 'rspec', '1.3.2'
gem 'rspec-rails', '~> 1.3.0', :require => 'spec'
gem 'email_spec', '0.6.5'
gem 'seed-fu'
end
group :test do
gem 'mocha', '0.9.8'
gem 'machinist', '1.0.6'
gem 'faker', '0.3.1'
gem 'timecop', '0.3.5'
gem 'fakeweb', '1.3.0'
gem 'shoulda'
gem 'uuid', "~> 2.3.7" # MIT
end
group :cucumber do
gem "cucumber", "~> 1.1.0"
gem "cucumber-rails", "~> 0.3.2"
gem "capybara", "~> 1.1.1"
gem 'database_cleaner', "~> 0.5.0"
gem 'launchy'
gem 'uuid', "~> 2.3.7" # MIT
end

Capybara + Rspec + :webkit = undefined javascript_driver

I want to change my default drive for running tests with javascript, specific scenario with javascript, from default, :selenium, to any, like :webkit, in RSpec, just setting :js => true flag. But, trying to runing "describe 'xxx', :js => true do" with :webkit, and loading javascript_driver in rspec_helper, thats what happened "Undefined method javascript_driver for Capybara:Module"
undefined method `javascript_driver=' for Capybara:Module (NoMethodError)
how I defined loader :webkit in file spec_helper.rb:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Capybara.javascript_driver = :webkit
Version of Capybara is 1.1.2
Gem File:
source 'https://rubygems.org'
gem 'rails', '3.2.5'
gem 'pg', '0.12.2'
gem "meta_search"
# Bootstrap and layouting
gem 'bootstrap-sass', '2.0.3'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'rails3-jquery-autocomplete'
#test support
gem 'faker', '1.0.1'
#login rules
gem 'devise'
gem 'cancan'
#criptar
gem 'bcrypt-ruby', '3.0.1'
#BR
gem 'brazilian-rails'
gem 'rails-i18n'
group :development do
gem 'annotate', '~> 2.4.1.beta'
gem 'nested_scaffold'
end
group :development, :test do
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
gem 'ruby-debug19'
gem 'linecache19'
gem 'factory_girl_rails', '1.4.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'capybara-webkit'
gem "launchy"
gem 'ZenTest'
#MAC OS Especific
gem 'rb-fsevent', '0.4.3.1', :require => false
gem 'growl', '1.0.3'
#Cucumber
gem 'cucumber-rails', '1.2.1', require: false
gem 'database_cleaner', '0.7.0'
end
group :production do
#gem 'pg', '0.12.2'
end
Thanks for you advanced.
missing this on spec_helper.rb
require "capybara/rspec"
Thanks https://github.com/jnicklas

Resources