首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Authlogic Facebook Connect和cucumber

Authlogic Facebook Connect和cucumber
EN

Stack Overflow用户
提问于 2010-05-04 02:59:33
回答 1查看 780关注 0票数 1

我将authlogic_facebook_connect插件添加到我的项目中,现在由于NoMethodError的原因,我在运行黄瓜测试时遇到了问题。

代码语言:javascript
复制
undefined method `set_facebook_session' for nil:NilClass (NoMethodError)

在authlogic_facebook_connect/Session.rb中,方法"authenticating_with_facebook_connect?“作为某种回调调用,并且定义了控制器,但缺少“set_facebook_session”方法。

代码语言:javascript
复制
  def authenticating_with_facebook_connect?
    controller.set_facebook_session
    attempted_record.nil? && errors.empty? && controller.facebook_session
  end

我不明白为什么cucumber测试没有用这个方法加载控制器。我还在开发环境和黄瓜环境中测试了这个应用程序,一切都很完美。

这是完整的黄瓜输出。

代码语言:javascript
复制
Feature: Authentication
  In order to keep security a user should only be able to edit their own profile

  Background:                                # features/authorization.feature:4
    Given a valid user record for joe_runner # features/step_definitions/user_steps.rb:4
      undefined method `set_facebook_session' for nil:NilClass (NoMethodError)
      ./vendor/plugins/authlogic/lib/authlogic/controller_adapters/abstract_adapter.rb:63:in `send'
      ./vendor/plugins/authlogic/lib/authlogic/controller_adapters/abstract_adapter.rb:63:in `method_missing'
      ./vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:132:in `authenticating_with_facebook_connect?'
      ./vendor/plugins/authlogic/lib/authlogic/session/callbacks.rb:83:in `validate'
      ./vendor/plugins/authlogic/lib/authlogic/session/validation.rb:64:in `valid?'
      ./vendor/plugins/authlogic/lib/authlogic/session/existence.rb:65:in `save'
      ./vendor/plugins/authlogic/lib/authlogic/session/existence.rb:30:in `create'
      ./vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/session_maintenance.rb:113:in `create_session'
      ./vendor/plugins/authlogic/lib/authlogic/acts_as_authentic/session_maintenance.rb:103:in `maintain_sessions'
      ./features/step_definitions/user_steps.rb:5:in `/^a valid user record for ([\w]*)$/'
      features/authorization.feature:5:in `Given a valid user record for joe_runner'

  Scenario: Jonathan can edit his profile but not other users profiles # features/authorization.feature:7
    Given jonathan is logged in as an user                             # features/step_definitions/user_steps.rb:13
    When I go to my user edit page                                     # features/step_definitions/web_steps.rb:18
    And I press "Update"                                               # features/step_definitions/web_steps.rb:22
    Then I should see "Account updated!"                               # features/step_definitions/web_steps.rb:142
    When I go to joe_runner's user edit page                           # features/step_definitions/web_steps.rb:18
    Then I should see "You do not allowed to access to view that page" # features/step_definitions/web_steps.rb:142

Failing Scenarios:
cucumber features/authentication.feature:9 # Scenario: Signup
cucumber features/authorization.feature:7 # Scenario: Jonathan can edit his profile but not other users profiles

2 scenarios (2 failed)
15 steps (2 failed, 13 skipped)
0m0.173s
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:995:in `sh'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in `sh'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in `sh'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1029:in `ruby'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in `ruby'
/Library/Ruby/Gems/1.8/gems/cucumber-0.6.4/lib/cucumber/rake/task.rb:68:in `run'
/Library/Ruby/Gems/1.8/gems/cucumber-0.6.4/lib/cucumber/rake/task.rb:138:in `define_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
activespoon:base_project jspooner$

有几个博客给出了如何用cucumber测试facebook应用程序的例子,但它们没有帮助,因为我的错误出现在这些之前。

http://opensoul.org/2009/3/6/testing-facebook-with-cucumber

http://ryanbigg.com/2010/03/testing-facebook/

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-05-06 10:32:27

在安装authlogic_facebook_connect之后,我的测试套件也遇到了同样的问题。我将以下补丁应用到插件中,它解决了这个问题:

http://gist.github.com/221893

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2760461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档