Skip to content

Instantly share code, notes, and snippets.

@austenito
Created April 11, 2012 12:50
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save austenito/2359120 to your computer and use it in GitHub Desktop.
Save austenito/2359120 to your computer and use it in GitHub Desktop.
Integration Testing w/ Sorcery
describe "Shopping Cart Requests" do
let!(:user) { Fabricate(:user) }
before(:each) do
login_user_post("admin", "admin")
end
context "when I visit the shopping cart" do
it " show the logged in users' cart items " do
#Test stuff
end
end
end
RSpec.configure do |config|
config.include Sorcery::TestHelpers::Rails
end
module Sorcery
module TestHelpers
module Rails
def login_user_post(user, password)
page.driver.post(user_sessions_url, { username: user, password: password})
end
end
end
end
Fabricator(:user, :class_name => "User") do
id { sequence }
username { "admin" }
password { "admin" }
display_name { "Admin Boom"}
admin { true }
email { "whatever@whatever.com" }
salt { "asdasdastr4325234324sdfds" }
crypted_password { Sorcery::CryptoProviders::BCrypt.encrypt("secret",
"asdasdastr4325234324sdfds") }
end
@eirvandelden
Copy link

This gist doesn't work for me either, I also either get ActionController::RoutingError:
No route matches [POST] "/login"

Or:
NameError:
undefined local variable or method `login_path'

Or:
NameError:
undefined local variable or method `page' for #<RSpec::ExampleGroups:

@anlek
Copy link

anlek commented Sep 28, 2014

Did you guys ever figure this out?
I'm getting the undefined local variable or methodpage' for ...` issue

@tomraulet
Copy link

@anlek : same error here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment