activescaffold/active_scaffold — Issue #126: Running the ActiveScaffold Unit Tests
Author: softcraft-development
Created: 2012-01-27 17:44:38+00:00
State: open

Hi there. I'm trying to run the ActiveScaffold unit test suite. I've been poking around the ActiveScaffold code lately (I was working on upgrading it to Rails 3.2, but you beat me to it; thanks!), and I'd like to do that with test coverage to ensure I'm not breaking anything. However, I'm not able to run the test suite, even without any changes.

I have a clean copy of the latest ActiveScaffold master. I'm using RVM and a new gemset to ensure that I have a clean copy of the gems. I've installed Rails 3.2 (going to try 3.2.1 soon) plus all of the bundled gems. I'm using ruby-1.8.7-p174, though I've seen this same behaviour with 1.9.2 as well.

when I run `rake test` I get this:

> /Users/craig/Sites/active_scaffold_clean/test/bridges/company.rb:2:in `require': no such file to load -- active_record (LoadError)
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/company.rb:2
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/active_scaffold_dependent_protect_test.rb:2:in `require'
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/active_scaffold_dependent_protect_test.rb:2
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4
> rake aborted!

That makes a certain amount of sense to me, because Rails isn't in the Gemfile, so it looks like it's not loading the dependency.

However, when I hack in `gem "rails", "3.2.0"` into the gemfile and rerun `rake test`, I get this:

> /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/activerecord-3.2.0/lib/active_record/reflection.rb:373: undefined method `delegate' for ActiveRecord::Reflection::ThroughReflection:Class (NoMethodError)
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/company.rb:3:in `require'
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/company.rb:3
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/active_scaffold_dependent_protect_test.rb:2:in `require'
>	from /Users/craig/Sites/active_scaffold_clean/test/bridges/active_scaffold_dependent_protect_test.rb:2
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
>	from /Users/craig/.rvm/gems/ruby-1.8.7-p174@as2/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4
> rake aborted!

As best as I can tell, this odd error is caused by a loading issue with rails / active support. active_record/reflection seems to be loaded before Module#delegate gets included from active_support.

So, my question is, how do you run the unit tests? What setup do you have to make them work successfully?

Thanks,
Craig