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 'PostsController' do | |
before { visit new_post_path } | |
it "should display form for post creation" do | |
pending "we need to sign in first!!!" | |
end | |
end |
Możemy użyć metody "brute force" ;) i po prostu wejść na stronę logowania i wypełnić formularz
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 'PostsController' | |
let(:user) { Factory :user } | |
it "should authenticate and than display form" do | |
visit new_session_path | |
fill_in 'Login', with: user.email | |
fill_in 'Password', with: user.password | |
click_button 'Sing in' | |
visit new_post_path | |
# fill in new post form | |
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
RSpec.configure do |config| | |
config.include Warden::Test::Helpers | |
config.before(:all) do | |
Warden.test_mode! | |
end | |
config.after(:all) do | |
Warden.test_reset! | |
end | |
end | |
def sign_in(user) | |
login_as user | |
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
require 'spec_helper' | |
describe 'PostsController' | |
let(:user) { Factory :user } | |
before { sign_in user } | |
it "should display form" do | |
visit new_post_path | |
# fill in new post form | |
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
def sign_in(user) | |
page.driver.post user_session_path, user: { login: user.email, password: user.password } | |
end |
*Wydaje mi się jednak, że wersja używająca Warden-a jest szybsza. Ale możliwe że to tylko subiektywne wrażenie
Brak komentarzy:
Prześlij komentarz