Skip to content
Permalink
Browse files

Merge branch 'appendix-a-system-tests'

  • Loading branch information...
ruralocity committed Aug 23, 2018
2 parents defe77a + 4714ae6 commit 8b3800f3cd39cd5a33332683afa3aee5e838f45c
@@ -15,7 +15,7 @@ gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'

group :development, :test do
gem 'rspec-rails', '~> 3.6.0'
gem 'rspec-rails', '~> 3.8.0'
gem 'factory_bot_rails', '~> 4.10.0'
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
@@ -53,7 +53,7 @@ GEM
arel (8.0.0)
autoprefixer-rails (6.7.7.2)
execjs
bcrypt (3.1.11)
bcrypt (3.1.12)
bindex (0.5.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
@@ -85,14 +85,15 @@ GEM
concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
devise (4.3.0)
crass (1.0.4)
devise (4.4.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
diff-lcs (1.3)
erubi (1.6.0)
erubi (1.7.1)
execjs (2.7.0)
factory_bot (4.10.0)
activesupport (>= 3.0.0)
@@ -102,7 +103,7 @@ GEM
faker (1.7.3)
i18n (~> 0.5)
ffi (1.9.18)
geocoder (1.4.4)
geocoder (1.4.9)
globalid (0.4.0)
activesupport (>= 4.2.0)
hashdiff (0.3.4)
@@ -122,11 +123,12 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.5)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
@@ -136,7 +138,7 @@ GEM
minitest (5.11.3)
multi_json (1.12.1)
nio4r (2.0.0)
nokogiri (1.8.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
paperclip (5.1.0)
@@ -147,7 +149,7 @@ GEM
mimemagic (~> 0.3.0)
public_suffix (3.0.0)
puma (3.8.2)
rack (2.0.3)
rack (2.0.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.1)
@@ -165,38 +167,38 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.1)
actionpack (= 5.1.1)
activesupport (= 5.1.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (12.3.1)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-rails (3.6.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
ruby_dep (1.5.0)
rubyzip (1.2.1)
safe_yaml (1.0.4)
@@ -225,7 +227,7 @@ GEM
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.7)
turbolinks (5.0.1)
@@ -273,7 +275,7 @@ DEPENDENCIES
paperclip
puma (~> 3.7)
rails (~> 5.1.1)
rspec-rails (~> 3.6.0)
rspec-rails (~> 3.8.0)
sass-rails (~> 5.0)
selenium-webdriver
shoulda-matchers!
@@ -1,8 +1,8 @@
# *Everyday Rails Testing with RSpec* sample application (2017 edition)

**Still a work in progress:** Refer to the [Everyday Rails] blog for news on
this edition of the book. You can find sample source for earlier editions in
the [everydayrails organization] on GitHub. Thanks!
Refer to the [Everyday Rails] blog for news on this edition of the book. You
can find sample source for earlier editions in the [everydayrails
organization] on GitHub. Thanks!

---

Some generated files are not rendered by default. Learn more.

@@ -38,6 +38,6 @@
user.geocode
}.to change(user, :location).
from(nil).
to("Brooklyn, New York, United States")
to("Brooklyn, New York, US")
end
end
@@ -60,7 +60,7 @@
# Use Devise helpers in tests
config.include Devise::Test::ControllerHelpers, type: :controller
config.include RequestSpecHelper, type: :request
config.include Devise::Test::IntegrationHelpers, type: :feature
config.include Devise::Test::IntegrationHelpers, type: :system

# Add support for Paperclip's Shoulda matchers
config.include Paperclip::Shoulda::Matchers
@@ -1,5 +1,9 @@
Capybara.javascript_driver = :selenium_chrome_headless
RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by :rack_test
end

# Use poltergeist/PhantomJS as an alternative to Selenium and Chrome
# require 'capybara/poltergeist'
# Capybara.javascript_driver = :poltergeist
config.before(:each, type: :system, js: true) do
driven_by :selenium_chrome_headless
end
end
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.feature "Notes", type: :feature do
RSpec.describe "Notes", type: :system do
let(:user) { FactoryBot.create(:user) }
let(:project) {
FactoryBot.create(:project,
@@ -9,7 +9,7 @@
}

scenario "user uploads an attachment" do
login_as user, scope: :user
sign_in user
visit project_path(project)
click_link "Add Note"
fill_in "Message", with: "My book cover"
@@ -1,12 +1,13 @@
require 'rails_helper'

RSpec.feature "Projects", type: :feature do
RSpec.describe "Projects", type: :system do
scenario "user creates a new project" do
user = FactoryBot.create(:user)
# using our customer login helper:
# sign_in_as user
# or the one provided by Devise:
sign_in user, scope: :user
sign_in user

visit root_path

expect {
@@ -26,7 +27,7 @@
scenario "user completes a project" do
user = FactoryBot.create(:user)
project = FactoryBot.create(:project, owner: user)
login_as user, scope: :user
sign_in user

visit project_path(project)

@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.feature "Sign in", type: :feature do
RSpec.describe "Sign in", type: :system do
let(:user) { FactoryBot.create(:user) }

before do
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.feature "Sign-ups", type: :feature do
RSpec.describe "Sign-ups", type: :system do
include ActiveJob::TestHelper

scenario "user successfully signs up" do
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.feature "Tasks", type: :feature do
RSpec.describe "Tasks", type: :system do
let(:user) { FactoryBot.create(:user) }
let(:project) {
FactoryBot.create(:project,
@@ -10,7 +10,7 @@
let!(:task) { project.tasks.create!(name: "Finish RSpec tutorial") }

scenario "user toggles a task", js: true do
sign_in user, scope: :user
sign_in user
go_to_project "RSpec tutorial"

complete_task "Finish RSpec tutorial"

0 comments on commit 8b3800f

Please sign in to comment.
You can’t perform that action at this time.