Can't Modify Frozen Class & Can't Determine Why Class is Frozen - ruby

I'm working on a Ruby on Trailblazer API and I keep getting this error when I run my Rspec test suite:
FrozenError: can't modify frozen #<Class:NotificationCenter>: NotificationCenter
I can't seem to determine where or how the class is being frozen. Find the file and stacktrace below for context:
sftp.rb File:
# frozen_string_literal: true
require 'grape'
require 'concepts'
class NotificationCenter < NotificationCenter.superclass
module API ### <- failure occurs on this line ###
class Notifications < Grape::API
class Reports < Grape::API
class Failed < Grape::API
class Sftp < Grape::API
resource :sftp do
route_param :email do
desc 'send notification to a specific user when report has failed to upload to sftp'
params do
optional :test, type: Boolean, default: true
requires :email, type: String, coerce_with: Base64.method(:urlsafe_decode64)
requires :report_name, type: String
end
post do
result = run! Notification::Report::User, {}, 'email.cell' => Notification::Cell::Report::Failed::Sftp
handle! result
end
end
end
end
end
end
end
end
end
Stack trace:
An error occurred while loading ./spec/resources/notifications/statements/failed_spec.rb.
Failure/Error: module API
FrozenError:
can't modify frozen #<Class:NotificationCenter>: NotificationCenter
# ./app/resources/notifications/reports/failed/sftp.rb:7:in `<class:NotificationCenter>'
# ./app/resources/notifications/reports/failed/sftp.rb:6:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./app/resources/notifications/reports/failed.rb:7:in `glob'
# ./app/resources/notifications/reports/failed.rb:7:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./app/resources/notifications/reports.rb:7:in `glob'
# ./app/resources/notifications/reports.rb:7:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./app/resources/notifications.rb:7:in `glob'
# ./app/resources/notifications.rb:7:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./app/resources.rb:4:in `glob'
# ./app/resources.rb:4:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./app.rb:9:in `<top (required)>'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `block in require'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:291:in `require'
# ./spec/resources/notifications/statements/failed_spec.rb:3:in `<top (required)>'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:285:in `load'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:285:in `block in load'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:257:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.2.8.1/lib/active_support/dependencies.rb:285:in `load'
As I said earlier, I can't seem to determine where or how the class is being frozen. I traversed the stack trace to try and determine where the NotificationCenter class had been defined the very first time. As far as I can tell, the sftp.rb file above, where the error is occuring, is the first time the class is being defined. I put a binding.pry just below class NotificationCenter < NotificationCenter.superclass, and ran NotificationCenter.frozen?, which returned true.
This is strange to me because as the class is being defined, the very first time it even comes into existence (as far as I can tell), it is already frozen. Additionally, there is not a single .freeze in the entire repository. So the class is seemingly being frozen by some other means.
Does anyone have any idea why this might occur?

Related

need basic setup to test a website on real android device (chrome browser) using ruby appium framework

I am trying to setup a basic framework with Cucumber, Appium and Ruby. I am getting errors when I run the basic script. I am testing web app on chrome browser for Android device. I can't figure out what's wrong with the setup. Appium Desktop for windows is running in the background
(Appium v1.12.1)
My env.rb
require "appium_lib"
def caps
{caps:
{
deviceName: "Android_Device",
platformName: "Android",
browserName: "Chrome",
newCommandTimeout: "3600"
}
}
end
Appium::Driver.new(caps, true)
Appium.promote_appium_methods Object
My hooks.rb file
Before do
$driver.start_driver
end
After do
sleep 3
$driver.driver.quit
end
My Step Definition file
Given(/^I log on to the site with the following:$/) do |table|
p "it works"
end
My feature file
Given I log on to the site with the following:
|site|
|ABC|
I am expecting the feature/scenario to pass
Actual Result-
C:\Users\Documents\xyz\abc (master)
λ cucumber features\Simple_POC.feature --tags #run
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
cannot load such file -- 2.5/rubyeventmachine (LoadError)
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/eventmachine-1.2.7-x64-mingw32/lib/rubyeventmachine.rb:2:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/eventmachine-1.2.7-x64-mingw32/lib/eventmachine.rb:8:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/faye-websocket-0.10.7/lib/faye/websocket.rb:10:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.0.4/lib/appium_lib_core/common/ws/websocket.rb:15:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.0.4/lib/appium_lib_core/common.rb:21:in `require_relative'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.0.4/lib/appium_lib_core/common.rb:21:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.0.4/lib/appium_lib_core.rb:18:in `require_relative'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib_core-3.0.4/lib/appium_lib_core.rb:18:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib-10.2.0/lib/appium_lib/appium.rb:5:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib-10.2.0/lib/appium_lib.rb:10:in `require_relative'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/appium_lib-10.2.0/lib/appium_lib.rb:10:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
C:/Users/Documents/xyz/abc/features/support/env.rb:1:in `<top (required)>'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/registry_and_more.rb:107:in `load'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/glue/registry_and_more.rb:107:in `load_code_file'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:144:in `load_file'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:85:in `block in load_files!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:84:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime/support_code.rb:84:in `load_files!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:272:in `load_step_definitions'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:68:in `run!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
C:/Ruby25-x64/bin/cucumber:23:in `load'
C:/Ruby25-x64/bin/cucumber:23:in `<main>'
was able to resolve the issue by doing the following -
1) gem uninstall eventmachine
2) gem install eventmachine --platform ruby
Tried few other solutions but the only one which worked are the above 2 steps.
Might help someone in the future

How do I add a method to ActiveRecord::Batches?

I was trying to add my custom implementation for ActiveRecordss find_in_batches method. First, I tried to monkeypatch the corresponding module:
module ActiveRecord
module Batches
def find_in_batches2
end
end
end
Task.find_in_batches2 do |group|
end
But ruby said:
NoMethodError: undefined method `find_in_batches2' for Task (call 'Task.connection' to establish a connection):Class
/home/yuri/.gem/ruby/2.1.5/gems/activerecord-4.2.0/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
/srv/http/tm/Rakefile:15:in `<top (required)>'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/yuri/.gem/ruby/2.1.5/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
-e:1:in `<main>'
Then I tried following this answer, to no avail. What am I doing wrong and why is it so hard?
Here is the solution:
ActiveRecord::Batches.module_eval do
def find_in_batches2
end
end
ActiveRecord::Querying.module_eval do
delegate :find_in_batches2, :to => :all
end
Don't forget to implement find_in_batches2.

Ruby: Rspec 2.14.1 on ruby 1.9.1 compatibility

Before anything, I know 1.9.1 (1.9.1-p243 specifically) is old and broken, but we have an app with a pretty strict dependency on it.
First off, is there a list of rspec-supported rubies?
Secondly, when putting anything in a describe block in a spec, I get an error uninitialized constant BasicObject::Class (NameError).
With this spec:
require_relative 'rspec_basic_object_test'
describe RspecBasicObjectTest do
before :each do
#obj = RspecBasicObjectTest.new
end
it 'returns something' do
#obj.foo.should == "foo"
end
end
and this ruby file:
class RspecBasicObjectTest
attr_reader :foo
def initialize
#foo = "foo"
end
end
I get:
dlampa#ubuntu:~/code/mine$ rspec rspec_basic_object_test_spec.rb
/home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/syntax.rb:74:in `block in enable_should': uninitialized constant BasicObject::Class (NameError)
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/syntax.rb:28:in `class_eval'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/syntax.rb:28:in `enable_should'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb:34:in `syntax='
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb:52:in `<module:Mocks>'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb:2:in `<module:RSpec>'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/configuration.rb:1:in `<top (required)>'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks/framework.rb:34:in `<top (required)>'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-mocks-2.14.6/lib/rspec/mocks.rb:1:in `<top (required)>'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/mocking/with_rspec.rb:1:in `<top (required)>'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/rubies/ruby-1.9.1-p243/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:388:in `mock_with'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:278:in `mock_framework'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:884:in `configure_mock_framework'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:280:in `ensure_example_groups_are_configured'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:295:in `set_it_up'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:245:in `subclass'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:232:in `describe'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/dsl.rb:18:in `describe'
from /home/dlampa/code/mine/rspec_basic_object_test_spec.rb:3:in `<top (required)>'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `each'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:22:in `run'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /home/dlampa/.rvm/gems/ruby-1.9.1-p243#rspec-test/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
Anyone else run into this? Or am I just missing something obvious in rspec's README that says 1.9.1 is old and broken, why are you using it?

ActiveRecord::AdapterNotSpecified error when running rspec with rails 4.1

I have not been able to find this exact error anywhere else on Google or on stackoverflow.
I am running Rails 4.1.0 and rspec-rails 3.0.0.beta2
When trying to run $rspec, I get the following error:
DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:development) instead. (called from <top (required)> at /Users/sam/code/rails/innovacert/spec/spec_helper.rb:4)
/Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection': 'development' database is not configured. Available: ["test"] (ActiveRecord::AdapterNotSpecified)
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:240:in `resolve_string_connection'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:267:in `resolve_hash_connection'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:228:in `resolve_connection'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:152:in `resolve'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:164:in `block in resolve_all'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:163:in `each'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:163:in `resolve_all'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_handling.rb:69:in `resolve'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/core.rb:46:in `configurations='
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/core.rb:48:in `block in <module:Core>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/concern.rb:120:in `class_eval'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/concern.rb:120:in `append_features'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/base.rb:297:in `include'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/base.rb:297:in `<class:Base>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/base.rb:282:in `<module:ActiveRecord>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/base.rb:23:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails/extensions/active_record/base.rb:25:in `<module:Extensions>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails/extensions/active_record/base.rb:4:in `<module:Rails>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails/extensions/active_record/base.rb:2:in `<module:RSpec>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails/extensions/active_record/base.rb:1:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails/extensions.rb:1:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-rails-3.0.0.beta2/lib/rspec/rails.rb:10:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:247:in `require'
from /Users/sam/code/rails/innovacert/spec/spec_helper.rb:4:in `<top (required)>'
from /Users/sam/code/rails/innovacert/spec/validators/rut_validator_spec.rb:1:in `require'
from /Users/sam/code/rails/innovacert/spec/validators/rut_validator_spec.rb:1:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/configuration.rb:932:in `load'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/configuration.rb:932:in `block in load_spec_files'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/configuration.rb:932:in `each'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/configuration.rb:932:in `load_spec_files'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/command_line.rb:21:in `run'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/runner.rb:100:in `run'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/lib/rspec/core/runner.rb:31:in `invoke'
from /Users/sam/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.0.beta2/exe/rspec:4:in `<top (required)>'
from /Users/sam/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `load'
from /Users/sam/.rvm/gems/ruby-2.1.1/bin/rspec:23:in `<main>'
from /Users/sam/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/sam/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
The error is being generated from a "require 'rspec/rails'" in spec_helper.rb.
I don't understand why this is happening as I have my test database configured properly in database.yml:
default: &default
host: localhost
adapter: postgresql
encoding: unicode
pool: 5
timeout: 5000
development:
<<: *default
database: innovacert_development
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASS'] %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: innovacert_test
username: sam
password:
From this line:
/Users/sam/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection': 'development' database is not configured. Available: ["test"] (ActiveRecord::AdapterNotSpecified)
IT would appear that rspec is trying to look for a database called :development. Yet in spec_helper.rb I explicitly define:
ENV["RAILS_ENV"] ||= "test"
I have used pry to take a look at this variable and it is definitely being assigned as 'test'.
Why is rspec failing?

Cucumber + Minitest Error

I've started to use Cucumber and wrote a simple test before the code implementation and cucumber said that minitest required. How can i require minitest in cucumber and how or in which file minitest should be required? Thanks in advance.
This is my error log:
Warning: you should require 'minitest/autorun' instead.
From C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/test/unit/assertions.rb:1:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:17:in `rescue in rescue in <top (required)>'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:12:in `rescue in <top (required)>'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/rb_support/rb_language.rb:9:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/options.rb:3:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/configuration.rb:2:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:12:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/bin/cucumber:11:in `<top (required)>'
C:/Ruby200/bin/cucumber:23:in `load'
C:/Ruby200/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From C:/Ruby200/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:670:in `<class:Runner>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:255:in `<module:Unit>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:9:in `<module:Test>'
C:/Ruby200/lib/ruby/2.0.0/test/unit.rb:8:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb:2:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/runtime.rb:23:in `initialize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:44:in `new'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/lib/cucumber/cli/main.rb:44:in `execute!'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/cucumber-1.3.2/bin/cucumber:13:in `<top (required)>'
C:/Ruby200/bin/cucumber:23:in `load'
C:/Ruby200/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
The particular error you are getting was a bug in cucumber and has been fixed in the latest release of cucumber 1.3.3.
You will probably also need something like this:
require 'minitest'
module MiniTestAssertions
def self.extended(base)
base.extend(MiniTest::Assertions)
base.assertions = 0
end
attr_accessor :assertions
end
World(MiniTestAssertions)
in your features/support/ directory.
Please see cucumber issues: #489 & 456

Resources