master
1require "rails_helper"
2
3feature "Registrations", type: :feature do
4 subject { NewRegistrationPage.new }
5
6 before :each do
7 subject.visit_page
8 end
9
10 describe "creating a new account" do
11 it "registers a new account" do
12 subject.register_with(username: "mo", email: "mo@example.com", password: "password")
13
14 expect(current_path).to eql(edit_profile_path("mo"))
15 end
16
17 context "when the username is taken" do
18 let!(:user) { create(:user) }
19
20 it "displays an error" do
21 subject.register_with(username: user.username)
22
23 expect(page).to have_content("Username has already been taken")
24 end
25 end
26
27 context "when the email is taken" do
28 let!(:user) { create(:user) }
29
30 it "displays an error" do
31 subject.register_with(email: user.email)
32
33 expect(page).to have_content("Email has already been taken")
34 end
35 end
36
37 context "when the terms and conditions are not accepted" do
38 it "displays an error" do
39 subject.register_with(accept_terms: false)
40
41 expect(page).to have_content("Terms and conditions must be accepted")
42 end
43 end
44 end
45end