mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Fix all the things!
* Update factories * Switch to Firefox headless with Selenium * Fix shoulda setup
This commit is contained in:
parent
50f1fc25aa
commit
cb8ce557ae
2
Gemfile
2
Gemfile
@ -54,7 +54,9 @@ group :test do
|
|||||||
gem "fivemat"
|
gem "fivemat"
|
||||||
gem "poltergeist"
|
gem "poltergeist"
|
||||||
gem "shoulda"
|
gem "shoulda"
|
||||||
|
gem "shoulda-matchers"
|
||||||
gem "simplecov"
|
gem "simplecov"
|
||||||
|
gem "webdrivers"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
|
|||||||
11
Gemfile.lock
11
Gemfile.lock
@ -79,6 +79,7 @@ GEM
|
|||||||
capybara-screenshot (1.0.25)
|
capybara-screenshot (1.0.25)
|
||||||
capybara (>= 1.0, < 4)
|
capybara (>= 1.0, < 4)
|
||||||
launchy
|
launchy
|
||||||
|
childprocess (3.0.0)
|
||||||
cliver (0.3.2)
|
cliver (0.3.2)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
coffee-rails (5.0.0)
|
coffee-rails (5.0.0)
|
||||||
@ -283,6 +284,7 @@ GEM
|
|||||||
ruby-progressbar (1.11.0)
|
ruby-progressbar (1.11.0)
|
||||||
ruby_parser (3.16.0)
|
ruby_parser (3.16.0)
|
||||||
sexp_processor (~> 4.15, >= 4.15.1)
|
sexp_processor (~> 4.15, >= 4.15.1)
|
||||||
|
rubyzip (2.3.2)
|
||||||
sass-rails (6.0.0)
|
sass-rails (6.0.0)
|
||||||
sassc-rails (~> 2.1, >= 2.1.1)
|
sassc-rails (~> 2.1, >= 2.1.1)
|
||||||
sassc (2.4.0)
|
sassc (2.4.0)
|
||||||
@ -294,6 +296,9 @@ GEM
|
|||||||
sprockets-rails
|
sprockets-rails
|
||||||
tilt
|
tilt
|
||||||
selectize-rails (0.12.6)
|
selectize-rails (0.12.6)
|
||||||
|
selenium-webdriver (3.142.7)
|
||||||
|
childprocess (>= 0.5, < 4.0)
|
||||||
|
rubyzip (>= 1.2.2)
|
||||||
sexp_processor (4.15.3)
|
sexp_processor (4.15.3)
|
||||||
shoulda (4.0.0)
|
shoulda (4.0.0)
|
||||||
shoulda-context (~> 2.0)
|
shoulda-context (~> 2.0)
|
||||||
@ -336,6 +341,10 @@ GEM
|
|||||||
unicode-display_width (2.0.0)
|
unicode-display_width (2.0.0)
|
||||||
warden (1.2.9)
|
warden (1.2.9)
|
||||||
rack (>= 2.0.9)
|
rack (>= 2.0.9)
|
||||||
|
webdrivers (4.6.0)
|
||||||
|
nokogiri (~> 1.6)
|
||||||
|
rubyzip (>= 1.3.0)
|
||||||
|
selenium-webdriver (>= 3.0, < 4.0)
|
||||||
websocket-driver (0.7.5)
|
websocket-driver (0.7.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.5)
|
websocket-extensions (0.1.5)
|
||||||
@ -380,12 +389,14 @@ DEPENDENCIES
|
|||||||
ruby_parser
|
ruby_parser
|
||||||
sass-rails
|
sass-rails
|
||||||
shoulda
|
shoulda
|
||||||
|
shoulda-matchers
|
||||||
simple_form
|
simple_form
|
||||||
simplecov
|
simplecov
|
||||||
slugtastic
|
slugtastic
|
||||||
standardrb
|
standardrb
|
||||||
uglifier
|
uglifier
|
||||||
unf
|
unf
|
||||||
|
webdrivers
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.7.2p137
|
ruby 2.7.2p137
|
||||||
|
|||||||
@ -41,4 +41,6 @@ DanBarberPhoto::Application.configure do
|
|||||||
|
|
||||||
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
||||||
config.assets.allow_debugging = true
|
config.assets.allow_debugging = true
|
||||||
|
|
||||||
|
config.assets.check_precompiled_asset = false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :contact do
|
factory :contact do
|
||||||
email "test@danbarberphoto.com"
|
email { "test@danbarberphoto.com" }
|
||||||
name "Dan Barber"
|
name { "Dan Barber" }
|
||||||
message "This is a message."
|
message { "This is a message." }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :page do
|
factory :page do
|
||||||
name "page"
|
name { "page" }
|
||||||
title "Page"
|
title { "Page" }
|
||||||
content "This is a page."
|
content { "This is a page." }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :photo do
|
factory :photo do
|
||||||
title "A Photo"
|
title { "A Photo" }
|
||||||
description "A lovely photo of a tree"
|
description { "A lovely photo of a tree" }
|
||||||
image Rails.root.join("spec/fixtures/photo.jpg")
|
image { Rails.root.join("spec/fixtures/photo.jpg") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
email "test@example.com"
|
email { "test@example.com" }
|
||||||
password_digest "password"
|
password_digest { "password" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
describe Category do
|
describe Category, type: :model do
|
||||||
it { should have_and_belong_to_many(:photos) }
|
it { is_expected.to have_and_belong_to_many(:photos) }
|
||||||
it { should validate_presence_of(:name) }
|
it { is_expected.to validate_presence_of(:name) }
|
||||||
it { should validate_presence_of(:slug) }
|
it { is_expected.to validate_presence_of(:slug) }
|
||||||
it { should validate_uniqueness_of(:name) }
|
it { is_expected.to validate_uniqueness_of(:name) }
|
||||||
it { should validate_uniqueness_of(:slug) }
|
it { is_expected.to validate_uniqueness_of(:slug) }
|
||||||
|
|
||||||
let(:category) { create(:category, name: "A Test Category") }
|
let(:category) { create(:category, name: "A Test Category") }
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
describe Contact do
|
describe Contact, type: :model do
|
||||||
it { is_expected.to validate_presence_of(:email) }
|
it { is_expected.to validate_presence_of(:email) }
|
||||||
it { is_expected.to validate_presence_of(:name) }
|
it { is_expected.to validate_presence_of(:name) }
|
||||||
it { is_expected.to validate_presence_of(:message) }
|
it { is_expected.to validate_presence_of(:message) }
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
require "spec_helper"
|
require "spec_helper"
|
||||||
|
|
||||||
describe Photo do
|
describe Photo, type: :model do
|
||||||
it { should have_and_belong_to_many(:categories) }
|
it { should have_and_belong_to_many(:categories) }
|
||||||
|
|
||||||
it { should validate_presence_of(:image) }
|
it { should validate_presence_of(:image) }
|
||||||
|
|||||||
@ -3,14 +3,20 @@ ENV["RAILS_ENV"] ||= "test"
|
|||||||
require File.expand_path("../../config/environment", __FILE__)
|
require File.expand_path("../../config/environment", __FILE__)
|
||||||
require "rspec/rails"
|
require "rspec/rails"
|
||||||
require "capybara/rspec"
|
require "capybara/rspec"
|
||||||
require "capybara/poltergeist"
|
|
||||||
|
|
||||||
# For code coverage
|
# For code coverage
|
||||||
require "simplecov"
|
require "simplecov"
|
||||||
SimpleCov.start
|
SimpleCov.start
|
||||||
|
|
||||||
# Use Poltergeist
|
# Use Firefox headless
|
||||||
Capybara.javascript_driver = :poltergeist
|
Capybara.register_driver :firefox_headless do |app|
|
||||||
|
options = ::Selenium::WebDriver::Firefox::Options.new
|
||||||
|
options.args << "--headless"
|
||||||
|
|
||||||
|
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
|
||||||
|
end
|
||||||
|
|
||||||
|
Capybara.javascript_driver = :firefox_headless
|
||||||
|
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||||
# in spec/support/ and its subdirectories.
|
# in spec/support/ and its subdirectories.
|
||||||
@ -70,3 +76,10 @@ RSpec.configure do |config|
|
|||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Shoulda::Matchers.configure do |config|
|
||||||
|
config.integrate do |with|
|
||||||
|
with.test_framework :rspec
|
||||||
|
with.library :rails
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user