New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to avoid the *_PARENT constants. #95

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@jviney
Contributor

jviney commented Jan 27, 2012

No description provided.

@bmabey

This comment has been minimized.

Contributor

bmabey commented Jan 27, 2012

Nice, thanks for doing that! Do the tests pass for you? (bundle exec rake) I am getting a uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter error. Here is the full stack trace:

(in /Users/bmabey/Programming/ruby/database_cleaner)
** Invoke default (first_time)
** Invoke spec (first_time)
** Execute spec
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter (NameError)
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
    from ./spec/database_cleaner/active_record/truncation_spec.rb:8
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `load'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load_files'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run'
    from /Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/bin/spec:5
rake aborted!
Command /Users/bmabey/Developer/.rvm/rubies/ruby-1.8.7-p248/bin/ruby -I"lib:lib:spec"  "/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/bin/spec" "spec/database_cleaner/active_record/base_spec.rb" "spec/database_cleaner/active_record/transaction_spec.rb" "spec/database_cleaner/active_record/truncation_spec.rb" "spec/database_cleaner/base_spec.rb" "spec/database_cleaner/configuration_spec.rb" "spec/database_cleaner/couch_potato/truncation_spec.rb" "spec/database_cleaner/data_mapper/base_spec.rb" "spec/database_cleaner/data_mapper/transaction_spec.rb" "spec/database_cleaner/data_mapper/truncation_spec.rb" "spec/database_cleaner/generic/base_spec.rb" "spec/database_cleaner/generic/truncation_spec.rb" "spec/database_cleaner/mongo_mapper/base_spec.rb" "spec/database_cleaner/mongo_mapper/truncation_spec.rb" "spec/database_cleaner/sequel/base_spec.rb" "spec/database_cleaner/sequel/transaction_spec.rb" "spec/database_cleaner/sequel/truncation_spec.rb" "spec/database_cleaner/shared_strategy_spec.rb"  failed
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/rake/spectask.rb:177
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:1112:in `verbose'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/gems/rspec-1.3.0/lib/spec/rake/spectask.rb:153
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/Users/bmabey/Developer/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/Users/bmabey/Developer/.rvm/rubies/ruby-1.8.7-p248/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248@global/gems/rake-0.8.7/bin/rake:31
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/bin/rake:19:in `load'
/Users/bmabey/Developer/.rvm/gems/ruby-1.8.7-p248/bin/rake:19
@jviney

This comment has been minimized.

Contributor

jviney commented Jan 27, 2012

Yeah I get the same. You'd have to alter active_record/truncation_spec.rb:8 to not reference all those constants, because they're now only defined if they were already loaded.

Perhaps this isn't a great idea, as it means you can't test the content of those adapters without loading them. You could replace it with something like:

    constants.select { |c| p c; c =~ /Adapter$/ && const_get(c).superclass.name =~ /Abstract/ }.each do |adapter_constant|
      describe adapter_constant, "#truncate_table" do
        it "responds" do
          adapter.new("foo").should respond_to(:truncate_table)
        end
        it "should truncate the table"
      end
    end

But that doesn't seem great to me.

@etagwerker

This comment has been minimized.

Member

etagwerker commented Oct 14, 2014

@jviney Thanks for your pull request! I'm closing this because it was added in another pull request.

@etagwerker etagwerker closed this Oct 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment