/
user_logs_in_with_twitter_spec.rb
58 lines (49 loc) 路 1.51 KB
/
user_logs_in_with_twitter_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "rails_helper"
def user_grants_authorization_on_twitter_popup(twitter_callback_hash)
OmniAuth.config.add_mock(:twitter, twitter_callback_hash)
end
def user_do_not_grants_authorization_on_twitter_popup
OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
end
RSpec.describe "Authenticating with twitter" do
let(:twitter_callback_hash) do
{
provider: "twitter",
uid: "111111",
credentials: {
token: "222222",
secret: "333333"
},
extra: {
access_token: "",
raw_info: {
name: "Bruce Wayne",
created_at: "Thu Jul 4 00:00:00 +0000 2013", # This is mandatory
}
},
info: {
nickname: "batman",
name: "Bruce Wayne",
email: "batman@batcave.com"
}
}
end
context "when user is new on dev.to" do
it "logging in with twitter using valid credentials" do
user_grants_authorization_on_twitter_popup(twitter_callback_hash)
visit root_path
click_link "SIGN IN VIA TWITTER"
expect(page).to have_link("Write your first post now")
expect(page).to have_link("Welcome Thread")
end
it "logging in with twitter using invalid credentials" do
user_do_not_grants_authorization_on_twitter_popup
visit root_path
click_link "SIGN IN VIA TWITTER"
expect(page).to have_link "Sign In/Up"
expect(page).to have_link "Via Twitter"
expect(page).to have_link "Via GitHub"
expect(page).to have_link "All about dev.to"
end
end
end