2011-03-18 69 views
2

我有一个非常小的新鲜的Rails 3应用程序。我正在使用RubyCAS-Client gem for Rails来对我们的CAS服务器进行身份验证。 CAS客户端正在工作,因为我可以登录和退出我的Web应用程序。使用Cucumber来测试RubyCAS客户端

这里是我的Gemfile:

source 'http://rubygems.org' 

gem 'rails', '3.0.5' 
gem 'mysql2' 
gem 'jquery-rails' 
gem 'nifty-generators' 
# Deploy with Capistrano 
# gem 'capistrano' 
gem 'rubycas-client' 
gem 'rubycas-client-rails', :git => "git://github.com/zuk/rubycas-client-rails.git" 

group :development, :test do 
    gem 'unicorn' 
    gem 'capybara' 
    gem 'cucumber' 
    gem 'cucumber-rails' 
    gem 'database_cleaner' 
    gem 'rspec' 
    gem 'rspec-rails' 
    gem 'launchy' 
    gem 'webrat' 
end 

这里是我的黄瓜的东西:

# feature file 

Feature: Manage generic_pages 
    In order to view pages that are in the base controller(generic) 
    I want to visit them and see that they work 

    Scenario: Visit the home page 
    Given I am on the home page 
    Given I am logged in 
    Then I should see "Submit a nomination" 
    And I should see "Nominee's name" 
    And I should see "What are you nominating them for?" 
    And I should see "Why are you nominating them for this award?" 

# cas-client steps 

Given /^I am logged_in$/ do 
    CASClient::Frameworks::Rails::Filter.fake("homer") 
end 

我得到的错误是:

Given I am logged_in                  # features/step_definitions/casclient_steps.rb:1 
     uninitialized constant CASClient::Frameworks (NameError) 
     ./features/step_definitions/casclient_steps.rb:2:in `/^I am logged_in$/' 
     features/manage_nominations.feature:9:in `Given I am logged_in' 

所有的步骤通过(如果我删除所有的Cas登录要求)。如果我添加casclient gem的'require'行,“登录”步骤也会通过,但其余步骤都会失败。出于某种原因,就好像Cucumber没有从Gemfile中加载适当的宝石,因此CASClient模块不适用于其环境。对需求行进行忽略就像解决问题的最终结果,但实际上并没有解决除即时错误之外的其他任何问题。

假过滤器是你应该如何使用Cucumber及其同类来测试的。我无法弄清楚为什么这不起作用。

+0

非常感谢,你让我知道如何嘲笑为CAS登录:'cASClient: :框架::导轨:: Filter.fake(“豪滨海“)' – 2012-12-20 10:20:28

回答

0

我就遇到了这个问题为好,我设法通过手动执行

require 'casclient/frameworks/rails/filter' 
1

由于您使用的宝石“rubycas-客户轨”来解决这个问题,你应该使用:

RubyCAS: :Filter.fake(“本垒打”)

无需有需要“casclient /框架/导轨/过滤器”