Skip to content

Instantly share code, notes, and snippets.

@stepheneb
Created April 22, 2010 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stepheneb/375634 to your computer and use it in GitHub Desktop.
Save stepheneb/375634 to your computer and use it in GitHub Desktop.
I'm getting these errors running: rake spec on the Investigations emb-
test branch -- but I expect problems like this might occur elsewhere.
When I run the new DataCollector controllers spec test on it's own I
get just what I expect -- one failing test (the bug the editing in
Java isn't working because part of the rendered otml is missing).
$ spec spec/controllers/embeddable/data_collectors_controller_spec.rb -u
......F...
1)
'Embeddable::DataCollectorsController GET edit with mime type of otml renders the requested data_collector as otml without error' FAILED
Expected at least 1 element matching "otrunk", found 0.
<false> is not true.
./spec/controllers/embeddable/data_collectors_controller_spec.rb:94:
Finished in 38.551741 seconds
11 examples, 1 failure
However when I run all the spec tests with rake I get 4 errors -- 3 are strange errors:
2) No child processes
3) wrong number of arguments (0 for 1)
4) wrong number of arguments (0 for 1)
Here's the detailed output:
1)
'Embeddable::DataCollectorsController GET edit with mime type of otml renders the requested data_collector as otml without error' FAILED
Expected at least 1 element matching "otrunk", found 0.
<false> is not true.
./spec/controllers/embeddable/data_collectors_controller_spec.rb:94:
2)
ActionView::TemplateError in 'Embeddable::DataCollectorsController GET edit assigns the requested data_collector as @data_collector'
No child processes
On line #133 of app/views/layouts/application.html.haml
130: #under_footer
131: - if current_user.has_role?('admin')
132: = display_system_info
133:
134: / once somebody is logged in,they should open outside the iframe.
135: - unless current_user.anonymous?
136: :javascript
vendor/gems/mojombo-grit-1.1.1/lib/open3_detach.rb:33:in `waitpid'
vendor/gems/mojombo-grit-1.1.1/lib/open3_detach.rb:33:in `popen3'
vendor/gems/mojombo-grit-1.1.1/lib/grit/git.rb:75:in `sh'
vendor/gems/mojombo-grit-1.1.1/lib/grit/git.rb:67:in `run'
vendor/gems/mojombo-grit-1.1.1/lib/grit/git.rb:55:in `method_missing'
vendor/gems/mojombo-grit-1.1.1/lib/grit/git-ruby.rb:103:in `rev_parse'
vendor/gems/mojombo-grit-1.1.1/lib/grit/ref.rb:91:in `current'
vendor/gems/mojombo-grit-1.1.1/lib/grit/repo.rb:84:in `head'
app/helpers/application_helper.rb:65:in `git_repo_info'
app/helpers/application_helper.rb:46:in `display_system_info'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:88:in `capture'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:106:in `content_tag'
app/helpers/application_helper.rb:44:in `display_system_info'
app/views/layouts/application.html.haml:133:in `_run_haml_app47views47layouts47application46html46haml'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/example/controller_example_group.rb:233:in `render'
app/controllers/embeddable/data_collectors_controller.rb:89:in `edit'
haml (2.2.0) [v] lib/sass/plugin/rails.rb:19:in `process'
/spec/controllers/embeddable/data_collectors_controller_spec.rb:83
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `instance_eval'
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
rspec (1.3.0) lib/spec/example/example_methods.rb:37:in `execute'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:214:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `each'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:103:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:23:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `each'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `run'
rspec (1.3.0) lib/spec/runner/options.rb:152:in `run_examples'
rspec (1.3.0) lib/spec/runner/command_line.rb:9:in `run'
rspec (1.3.0) bin/spec:5
3)
ActionView::TemplateError in 'Embeddable::DataCollectorsController GET show assigns the requested data_collector as @data_collector'
wrong number of arguments (0 for 1)
On line #9 of app/views/shared/_embeddable_container.html.haml
6: %div{ :id => dom_id_for(component, :item), :class => 'item item_selectable '}
7: = render_show_partial_for(component)
8: - else
9: - view_class = teacher_only?(component) ? "teacher_only container_element" : "container_element"
10: %div{ :id => dom_id_for(component), :class => "container_element" }
11: = show_menu_for(component, options)
12: %div{ :id => dom_id_for(component, :item), :class => 'item item_selectable '}
app/helpers/application_helper.rb:993:in `teacher_only?'
app/helpers/application_helper.rb:993:in `teacher_only?'
app/views/shared/_embeddable_container.html.haml:9:in `_run_haml_app47views47shared47_embeddable_container46html46haml_locals_component_embeddable_container_object'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:17:in `render_partial'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:11:in `render_without_mock_proxy'
haml (2.2.0) [v] lib/haml/helpers.rb:77:in `non_haml'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:11:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
app/views/embeddable/data_collectors/show.html.haml:1:in `_run_haml_app47views47embeddable47data_collectors47show46html46haml'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/example/controller_example_group.rb:233:in `render'
app/controllers/embeddable/data_collectors_controller.rb:40:in `show'
haml (2.2.0) [v] lib/sass/plugin/rails.rb:19:in `process'
/spec/controllers/embeddable/data_collectors_controller_spec.rb:34
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `instance_eval'
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
rspec (1.3.0) lib/spec/example/example_methods.rb:37:in `execute'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:214:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `each'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:103:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:23:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `each'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `run'
rspec (1.3.0) lib/spec/runner/options.rb:152:in `run_examples'
rspec (1.3.0) lib/spec/runner/command_line.rb:9:in `run'
rspec (1.3.0) bin/spec:5
4)
ActionView::TemplateError in 'Embeddable::DataCollectorsController GET index runs without error'
wrong number of arguments (0 for 1)
On line #9 of app/views/shared/_embeddable_container.html.haml
6: %div{ :id => dom_id_for(component, :item), :class => 'item item_selectable '}
7: = render_show_partial_for(component)
8: - else
9: - view_class = teacher_only?(component) ? "teacher_only container_element" : "container_element"
10: %div{ :id => dom_id_for(component), :class => "container_element" }
11: = show_menu_for(component, options)
12: %div{ :id => dom_id_for(component, :item), :class => 'item item_selectable '}
app/helpers/application_helper.rb:993:in `teacher_only?'
app/helpers/application_helper.rb:993:in `teacher_only?'
app/views/shared/_embeddable_container.html.haml:9:in `_run_haml_app47views47shared47_embeddable_container46html46haml_locals_component_embeddable_container_object'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:17:in `render_partial'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:11:in `render_without_mock_proxy'
haml (2.2.0) [v] lib/haml/helpers.rb:77:in `non_haml'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:11:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
app/views/embeddable/data_collectors/index.html.haml:3:in `_run_haml_app47views47embeddable47data_collectors47index46html46haml'
app/views/embeddable/data_collectors/index.html.haml:2:in `each'
app/views/embeddable/data_collectors/index.html.haml:2:in `_run_haml_app47views47embeddable47data_collectors47index46html46haml'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
haml (2.2.0) [v] lib/haml/helpers/action_view_mods.rb:13:in `render_without_mock_proxy'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/extensions/action_view/base.rb:27:in `render'
/Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/example/controller_example_group.rb:233:in `render'
app/controllers/embeddable/data_collectors_controller.rb:26:in `index'
haml (2.2.0) [v] lib/sass/plugin/rails.rb:19:in `process'
/spec/controllers/embeddable/data_collectors_controller_spec.rb:26
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `instance_eval'
rspec (1.3.0) lib/spec/example/example_methods.rb:40:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
rspec (1.3.0) lib/spec/example/example_methods.rb:37:in `execute'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:214:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `each'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:212:in `run_examples'
rspec (1.3.0) lib/spec/example/example_group_methods.rb:103:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:23:in `run'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `each'
rspec (1.3.0) lib/spec/runner/example_group_runner.rb:22:in `run'
rspec (1.3.0) lib/spec/runner/options.rb:152:in `run_examples'
rspec (1.3.0) lib/spec/runner/command_line.rb:9:in `run'
rspec (1.3.0) bin/spec:5
Finished in 88.655267 seconds
1312 examples, 4 failures, 681 pending
Hmmm ... taking a look at the 'wrong number of arguments (0 for 1)' problem here's what I've found out: when
running the tests using: 'rake spec' ApplicationHelper is mixed into Embeddable::DataCollector and adds the
method teacher_only? -- which does indeed require an argument.
Here's the only class ancestors when examining a Embeddable::DataCollector instance in script/console:
>> puts Embeddable::DataCollector.class.ancestors.join("\n")
Class
Mocha::ClassMethods
ActiveSupport::Dependencies::ClassConstMissing
Module
Mocha::ModuleMethods
Attributes
ActiveSupport::Deprecation::ClassMethods
ActiveSupport::Dependencies::ModuleConstMissing
ActiveSupport::CoreExtensions::Module
Object
Clipboard
JnlpHelper
OtmlHelper
Mocha::ObjectMethods
ERB::Util
PP::ObjectMixin
JSON::Ext::Generator::GeneratorMethods::Object
ActiveSupport::Dependencies::Loadable
InstanceExecMethods
Base64::Deprecated
Base64
Kernel
There are a whole bunch of things that shouldn't be there like: 'Clipboard, JnlpHelper, OtmlHelper'
We should figure out why this is happening and change it.
But I added a debugger statement in the partial: _embeddable_container.html.haml and stepping into
teacher_only?(component) showed the error happens here:
[988, 997] in /Users/stephen/dev/test/rites/app/helpers/application_helper.rb
988 # is a component viewable only by teacher?
989 # cascading logic.
990 # TODO: generic container-based method-forwarding mechanism
991 #
992 def teacher_only?(thing)
=> 993 if (thing.respond_to?("teacher_only?") && thing.teacher_only?)
994 return true;
995 end
996 if (thing.respond_to?("parent"))
997 while (thing = thing.parent)
'thing' is an Embeddable::DataCollector instance and unfortunately this evaluates to true:
thing.respond_to?("teacher_only?")
Because the error then happens here: thing.teacher_only?
Here's the MUCH longer list of class ancestors when examining a Embeddable::DataCollector instance in the
debugger when running the spec tests with: rake spec -- ApplicationHelper is mixed in -- which seems insane!
(rdb:1) Kernel.puts thing.class.ancestors.join("\n")
Embeddable::DataCollector
Rails::Plugin::DefaultValueForPlugin::InstanceMethods
Cloneable
Changeable
Foo::Acts::Replicatable::InstanceMethods
ActiveRecord::Base
Spec::Rails::Extensions::ActiveRecord::InstanceMethods
SendUpdateEvents
CC::HAS::Settings
DeepCloning
Foo::Acts::Replicatable
ActiveRecord::Acts::List
ActiveRecord::Extensions::SqlGeneration
WillPaginate::Finder
ActiveRecord::Aggregations
ActiveRecord::Transactions
ActiveRecord::Reflection
ActiveRecord::Batches
ActiveRecord::Calculations
ActiveRecord::Serialization
ActiveRecord::AutosaveAssociation
ActiveRecord::NestedAttributes
ActiveRecord::Associations
ActiveRecord::AssociationPreload
ActiveRecord::NamedScope
ActiveRecord::Callbacks
ActiveRecord::Observing
ActiveRecord::Timestamp
ActiveRecord::Dirty
ActiveRecord::AttributeMethods
ActiveRecord::Locking::Optimistic
ActiveRecord::Locking::Pessimistic
ActiveSupport::Callbacks
ActiveRecord::Validations
Object
ApplicationHelper
AuthenticatedSystem
AuthenticatedTestHelper
Spec::Mocks::Methods
Mocha::ObjectMethods
Clipboard
JnlpHelper
OtmlHelper
ERB::Util
PP::ObjectMixin
JSON::Ext::Generator::GeneratorMethods::Object
ActiveSupport::Dependencies::Loadable
InstanceExecMethods
Base64::Deprecated
Base64
Spec::DSL::Main
Spec::Example::ArgsAndOptions
Kernel
hmmm ... more clues
I ended up here in the debugger
[10, 19] in /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb
10 # It's important that loading files (or choosing not to) stays the
11 # responsibility of the ExampleGroupRunner. Some implementations (like)
12 # the one using DRb may choose *not* to load files, but instead tell
13 # someone else to do it over the wire.
14 files.each do |file|
=> 15 load file
16 end
17 end
After this loop finishes the following is true:
Embeddable::DataCollector.instance_methods.include?("teacher_only?")
This is the loop that is loading all 189 spec files.
I set a Display command in the debugger to print out useful info every step through the loop:
(rdb:1) Display [Embeddable::DataCollector.instance_methods.include?("teacher_only?"), files.index(file), file].inspect
And then pressed 'n' and return many times and found this:
(rdb:1) n
1: [Embeddable::DataCollector.instance_methods.include?("teacher_only?"), files.index(file), file].inspect = [false, 185, "spec/helpers/application_helper_spec.rb"]
[10, 19] in /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb
10 # It's important that loading files (or choosing not to) stays the
11 # responsibility of the ExampleGroupRunner. Some implementations (like)
12 # the one using DRb may choose *not* to load files, but instead tell
13 # someone else to do it over the wire.
14 files.each do |file|
=> 15 load file
16 end
17 end
18
19 def run
/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15
load file
(rdb:1) n
1: [Embeddable::DataCollector.instance_methods.include?("teacher_only?"), files.index(file), file].inspect = [true, 186, "spec/helpers/admin/projects_helper_spec.rb"]
[10, 19] in /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb
10 # It's important that loading files (or choosing not to) stays the
11 # responsibility of the ExampleGroupRunner. Some implementations (like)
12 # the one using DRb may choose *not* to load files, but instead tell
13 # someone else to do it over the wire.
14 files.each do |file|
=> 15 load file
16 end
17 end
So ... after loading 185 (of 189) files loading: 'spec/helpers/application_helper_spec.rb' mixes the ApplicationHelper methods.
In fact their mixed in to every Object because they are mixed into Object itself:
Object.instance_methods.include?("teacher_only?") => true
There's not much in spec/helpers/application_helper_spec.rb:
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include AuthenticatedTestHelper
describe ApplicationHelper do
describe "title" do
it "should set @page_title" do
title('hello').should be_nil
@page_title.should eql('hello')
end
it "should output container if set" do
title('hello', :h2).should have_tag('h2', 'hello')
end
end
end
Evidently self is Object when that file is loaded and mixes the methods in ApplicationHelper into Object -- not useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment