Skip to content

Commit 32178f7

Browse files
committed
Introduce acceptance testing
This is the culmination of several months work, and at least one side quest, in laying down the foundations of a test suite which will run Administrate completely from scratch. For each scenario, we create a new Rails application in a clean environment, install Administrate and run the generators. We can then test against this fresh application. Whilst we seem to have had a good track record when it comes to past and future compatibility, the hope is that by having such an outside perspective focused test suite, this will provide much broader confidence, especially where different frontend configurations are concerned. We'll also be able to test speculatively, such as against the `main` branch of Rails which isn't something we could've done with confidence in the past with so many different components involved. To do this, we introduce the `jet_black` gem, which helps with running "black box" tests for command line tools, and `sack_race`, which helps run and manage processes inside the test suite. To run the tests themselves, we use Capybara like we do elsewhere, only pointed against the Rails project we created as part of the test. It's not expected that we'd re-use our existing Capybara tests here, but rather create new ones for each scenario. As these tests are always going to be slow, we don't run these as usual when running `rspec`, so they excluded. We'll run them in GitHub Actions as standalone jobs. Over time, it's expected that we'd create acceptance tests for all supported configurations, covering different frontend tools, to projects with complex model configurations and beyond. https://github.com/odlp/jet_black https://github.com/nickcharlton/sack_race
1 parent 6616475 commit 32178f7

File tree

13 files changed

+153
-4
lines changed

13 files changed

+153
-4
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--color
22
--require spec_helper
3+
--exclude "**/black_box/*_spec.rb"

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ group :test do
3636
gem "capybara"
3737
gem "database_cleaner"
3838
gem "formulaic"
39+
gem "jet_black"
3940
gem "launchy"
41+
gem "sack_race", github: "nickcharlton/sack_race"
4042
gem "selenium-webdriver"
4143
gem "shoulda-matchers"
4244
gem "timecop"

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
GIT
2+
remote: https://github.com/nickcharlton/sack_race.git
3+
revision: 89b4e5fff452aa6e48498aa356da87f8d1b65ae9
4+
specs:
5+
sack_race (1.0.0.rc1)
6+
17
PATH
28
remote: .
39
specs:
@@ -174,6 +180,7 @@ GEM
174180
pp (>= 0.6.0)
175181
rdoc (>= 4.0.0)
176182
reline (>= 0.4.2)
183+
jet_black (0.7.1)
177184
jsbundling-rails (1.3.1)
178185
railties (>= 6.0.0)
179186
json (2.13.2)
@@ -426,6 +433,7 @@ DEPENDENCIES
426433
globalid
427434
i18n-tasks (= 1.0.15)
428435
image_processing
436+
jet_black
429437
jsbundling-rails (~> 1.3)
430438
kaminari-i18n
431439
launchy
@@ -434,6 +442,7 @@ DEPENDENCIES
434442
pundit
435443
rack-timeout
436444
redcarpet
445+
sack_race!
437446
selenium-webdriver
438447
sentry-rails
439448
sentry-ruby

bin/bundle

Lines changed: 0 additions & 3 deletions
This file was deleted.

gemfiles/pundit21.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ group :test do
3636
gem "capybara"
3737
gem "database_cleaner"
3838
gem "formulaic"
39+
gem "jet_black"
3940
gem "launchy"
41+
gem "sack_race", github: "nickcharlton/sack_race"
4042
gem "selenium-webdriver"
4143
gem "shoulda-matchers"
4244
gem "timecop"

gemfiles/rails60.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ group :test do
4040
gem "capybara"
4141
gem "database_cleaner"
4242
gem "formulaic"
43+
gem "jet_black"
4344
gem "launchy"
45+
gem "sack_race", github: "nickcharlton/sack_race"
4446
gem "selenium-webdriver"
4547
gem "shoulda-matchers"
4648
gem "timecop"

gemfiles/rails61.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ group :test do
3939
gem "capybara"
4040
gem "database_cleaner"
4141
gem "formulaic"
42+
gem "jet_black"
4243
gem "launchy"
44+
gem "sack_race", github: "nickcharlton/sack_race"
4345
gem "selenium-webdriver"
4446
gem "shoulda-matchers"
4547
gem "timecop"

gemfiles/rails70.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ group :test do
3737
gem "capybara"
3838
gem "database_cleaner"
3939
gem "formulaic"
40+
gem "jet_black"
4041
gem "launchy"
42+
gem "sack_race", github: "nickcharlton/sack_race"
4143
gem "selenium-webdriver"
4244
gem "shoulda-matchers"
4345
gem "timecop"

gemfiles/rails80.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ group :test do
3737
gem "capybara"
3838
gem "database_cleaner"
3939
gem "formulaic"
40+
gem "jet_black"
4041
gem "launchy"
42+
gem "sack_race", github: "nickcharlton/sack_race"
4143
gem "selenium-webdriver"
4244
gem "shoulda-matchers"
4345
gem "timecop"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require "rails_helper"
2+
3+
RSpec.describe "with a Default Rails app" do
4+
it "works" do
5+
create_rails_application
6+
setup_post_model
7+
setup_administrate
8+
9+
app.start_and_wait_for_ready
10+
11+
visit("/admin")
12+
13+
expect(page).to have_css("header h1#page-title", text: "Posts")
14+
click_on "New post"
15+
16+
fill_in "Body", with: "Some words!"
17+
fill_in "Title", with: "A post with words"
18+
click_button "Create Post"
19+
20+
expect(page).to have_content("Post was successfully created.")
21+
expect(page).to have_content("Show Post #1")
22+
23+
app.stop
24+
end
25+
26+
def session
27+
@session ||= JetBlack::Session.new(options: {clean_bundler_env: true})
28+
end
29+
30+
def app
31+
@app ||= RailsProcess.new(session)
32+
end
33+
end

0 commit comments

Comments
 (0)