Created
August 3, 2012 01:58
-
-
Save rrmartins/3243400 to your computer and use it in GitHub Desktop.
Error Devise with RSpec and Rails 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe ContaPagarsController do | |
render_views | |
login_user | |
it "should have a current_user" do | |
subject.current_user.should_not be_nil | |
end | |
it "should get index" do | |
get 'index' | |
response.should be_success | |
end | |
describe "POST 'create'" do | |
it "creates link" | |
it "saves link" | |
it "redirects to link overview" | |
it "displays message" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ControllerMacros | |
def login_user | |
before(:each) do | |
require 'pry' | |
binding.pry | |
@request.env["devise.mapping"] = Devise.mappings[:user] | |
user = FactoryGirl.create(:user) | |
user.confirm! | |
sign_in user | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.../spec/spec_helper.rb:27:in `block (2 levels) in <top (required)>': uninitialized constant ControllerMacros (NameError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
config.use_transactional_fixtures = false | |
config.mock_with :rspec | |
config.color_enabled = true | |
config.formatter = 'documentation' | |
config.include Devise::TestHelpers, :type => :controller | |
config.extend ControllerMacros, :type => :controller | |
end |
i add require 'support/controller_macros'
on top of spec/rails_helper.rb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
it's should not be in spec_helper file. Right place for it, is devise.rb in spec/support folder