I have a very small freshly made Rails 3 application. I am using the RubyCAS-Client gem for Rails to authenticate against our CAS server. The CAS client is working as I am able to log into and out of my web application.
Here is my Gemfile:
source 'http://rub开发者_C百科ygems.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
Here is my Cucumber stuff:
# 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
The error I get is:
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'
All of the steps pass( if I remove all of the Cas login requirements). If I add the casclient gem's 'require' lines the "logged in" step passes as well, but then the rest of the steps fail. For some reason it is as if Cucumber is not loading the proper gems from the Gemfile and so the CASClient module is not available to its environment. Fudging the require lines in is like an end run around the problem but it doesn't actually fix anything other than the immediate error.
The fake filter is how you are supposed to test this using Cucumber and its ilk. I can't figure out why this isn't working.
Since you are using gem 'rubycas-client-rails' you should use:
RubyCAS::Filter.fake('homer')
No need to have the require 'casclient/frameworks/rails/filter'
I ran into this problem as well, and I managed to solve it by manually doing
require 'casclient/frameworks/rails/filter'
精彩评论