Make sure to use apparition for system specs

rpp-main
rebuilt 3 years ago
parent 4bf61fb7b1
commit a9316f18cb

@ -1,18 +1,18 @@
require 'simplecov' require "simplecov"
SimpleCov.start do SimpleCov.start do
add_filter '/app/models/legacy' add_filter "/app/models/legacy"
add_filter '/app/views/legacy' add_filter "/app/views/legacy"
add_filter '/app/controllers/legacy' add_filter "/app/controllers/legacy"
add_filter '/spec/models/legacy' add_filter "/spec/models/legacy"
add_filter '/spec/views/legacy' add_filter "/spec/views/legacy"
add_filter '/spec/controllers/legacy' add_filter "/spec/controllers/legacy"
add_filter '/app/helpers/schedules_helper.rb' add_filter "/app/helpers/schedules_helper.rb"
add_filter '/lib/tasks/survey.rake' add_filter "/lib/tasks/survey.rake"
add_filter '/spec/lib/tasks/survey_rake_spec.rb' add_filter "/spec/lib/tasks/survey_rake_spec.rb"
end end
require 'capybara/rspec' require "capybara/rspec"
require 'capybara/apparition' require "capybara/apparition"
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause # The generated `.rspec` file contains `--require spec_helper` which will cause
@ -68,7 +68,7 @@ RSpec.configure do |config|
config.include Capybara::DSL config.include Capybara::DSL
config.before(:each, type: :system) do config.before(:each, type: :system) do
driven_by :rack_test driven_by :apparition
end end
config.before(:each, js: true) do config.before(:each, js: true) do
@ -89,7 +89,7 @@ RSpec.configure do |config|
# # Allows RSpec to persist some state between runs in order to support # # Allows RSpec to persist some state between runs in order to support
# # the `--only-failures` and `--next-failure` CLI options. We recommend # # the `--only-failures` and `--next-failure` CLI options. We recommend
# # you configure your source control system to ignore this file. # # you configure your source control system to ignore this file.
config.example_status_persistence_file_path = 'spec/examples.txt' config.example_status_persistence_file_path = "spec/examples.txt"
# #
# # Limits the available syntax to the non-monkey patched syntax that is # # Limits the available syntax to the non-monkey patched syntax that is
# # recommended. For more details, see: # # recommended. For more details, see:
@ -126,7 +126,7 @@ RSpec.configure do |config|
# Kernel.srand config.seed # Kernel.srand config.seed
config.before(:each) do config.before(:each) do
stub_const('Twilio::REST::Client', FakeSMS) stub_const("Twilio::REST::Client", FakeSMS)
end end
config.after(:each) do config.after(:each) do
@ -134,14 +134,15 @@ RSpec.configure do |config|
end end
end end
require 'active_support/all' require "active_support/all"
class FakeSMS class FakeSMS
Message = Struct.new(:from, :to, :body) Message = Struct.new(:from, :to, :body)
cattr_accessor :messages cattr_accessor :messages
self.messages = [] self.messages = []
def initialize(_account_sid, _auth_token); end def initialize(_account_sid, _auth_token)
end
def self.reset def self.reset
self.messages = [] self.messages = []
@ -158,7 +159,7 @@ class FakeSMS
def get(sid) def get(sid)
phone = self.class.messages[sid].to phone = self.class.messages[sid].to
phone = "+1#{phone}" unless phone.starts_with?('+1') phone = "+1#{phone}" unless phone.starts_with?("+1")
Struct.new(:to).new(phone) Struct.new(:to).new(phone)
end end
end end
@ -168,7 +169,7 @@ def create_recipients(school, count)
count.times do |i| count.times do |i|
recipients << school.recipients.create( recipients << school.recipients.create(
name: "Person#{i}", name: "Person#{i}",
phone: '+' + (i.to_s * 10) phone: "+" + (i.to_s * 10)
) )
end end
recipients recipients

Loading…
Cancel
Save