1
votes

People, I'm new at RoR enviroment, and I'm trying to do something apparently simple, but its getting complicated.

I do not have roles in my application, and I just want to add some features to logged in users, but starting with the RSpec tests, I cannot find the way to test if the user is signed in...

I'm using CanCan with Devise.

I tried this code below, but it didn't work, says that there is no method called sign_in, I've already tried current_user, and user_signed_in?

before(:each) do
  @user = User.new
  sign_in @user
end

What am I missing?

gemfile:

source 'http://rubygems.org'

gem 'rails', '~> 3.0.7'

# authentication
gem 'devise', '~> 1.3.4'

#authorization
gem "cancan"

# mongodb database
gem 'mongoid', '~> 2.0'
gem 'bson_ext', '~> 1.3'

gem "high_voltage"
gem 'translate_routes'

gem 'factory_girl_rails', "~> 1.1.rc1"

group :development, :test do
  gem "rspec-rails", ">= 2.0.0"
  gem "cucumber-rails", ">= 0.3.2"
  gem "webrat", ">= 0.7.2"
  gem 'rspec', '2.5.0'
  gem 'spork'
  gem 'launchy'
  gem 'autotest'
  gem 'autotest-rails-pure'
  gem 'ruby-debug'
  gem 'rake', '0.9.2'
  gem 'shoulda'
end
1

1 Answers

1
votes

Do you have a spec/support/devise.rb file? It needs to include

RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end