我有一个非常小的新制作的 Rails 3 应用程序。我正在使用 Rails 的 RubyCAS-Client gem 对我们的 CAS 服务器进行身份验证。CAS 客户端正在工作,因为我能够登录和退出我的 Web 应用程序。
这是我的 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”行,“logged in”步骤也会通过,但其余步骤将失败。由于某种原因,就好像 Cucumber 没有从 Gemfile 加载正确的 gem,因此 CASClient 模块对其环境不可用。捏造需要的行就像解决问题的结束一样,但它实际上并没有解决除了直接错误之外的任何问题。
假过滤器是您应该如何使用 Cucumber 及其同类产品进行测试的方式。我不知道为什么这不起作用。