diff --git a/app/forms/edit_event_form.rb b/app/forms/edit_event_form.rb index ab3a5f75..49f3cebd 100644 --- a/app/forms/edit_event_form.rb +++ b/app/forms/edit_event_form.rb @@ -136,7 +136,6 @@ def initialize(event) :url, :venue_id, :social_organiser_id, - :social_organiser_id, :class_style, :course_length, :class_organiser_id, diff --git a/spec/models/info_page_spec.rb b/spec/models/info_page_spec.rb index 4dfe51e2..420fa0a2 100644 --- a/spec/models/info_page_spec.rb +++ b/spec/models/info_page_spec.rb @@ -15,7 +15,7 @@ content: %w[about_bristol bristol_history] } } - pages = instance_double("InfoPages", page: config) + pages = instance_double("InfoPage::InfoPages", page: config) page = described_class.new(:about, pages:, city: :london) @@ -40,7 +40,7 @@ sidebar: %w[lindy_hop about_us_bristol] } } - pages = instance_double("InfoPages", page: config) + pages = instance_double("InfoPage::InfoPages", page: config) page = described_class.new(:about, pages:, city: :bristol) diff --git a/spec/presenters/associated_event_spec.rb b/spec/presenters/associated_event_spec.rb index a18050a2..1284d5a1 100644 --- a/spec/presenters/associated_event_spec.rb +++ b/spec/presenters/associated_event_spec.rb @@ -18,7 +18,7 @@ describe "#link" do it "links to the event" do event = instance_double("Event") - url_helpers = instance_double("Rails.application.routes.url_helpers") + url_helpers = double("Rails.application.routes.url_helpers") # rubocop:disable RSpec/VerifiedDoubles allow(url_helpers).to receive(:event_path).with(event).and_return("/path/to/event") associated_event = described_class.new(event, summarizer: double, url_helpers:) diff --git a/spec/presenters/maps/social_listing_spec.rb b/spec/presenters/maps/social_listing_spec.rb index 562f3606..701d3f7e 100644 --- a/spec/presenters/maps/social_listing_spec.rb +++ b/spec/presenters/maps/social_listing_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Maps::SocialListing do describe ".has_class?" do it "delegates to the given event" do - has_class = instance_double("Boolean") + has_class = double("Boolean") # rubocop:disable RSpec/VerifiedDoubles event = instance_double("Event", has_class?: has_class) social_listing = described_class.new(event, url_helpers: double) @@ -20,7 +20,7 @@ describe ".has_taster?" do it "delegates to the given event" do - has_taster = instance_double("Boolean") + has_taster = double("Boolean") # rubocop:disable RSpec/VerifiedDoubles event = instance_double("Event", has_taster?: has_taster) social_listing = described_class.new(event, url_helpers: double) diff --git a/spec/presenters/social_listing_spec.rb b/spec/presenters/social_listing_spec.rb index 29f380fb..0c7db35f 100644 --- a/spec/presenters/social_listing_spec.rb +++ b/spec/presenters/social_listing_spec.rb @@ -132,7 +132,7 @@ describe ".new?" do it "delegates to the given event" do - new = instance_double("Boolean") + new = double("Boolean") # rubocop:disable RSpec/VerifiedDoubles event = instance_double("Event", new?: new) social_listing = described_class.new(event, url_helpers: double) diff --git a/spec/services/session_creator_spec.rb b/spec/services/session_creator_spec.rb index 1e0b3a31..d1ba08d2 100644 --- a/spec/services/session_creator_spec.rb +++ b/spec/services/session_creator_spec.rb @@ -7,7 +7,7 @@ describe "#create" do context "when the user has a role in the system" do it "logs the user in" do - authoriser = instance_double("described_class::Authoriser", authorised?: true) + authoriser = instance_double("SessionCreator::Authoriser", authorised?: true) login_session = instance_double("LoginSession", log_in!: double) creator = described_class.new(authoriser:, login_session:, logger: fake_logger) @@ -25,7 +25,7 @@ end it "returns true" do - authoriser = instance_double("described_class::Authoriser", authorised?: true) + authoriser = instance_double("SessionCreator::Authoriser", authorised?: true) login_session = instance_double("LoginSession", log_in!: double) creator = described_class.new(authoriser:, login_session:, logger: fake_logger) @@ -38,7 +38,7 @@ context "when the user doesn't have a role in the system" do it "does not log the user in" do - authoriser = instance_double("described_class::Authoriser", authorised?: false) + authoriser = instance_double("SessionCreator::Authoriser", authorised?: false) login_session = instance_double("LoginSession", log_in!: double) creator = described_class.new(authoriser:, login_session:, logger: fake_logger) @@ -49,7 +49,7 @@ end it "returns false" do - authoriser = instance_double("described_class::Authoriser", authorised?: false) + authoriser = instance_double("SessionCreator::Authoriser", authorised?: false) login_session = instance_double("LoginSession", log_in!: double) creator = described_class.new(authoriser:, login_session:, logger: fake_logger) @@ -60,7 +60,7 @@ end it "logs" do - authoriser = instance_double("described_class::Authoriser", authorised?: false) + authoriser = instance_double("SessionCreator::Authoriser", authorised?: false) login_session = instance_double("LoginSession", log_in!: double) logger = fake_logger creator = described_class.new(authoriser:, login_session:, logger:) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c16e722f..075b2ea3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,6 +20,10 @@ config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true + if config.files_to_run.count > 1 + # Don't verify that doubled objects exist if only runnig one file + mocks.verify_doubled_constant_names = true + end end # used for --seed when randomising specs diff --git a/spec/support/time_formats_helper.rb b/spec/support/time_formats_helper.rb index 92d17626..55aa25c7 100644 --- a/spec/support/time_formats_helper.rb +++ b/spec/support/time_formats_helper.rb @@ -6,9 +6,12 @@ require "active_support/core_ext/time/conversions" require "active_support/core_ext/integer/inflections" -# Allow reference to translations in isolated specs: -%w[en.yml en.rb].each do |locale_file| - I18n.load_path.push( - File.expand_path(locale_file, File.expand_path("../../config/locales", __dir__)) - ) +locale_files = %w[en.yml en.rb].map do |locale_file| + File.expand_path(locale_file, File.expand_path("../../config/locales", __dir__)) +end + +# Allow reference to translations in isolated specs, +# but only load the files if they're not already in the load path +locale_files.each do |file| + I18n.load_path.push(file) unless I18n.load_path.include?(file) end