Skip to content
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

can't test jpeg upload #47

Open
eostrom opened this issue Dec 26, 2010 · 2 comments
Open

can't test jpeg upload #47

eostrom opened this issue Dec 26, 2010 · 2 comments

Comments

@eostrom
Copy link

eostrom commented Dec 26, 2010

I don't really know where to file this; it's an interaction between env.js and Rails, basically, but it bit me in a Capybara context.

I have a Cucumber scenario that fills out a simple form, attaches a JPEG file to the form input, and submits it. It passes in Rack::Test, but when I submit the form using env.js, I get a lot of "Exception while dispatching events: super: no superclass method `require' for Object:Class" (stack trace below).

The offending line is in form.js:

            if (transfer_encoding === "base64") {
                Ruby.require("base64");
                content = Ruby.eval("lambda { |fn| Base64.encode64(File.read(fn)) }").call(array[i].filename);
            }

The 'require' is handled (intercepted?) by ActiveSupport::Dependencies::Loadable:

  def require(file, *)
    load_dependency(file) { super }
  end

... which fails because Object has no superclass, I guess.

I can imagine considering this a bug in Rails, but I'm not sure. It looks like I can work around it by uploading PNGs (this theory is untested), or at a mild performance cost, capybara-envjs could require base64 preemptively instead of waiting for form.js to do it. But maybe there's a better way?

I'm using, among other things, ruby 1.8.7-p299, rails 3.0.3, capybara 0.4.0, capybara-envjs 0.4.0, johnson 2.0.0pre3, envjs 0.3.8, and cucumber 0.10.0.

$ cucumber features/editing.feature:22
cucumber features/editing.feature:22
Using the default profile...
....... WARNING:    [Sun Dec 26 2010 14:29:20 GMT-0600 (CST)] {ENVJS} Exception while dispatching events: super: no superclass method `require' for Object:Class
oopse super: no superclass method `require' for Object:Class
undefined
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in `load_dependency'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:in `call'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:in `__send__'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/johnson-2.0.0.pre3/lib/johnson/tracemonkey/js_land_proxy.rb:16:in `send_with_possible_block'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/johnson-2.0.0.pre3/lib/johnson/ruby_land_proxy.rb:110:in `call_function_property'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/johnson-2.0.0.pre3/lib/johnson/ruby_land_proxy.rb:110:in `method_missing'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-envjs-0.4.0/lib/capybara/driver/envjs_driver.rb:127:in `_event'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-envjs-0.4.0/lib/capybara/driver/envjs_driver.rb:78:in `click'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-0.4.0/lib/capybara/node.rb:144:in `click'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-0.4.0/lib/capybara/node/actions.rb:37:in `click_button'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-0.4.0/lib/capybara/session.rb:273:in `send'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-0.4.0/lib/capybara/session.rb:273:in `method_missing'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/capybara-0.4.0/lib/capybara/dsl.rb:93:in `click_button'
/Users/eostrom/workspace/confoundedcontraption/comics/features/step_definitions/web_steps.rb:29
/Users/eostrom/workspace/confoundedcontraption/comics/features/step_definitions/web_steps.rb:14:in `with_scope'
/Users/eostrom/workspace/confoundedcontraption/comics/features/step_definitions/web_steps.rb:28
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/core_ext/instance_exec.rb:48:in `cucumber_instance_exec'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/rb_support/rb_step_definition.rb:62:in `invoke'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/step_match.rb:26:in `invoke'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/step_invocation.rb:63:in `invoke'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/step_invocation.rb:42:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:99:in `visit_step'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:98:in `visit_step'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/step_collection.rb:15:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/step_collection.rb:14:in `each'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/step_collection.rb:14:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:93:in `visit_steps'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:92:in `visit_steps'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/scenario.rb:53:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:79:in `with_hooks'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:95:in `before_and_after'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:78:in `with_hooks'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/support_code.rb:115:in `call'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/support_code.rb:115:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/language_support/language_methods.rb:13:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/language_support/language_methods.rb:95:in `call'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/language_support/language_methods.rb:95:in `execute_around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/language_support/language_methods.rb:12:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/support_code.rb:114:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/support_code.rb:112:in `call'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime/support_code.rb:112:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:90:in `around'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:77:in `with_hooks'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/scenario.rb:51:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/scenario.rb:106:in `with_visitor'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/scenario.rb:45:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:51:in `visit_feature_element'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:50:in `visit_feature_element'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/feature.rb:40:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/feature.rb:39:in `each'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/feature.rb:39:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:20:in `visit_feature'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:19:in `visit_feature'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/features.rb:29:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/features.rb:17:in `each'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/features.rb:17:in `each'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/features.rb:28:in `accept'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:14:in `visit_features'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:164:in `broadcast'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/ast/tree_walker.rb:13:in `visit_features'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/runtime.rb:45:in `run!'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/cli/main.rb:43:in `execute!'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/../lib/cucumber/cli/main.rb:20:in `execute'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/gems/cucumber-0.10.0/bin/cucumber:14
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/bin/cucumber:19:in `load'
/Users/eostrom/.rvm/gems/ruby-1.8.7-p299@comics/bin/cucumber:19
 WARNING:   [Sun Dec 26 2010 14:29:20 GMT-0600 (CST)] {ENVJS} Exception while dispatching events: super: no superclass method `require' for Object:Class
F---------------------F

(::) failed steps (::)

super: no superclass method `require' for Object:Class (NoMethodError)
./features/step_definitions/web_steps.rb:29
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:28:in `/^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/'
features/editing.feature:31:in `And I press "Save"'
@eostrom
Copy link
Author

eostrom commented Dec 26, 2010

This seems to work, if inelegantly:

                // Ruby.Object.require("base64");
                content = Ruby.eval("Object.require('base64'); lambda { |fn| Base64.encode64(File.read(fn)) }").call(array[i].filename);

@smparkes
Copy link
Owner

Any chance you could push a test case somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants