I am creating automated tests for my rails app using rspec and factoryBot. In my case I am creating a company with a requirement of having a logo. Creating a company in the test is not a problem but if I try and modify the company outside of the test file I am getting an error message of
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
I have tried alternative upload methods but with no luck. Below is the factory for the company and the process I am using to create a company. This is not the exact code in my implementation as I am unable to share that but I have replicated it as much as I could.
If I manually test the code it works fine. It is only when running the code with rspec the error occurs.
factories.rb
FactoryBot.define do
factory :company do
name { 'Name' }
b_day { Date.today }
age { 1 }
logo { Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/support/logo.png')), 'image/png') }
end
end
companies_rake_spec.rb
describe "Company b_day today" do
it "Add 1 to company age" do
company1 = create(:company)
Rake::Task['companies:update_age'].invoke
company1_refresh = Company.where(id: company1.id).first
expect(company1_refresh.age).to eq(company1.age + 1)
end
end
company.rake
namespace :companies do
desc "TODO"
task update_age: :environment do
Company.find_each do | company |
if (company.b_day.day == Date.today.day) && (company.b_day.month == Date.today.month)
company.age += 1
puts company.inspect
company.save!
end
end
end
end
end
console
#<Company id: 34, name: "Name", b_day: 2018-11-13, age: 2, logo: "1cbeef36f13a8a88db0c37fa30da6ffd.png">
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
stacktrace
Failures:
1) companies:update_age age + 1
Failure/Error: company.save!
ActiveRecord::RecordInvalid:
Validation failed: Logo can't be blank
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/validations.rb:78:in `raise_validation_error'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/validations.rb:50:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:324:in `block in save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:211:in `transaction'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/transactions.rb:324:in `save!'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/suppressor.rb:45:in `save!'
# ./lib/tasks/companies.rake:54:in `block (3 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `block (2 levels) in find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:59:in `block in find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:121:in `block in find_in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:214:in `block in in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:198:in `loop'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:198:in `in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:120:in `find_in_batches'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/relation/batches.rb:58:in `find_each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/activerecord-5.0.7/lib/active_record/querying.rb:9:in `find_each'
# ./lib/tasks/companies.rake:8:in `block (2 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
# /Users/mac/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
# ./spec/lib/tasks/companies_rake_spec.rb:122:in `block (3 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:254:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:254:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:500:in `block in with_around_and_singleton_context_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:457:in `block in with_around_example_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:464:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:342:in `call'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-rails-3.8.0/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:447:in `instance_exec'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:373:in `execute_with'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:606:in `block (2 levels) in run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:342:in `call'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:607:in `run_around_example_hooks_for'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:464:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:457:in `with_around_example_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:251:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:629:in `block in run_examples'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:625:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:625:in `run_examples'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:591:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `block in run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/example_group.rb:592:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `block (3 levels) in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `map'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:116:in `block (2 levels) in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/configuration.rb:1989:in `with_suite_hooks'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:111:in `block in run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/reporter.rb:74:in `report'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:110:in `run_specs'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:87:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:71:in `run'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/mac/.rvm/gems/ruby-2.5.1/gems/rspec-core-3.8.0/exe/rspec:4:in `<top (required)>'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/rspec:23:in `load'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/rspec:23:in `<main>'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
# /Users/mac/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'
How to properly do model testing with ActiveStorage in rails?
Using the info from there and adapting to your specifics, try the following factory:
FactoryBot.define do
factory :company do
name { 'Name' }
b_day { Date.today }
age { 1 }
after(:build) do |company|
company.logo.attach(io: File.open(Rails.root.join('spec', 'support', 'logo.jpeg')), filename: 'logo.jpeg', content_type: 'image/jpeg')
end
end
end
EDIT:
You may also need to add this to your config/environments/test.rb file:
config.active_storage.service = :test
Related
I want to enumerate through the contents of a tar file in alphabetical order of the filenames contained in the tar file. The following dies with the error Error: closed Gem::Package::TarReader::Entry.
Gem::Package::TarReader.new io do |tar|
tar.sort_by{ |e| e.full_name }.each.map do |tar_entry|
file_contents = tar_entry.read
# more code here, not shown for clarity
file_contents
end
end
Here is the stack trace:
Liquid Exception: closed Gem::Package::TarReader::Entry in /var/sitesUbuntu/www.mslinn.com/_drafts/2020-09-28-using-aws-cloud9-with-jump-server.html
jekyll 3.8.7 | Error: closed Gem::Package::TarReader::Entry
/usr/lib/ruby/2.7.0/rubygems/package/tar_reader/entry.rb:30:in `check_closed': closed Gem::Package::TarReader::Entry (IOError)
from /usr/lib/ruby/2.7.0/rubygems/package/tar_reader/entry.rb:133:in `read'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:14:in `block (2 levels) in untar_contents'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `each'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `each'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `map'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:13:in `block in untar_contents'
from /usr/lib/ruby/2.7.0/rubygems/package/tar_reader.rb:29:in `new'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:12:in `untar_contents'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:25:in `block in render'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:24:in `open'
from /var/sitesUbuntu/www.mslinn.com/_plugins/archive_display.rb:24:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:91:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
from /var/lib/gems/2.7.0/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:126:in `render_liquid'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:79:in `render_document'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/renderer.rb:62:in `run'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:479:in `render_regenerated'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:464:in `block (2 levels) in render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:463:in `each'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:463:in `block in render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:462:in `each_value'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:462:in `render_docs'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:191:in `render'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/site.rb:71:in `process'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/command.rb:28:in `process_site'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:65:in `build'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/build.rb:36:in `process'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `block in start'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `each'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:93:in `start'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
from /var/lib/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from /var/lib/gems/2.7.0/gems/jekyll-3.8.7/exe/jekyll:15:in `<top (required)>'
from /home/mslinn/gems/bin/jekyll:23:in `load'
from /home/mslinn/gems/bin/jekyll:23:in `<main>'
I just had to sort the result:
require 'rubygems/package'
File.open(tar_name, "rb") do |file|
Gem::Package::TarReader.new(file) do |tar|
return tar.each.map { |tar_entry|
if tar_entry.file?
file_contents = tar_entry.read.strip
"<div class='codeLabel'>#{tar_entry.full_name}</div><pre data-lt-active='false'>#{file_contents}</pre>"
else
""
end
}.sort_by{ |e| e.full_name }
end
end
Here is how I actually wrote the code in production:
def traverse_tar(tar_name)
require 'rubygems/package'
File.open(tar_name, "rb") do |file|
Gem::Package::TarReader.new(file) do |tar|
return tar.each.map { |entry|
if entry.file? then { :name => entry.full_name, :content => entry.read.strip } else nil end
}.compact.sort_by { |entry| entry[:name] }.map { |entry|
"<div class='codeLabel'>#{entry[:name]}</div><pre data-lt-active='false'>#{entry[:content]}</pre>"
}
end
end
end
I have a grape entity for a Contact model, which references User model twice:
class Contact < ApplicationRecord
belongs_to :user, foreign_key: :user_id
belongs_to :contact, class_name: 'User', foreign_key: :contact_id
def entity
Entity.new(self)
end
class Entity < Grape::Entity
expose :contact do
expose :id
expose :user, as: :inviter, merge: true, using: User::Entity
expose :contact, as: :invitee, merge: true, using: User::Entity
expose :status
end
end
end
When I get an endpoint which presents contact, I have the following error
ArgumentError:
wrong number of arguments (given 3, expected 0)
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:53:in `block in merge_strategy'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:19:in `merge!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure/output_builder.rb:19:in `add'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:62:in `block (2 levels) in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:108:in `block in with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/options.rb:102:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:107:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:60:in `block in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each_with_object'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:61:in `block (2 levels) in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:108:in `block in with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/options.rb:102:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/base.rb:107:in `with_attr_path'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:60:in `block in serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each_with_object'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/exposure/nesting_exposure.rb:59:in `serializable_value'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-entity-0.6.1/lib/grape_entity/entity.rb:473:in `serializable_hash'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/formatter/json.rb:6:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `block in build_formatted_response'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `collect'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:44:in `build_formatted_response'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/formatter.rb:28:in `after'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:34:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:31:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:31:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:34:in `block in call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:33:in `catch'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/error.rb:33:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/middleware/base.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/endpoint.rb:224:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/endpoint.rb:218:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router/route.rb:72:in `exec'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:119:in `process_route'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:74:in `block in identity'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:93:in `transaction'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:72:in `identity'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:57:in `block in call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:135:in `with_optimization'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/router.rb:56:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:119:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:45:in `call!'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/grape-0.19.1/lib/grape/api.rb:40:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/conditional_get.rb:25:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:36:in `call_app'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `block in call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/rack/logger.rb:24:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/railties-5.0.1/lib/rails/engine.rb:522:in `call'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request'
# /home/doimhneacht/.rvm/gems/ruby-2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:124:in `request'
# ./spec/requests/contacts_spec.rb:39:in `block (4 levels) in <top (required)>'
How to make it include User entities for both inviter and invitee in the Contact entity?
describe "The Original Method list_instances_of_with_resources_change" do
it "Should execute successfully and return Array of Google::Apis::DnsV1::Change object" do
expect{subject_class::list_instances_of_with_resources_change("Dummy ID",custom_params)}.to raise_error
end
end
The error which I am getting.
2) Testing Change Resource : The Original Method list_instances_of_with_resources_change Should execute successfully and return Array of Google::Apis::DnsV1::Change object
Failure/Error: response = client.send("list_changes", project, managed_zone, max_results:max_results, page_token:page_token, sort_by:sort_by, sort_order:sort_order)
Google::Apis::ClientError:
invalid: Invalid value for project: graphite-development1
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:211:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/api_command.rb:102:in `check_status'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:179:in `process_response'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:286:in `execute_once'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:107:in `block (2 levels) in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:104:in `block in execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/http_command.rb:96:in `execute'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/lib/google/apis/core/base_service.rb:345:in `execute_or_queue_command'
# /home/vivekkumarmishra17/.rvm/gems/ruby-2.3.0/gems/google-api-client-0.9.4/generated/google/apis/dns_v1/service.rb:191:in `list_changes'
# ./lib/puppet_x/puppetlabs/google_cloud_dns/provider.rb:165:in `list_instances_of_change'
# ./spec/unit/neg_google_cloud_dns_change_spec.rb:24:in `block (2 levels) in <top (required)>'
I am using ruby "2.0.0" and 'rails', '~> 4.0.0' and 'rspec-rails', "2.14.2" ( quoted from the Gemfile. I have two entirely different apps and I am getting the same error on both.
I used the scaffold generator for my controller. So it also generated my controller tests. In particular the update action broke right away.
Test code
describe "PUT update" do
describe "with valid params" do
it "updates the requested product" do
product = Product.create! valid_attributes
# Assuming there are no other products in the database, this
# specifies that the Product created on the previous line
# receives the :update_attributes message with whatever params are
# submitted in the request.
expect_any_instance_of(Product).to receive(:update).with({ "product_name" => "Product 1" })
put :update, {:id => product.to_param, :product => { "product_name" => "Product 1" }}, valid_session
end
Controller code:
# PATCH/PUT /products/1
# PATCH/PUT /products/1.json
def update
respond_to do |format|
if #product.update_attributes(product_params)
format.html { redirect_to #product, notice: 'Product was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: #product.errors, status: :unprocessable_entity }
end
end
end
So i run my test and:
1) ProductsController PUT update with valid params updates the requested product
Failure/Error: Unable to find matching line from backtrace
Exactly one instance should have received the following message(s) but didn't: update
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-mocks-3.0.2/lib/rspec/mocks/any_instance/recorder.rb:92:in `verify'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-mocks-3.0.2/lib/rspec/mocks/space.rb:69:in `block in verify_all'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-mocks-3.0.2/lib/rspec/mocks/space.rb:69:in `each_value'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-mocks-3.0.2/lib/rspec/mocks/space.rb:69:in `verify_all'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-mocks-3.0.2/lib/rspec/mocks.rb:45:in `verify'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/mocking_adapters/rspec.rb:21:in `verify_mocks_for_rspec'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:354:in `verify_mocks'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:345:in `run_after_example'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:163:in `block in run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `call'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-rails-3.0.1/lib/rspec/rails/example/controller_example_group.rb:174:in `block (2 levels) in <module:ControllerExampleGroup>'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `call'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:68:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:294:in `instance_exec'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `call'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:432:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/hooks.rb:485:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:303:in `with_around_example_hooks'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example.rb:145:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:494:in `block in run_examples'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:490:in `map'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:490:in `run_examples'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:457:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `block in run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `map'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `block in run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `map'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/example_group.rb:458:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `map'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:112:in `block in run_specs'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/reporter.rb:54:in `report'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:108:in `run_specs'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:86:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
# /Users//.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-3.0.2/exe/rspec:4:in `<top (required)>'
# /Users//.rvm/gems/ruby-2.0.0-p353/bin/rspec:23:in `load'
# /Users//.rvm/gems/ruby-2.0.0-p353/bin/rspec:23:in `<main>'
# /Users//.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
# /Users//.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Finished in 0.27911 seconds (files took 1.85 seconds to load)
16 examples, 1 failure
Failed examples:
rspec ./spec/controllers/products_controller_spec.rb:90 # ProductsController PUT update with valid params updates the requested product
I am posting the response after this, the problem is solved:
So a good friend took a glance at my code and he pointed out that:
expect_any_instance_of(Product).to receive(:update).with({ "product_name" => "Product 1" })
Is trying to receive an update from the model. There is no update method on the model:
class Product < ActiveRecord::Base
before_validation :normalize_name, on: :create
validates :product_name, presence: true, uniqueness: true
validates :product_cost, presence: true, :numericality => { :greater_than_or_equal_to => 1 }
protected
def normalize_name
self.product_name = self.product_name.downcase.titleize
end
end
So the fix consists in adding :update_attributes to the tests in order to make the call to the model, instead as a controller action as it was doing before.
expect_any_instance_of(Product).to receive(:update_attributes).with({ "product_name" => "Product 1" })
And now the test pass.
I hope this helps. I am fairly new to Rails, so please bear with any inaccuracies or errors. Feel free to report typos or corrections, they are always welcome.
When I try to lauch webbrick from my terminal using rails server, This is what I get and webbrick shuts down, what could be the problem.
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
Following the shutdown I get this huge error which absolutely makes no sense to me.
/Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:229:in `default_controller_and_action': missing :controller (ArgumentError)
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:116:in `normalize_options!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:64:in `initialize'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:601:in `map_method'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:562:in `get'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:14:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
from /Users/Fulcrum/Sites/recrea8/config/routes.rb:1:in `<top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Fulcrum/Sites/recrea8/config/environment.rb:5:in `<top (required)>'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `require'
from /Users/Fulcrum/Sites/recrea8/config.ru:3:in `block in <main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `new'
from /Users/Fulcrum/Sites/recrea8/config.ru:in `<main>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Users/Fulcrum/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This is my route.rb
Recrea8::Application.routes.draw do
resources :sessions
resources :users
resources :categories
resources :characters
resources :industries
resources :nationalities
resources :personalities
resources :project_types
resources :projects
get 'logout', 'sessions#destroy', as: 'logout'
match ':controller(/:action(/:id))', :via => [:get, :post]
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'users#new'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
Try to change lines:
#get 'logout', 'sessions#destroy', as: 'logout'
get 'logout' => 'sessions#destroy', as: 'logout'
And
#root 'users#new'
root to: 'users#new'