Skip to content

Commit 9629051

Browse files
Cucumber and Capybara setup
0 parents  commit 9629051

10 files changed

+193
-0
lines changed

.gitignore

Whitespace-only changes.

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.0

Gemfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem 'byebug'
6+
gem 'capybara'
7+
gem 'cucumber'
8+
gem 'selenium-webdriver'

Gemfile.lock

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.8.7)
5+
public_suffix (>= 2.0.2, < 7.0)
6+
base64 (0.2.0)
7+
bigdecimal (3.1.8)
8+
builder (3.3.0)
9+
byebug (11.1.3)
10+
capybara (3.40.0)
11+
addressable
12+
matrix
13+
mini_mime (>= 0.1.3)
14+
nokogiri (~> 1.11)
15+
rack (>= 1.6.0)
16+
rack-test (>= 0.6.3)
17+
regexp_parser (>= 1.5, < 3.0)
18+
xpath (~> 3.2)
19+
cucumber (9.2.0)
20+
builder (~> 3.2)
21+
cucumber-ci-environment (> 9, < 11)
22+
cucumber-core (> 13, < 14)
23+
cucumber-cucumber-expressions (~> 17.0)
24+
cucumber-gherkin (> 24, < 28)
25+
cucumber-html-formatter (> 20.3, < 22)
26+
cucumber-messages (> 19, < 25)
27+
diff-lcs (~> 1.5)
28+
mini_mime (~> 1.1)
29+
multi_test (~> 1.1)
30+
sys-uname (~> 1.2)
31+
cucumber-ci-environment (10.0.1)
32+
cucumber-core (13.0.3)
33+
cucumber-gherkin (>= 27, < 28)
34+
cucumber-messages (>= 20, < 23)
35+
cucumber-tag-expressions (> 5, < 7)
36+
cucumber-cucumber-expressions (17.1.0)
37+
bigdecimal
38+
cucumber-gherkin (27.0.0)
39+
cucumber-messages (>= 19.1.4, < 23)
40+
cucumber-html-formatter (21.6.0)
41+
cucumber-messages (> 19, < 25)
42+
cucumber-messages (22.0.0)
43+
cucumber-tag-expressions (6.1.0)
44+
diff-lcs (1.5.1)
45+
ffi (1.17.0-x86_64-linux-gnu)
46+
logger (1.6.0)
47+
matrix (0.4.2)
48+
mini_mime (1.1.5)
49+
multi_test (1.1.0)
50+
nokogiri (1.16.7-x86_64-linux)
51+
racc (~> 1.4)
52+
public_suffix (6.0.1)
53+
racc (1.8.1)
54+
rack (3.1.7)
55+
rack-test (2.1.0)
56+
rack (>= 1.3)
57+
regexp_parser (2.9.2)
58+
rexml (3.3.4)
59+
strscan
60+
rubyzip (2.3.2)
61+
selenium-webdriver (4.23.0)
62+
base64 (~> 0.2)
63+
logger (~> 1.4)
64+
rexml (~> 3.2, >= 3.2.5)
65+
rubyzip (>= 1.2.2, < 3.0)
66+
websocket (~> 1.0)
67+
strscan (3.1.0)
68+
sys-uname (1.3.0)
69+
ffi (~> 1.1)
70+
websocket (1.2.11)
71+
xpath (3.2.0)
72+
nokogiri (~> 1.8)
73+
74+
PLATFORMS
75+
x86_64-linux
76+
77+
DEPENDENCIES
78+
byebug
79+
capybara
80+
cucumber
81+
selenium-webdriver
82+
83+
BUNDLED WITH
84+
2.4.1

cucumber.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
default: |
2+
staff-features
3+
--publish-quiet
4+
--format pretty
5+
--color
6+
--require env.rb
7+
--require helpers
8+
--require staff-features

env.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'capybara/cucumber'
2+
require 'selenium-webdriver'
3+
4+
BASE_URL = 'https://e2e.archivesspace.org'
5+
PUBLIC_URL = BASE_URL
6+
STAFF_URL = "#{BASE_URL}/staff"
7+
8+
Capybara.register_driver :firefox do |app|
9+
options = Selenium::WebDriver::Firefox::Options.new
10+
11+
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
12+
end
13+
14+
Capybara.default_driver = :firefox
15+
Capybara.default_max_wait_time = 10

helpers/helpers.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
def expect_record_to_be_in_search_results(search_term)
2+
fill_in 'global-search-box', with: search_term
3+
find('#global-search-button').click
4+
5+
search_result_rows = all('#tabledSearchResults tbody tr')
6+
7+
expect(search_result_rows.length).to eq 1
8+
expect(search_result_rows[0].text).to include search_term
9+
end
10+
11+
def expect_record_to_not_be_in_search_results(search_term)
12+
fill_in 'global-search-box', with: search_term
13+
find('#global-search-button').click
14+
15+
search_result_rows = all('#tabledSearchResults tbody tr')
16+
17+
expect(search_result_rows.length).to eq 0
18+
expect(find('.alert.alert-info.with-hide-alert').text).to eq 'No records found'
19+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Accession Create
2+
Background:
3+
Given the user is logged in as admin
4+
Scenario: Accession is successfully created
5+
Given the web browser is on the create accession page
6+
When the user fills in all the required fields
7+
When the user clicks on Save
8+
Then a new accession is created
9+
Scenario: Accession fails to be created
10+
Given the web browser is on the create accession page
11+
When the user does not fill in all the required fields
12+
When the user clicks on Save
13+
Then a new accession is not created
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Given('the web browser is on the create accession page') do
2+
@uuid = SecureRandom.uuid
3+
4+
click_on 'Create'
5+
click_on 'Accession'
6+
end
7+
8+
When('the user fills in all the required fields') do
9+
fill_in 'accession_id_0_', with: "Accession #{@uuid}"
10+
end
11+
12+
When('the user does not fill in all the required fields') do
13+
fill_in 'accession_id_0_', with: ''
14+
end
15+
16+
When('the user clicks on Save') do
17+
click_button 'Save'
18+
end
19+
20+
Then('a new accession is created') do
21+
expect(find('h2').text).to eq "Accession #{@uuid} Accession"
22+
expect(find('.alert.alert-success.with-hide-alert').text).to eq 'Accession created'
23+
24+
expect_record_to_be_in_search_results(@uuid)
25+
end
26+
27+
Then('a new accession is not created') do
28+
expect(find('h2').text).to eq 'New Accession Accession'
29+
expect(find('.alert.alert-danger.with-hide-alert').text).to eq 'Identifier - Property is required but was missing'
30+
31+
expect_record_to_not_be_in_search_results(@uuid)
32+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Given 'the user is logged in as admin' do
2+
visit STAFF_URL
3+
4+
fill_in "username", with: 'admin'
5+
fill_in "password", with: 'admin'
6+
7+
click_on 'Sign In'
8+
9+
expect(page).to have_content 'Welcome to ArchivesSpace'
10+
expect(page).to have_content 'Your friendly archives management tool.'
11+
element = find('.global-header .user-container')
12+
expect(element.text.strip).to eq 'admin'
13+
end

0 commit comments

Comments
 (0)