forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact_router_demo_spec.rb
37 lines (31 loc) · 1.05 KB
/
react_router_demo_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
# frozen_string_literal: true
require "rails_helper"
require "system/shared/contexts"
describe "React Router Routes" do
context "when Root URL", page: :main do
it "shows comments section" do
visit root_path
click_link "Comments (Root URL)"
expect(page).to have_selector("h2", text: "Comments")
end
end
context "when /react-router URL", page: :main do
it "shows 'React Router is working!' message" do
visit root_path
click_link "Test React Router ('/react-router')"
expect(page).to have_selector("h1", text: "React Router is working!")
end
end
context "when /react-router/redirect URL", page: :main do
before do
visit root_path
click_link "Test Redirect (url to '/react-router/redirect' which goes to root '/')"
end
it "shows comments section" do
expect(page).to have_selector("h2", text: "Comments")
end
it "shows redirect message" do
expect(page).to have_selector(".bg-success", text: "You have been redirected from/react-router/redirect")
end
end
end