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 "poltergeist"
|
||||
gem "shoulda"
|
||||
gem "shoulda-matchers"
|
||||
gem "simplecov"
|
||||
gem "webdrivers"
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
||||
11
Gemfile.lock
11
Gemfile.lock
@ -79,6 +79,7 @@ GEM
|
||||
capybara-screenshot (1.0.25)
|
||||
capybara (>= 1.0, < 4)
|
||||
launchy
|
||||
childprocess (3.0.0)
|
||||
cliver (0.3.2)
|
||||
coderay (1.1.3)
|
||||
coffee-rails (5.0.0)
|
||||
@ -283,6 +284,7 @@ GEM
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby_parser (3.16.0)
|
||||
sexp_processor (~> 4.15, >= 4.15.1)
|
||||
rubyzip (2.3.2)
|
||||
sass-rails (6.0.0)
|
||||
sassc-rails (~> 2.1, >= 2.1.1)
|
||||
sassc (2.4.0)
|
||||
@ -294,6 +296,9 @@ GEM
|
||||
sprockets-rails
|
||||
tilt
|
||||
selectize-rails (0.12.6)
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
sexp_processor (4.15.3)
|
||||
shoulda (4.0.0)
|
||||
shoulda-context (~> 2.0)
|
||||
@ -336,6 +341,10 @@ GEM
|
||||
unicode-display_width (2.0.0)
|
||||
warden (1.2.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-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
@ -380,12 +389,14 @@ DEPENDENCIES
|
||||
ruby_parser
|
||||
sass-rails
|
||||
shoulda
|
||||
shoulda-matchers
|
||||
simple_form
|
||||
simplecov
|
||||
slugtastic
|
||||
standardrb
|
||||
uglifier
|
||||
unf
|
||||
webdrivers
|
||||
|
||||
RUBY VERSION
|
||||
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
|
||||
config.assets.allow_debugging = true
|
||||
|
||||
config.assets.check_precompiled_asset = false
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :contact do
|
||||
email "test@danbarberphoto.com"
|
||||
name "Dan Barber"
|
||||
message "This is a message."
|
||||
email { "test@danbarberphoto.com" }
|
||||
name { "Dan Barber" }
|
||||
message { "This is a message." }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :page do
|
||||
name "page"
|
||||
title "Page"
|
||||
content "This is a page."
|
||||
name { "page" }
|
||||
title { "Page" }
|
||||
content { "This is a page." }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :photo do
|
||||
title "A Photo"
|
||||
description "A lovely photo of a tree"
|
||||
image Rails.root.join("spec/fixtures/photo.jpg")
|
||||
title { "A Photo" }
|
||||
description { "A lovely photo of a tree" }
|
||||
image { Rails.root.join("spec/fixtures/photo.jpg") }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
email "test@example.com"
|
||||
password_digest "password"
|
||||
email { "test@example.com" }
|
||||
password_digest { "password" }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Category do
|
||||
it { should have_and_belong_to_many(:photos) }
|
||||
it { should validate_presence_of(:name) }
|
||||
it { should validate_presence_of(:slug) }
|
||||
it { should validate_uniqueness_of(:name) }
|
||||
it { should validate_uniqueness_of(:slug) }
|
||||
describe Category, type: :model do
|
||||
it { is_expected.to have_and_belong_to_many(:photos) }
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
it { is_expected.to validate_presence_of(:slug) }
|
||||
it { is_expected.to validate_uniqueness_of(:name) }
|
||||
it { is_expected.to validate_uniqueness_of(:slug) }
|
||||
|
||||
let(:category) { create(:category, name: "A Test Category") }
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
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(:name) }
|
||||
it { is_expected.to validate_presence_of(:message) }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Photo do
|
||||
describe Photo, type: :model do
|
||||
it { should have_and_belong_to_many(:categories) }
|
||||
|
||||
it { should validate_presence_of(:image) }
|
||||
|
||||
@ -3,14 +3,20 @@ ENV["RAILS_ENV"] ||= "test"
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require "rspec/rails"
|
||||
require "capybara/rspec"
|
||||
require "capybara/poltergeist"
|
||||
|
||||
# For code coverage
|
||||
require "simplecov"
|
||||
SimpleCov.start
|
||||
|
||||
# Use Poltergeist
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
# Use Firefox headless
|
||||
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,
|
||||
# in spec/support/ and its subdirectories.
|
||||
@ -70,3 +76,10 @@ RSpec.configure do |config|
|
||||
DatabaseCleaner.clean
|
||||
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