From 03cce5e25d2e183865e3cac78f03cd5432563679 Mon Sep 17 00:00:00 2001 From: Mohamed Wael Khobalatte Date: Fri, 2 Oct 2015 21:47:05 +0100 Subject: [PATCH] Avoid defining same constants in multiple specs --- spec/lib/custom_field_form_builder_spec.rb | 4 +--- spec/lib/journal_formatter/attachment_spec.rb | 4 +--- spec/lib/journal_formatter/custom_field_spec.rb | 4 +--- spec/lib/journal_formatter/diff_spec.rb | 4 +--- spec/lib/tabular_form_builder_spec.rb | 4 +--- spec/requests/api/v3/authentication_spec.rb | 6 +++--- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rb index 0a7a927f69..151f8ed5ce 100644 --- a/spec/lib/custom_field_form_builder_spec.rb +++ b/spec/lib/custom_field_form_builder_spec.rb @@ -29,12 +29,10 @@ require 'spec_helper' require 'ostruct' -TestViewHelper = Class.new(ActionView::Base) - describe CustomFieldFormBuilder do include Capybara::RSpecMatchers - let(:helper) { TestViewHelper.new } + let(:helper) { ActionView::Base.new } let(:resource) { FactoryGirl.build(:user, firstname: 'JJ', diff --git a/spec/lib/journal_formatter/attachment_spec.rb b/spec/lib/journal_formatter/attachment_spec.rb index c6c521ac26..bf8ed8c60a 100644 --- a/spec/lib/journal_formatter/attachment_spec.rb +++ b/spec/lib/journal_formatter/attachment_spec.rb @@ -40,13 +40,11 @@ describe OpenProject::JournalFormatter::Attachment do { only_path: true } end - Struct.new('TestJournal', :id) - let(:klass) { OpenProject::JournalFormatter::Attachment } let(:instance) { klass.new(journal) } let(:id) { 1 } let(:journal) do - Struct::TestJournal.new(id) + OpenStruct.new(id: id) end let(:user) { FactoryGirl.create(:user) } let(:attachment) { diff --git a/spec/lib/journal_formatter/custom_field_spec.rb b/spec/lib/journal_formatter/custom_field_spec.rb index 5cbf4258dc..fd3d28c3fd 100644 --- a/spec/lib/journal_formatter/custom_field_spec.rb +++ b/spec/lib/journal_formatter/custom_field_spec.rb @@ -32,13 +32,11 @@ describe OpenProject::JournalFormatter::CustomField do include CustomFieldsHelper include ActionView::Helpers::TagHelper - Struct.new('TestJournal', :id) - let(:klass) { OpenProject::JournalFormatter::CustomField } let(:instance) { klass.new(journal) } let(:id) { 1 } let(:journal) do - Struct::TestJournal.new(id) + OpenStruct.new(id: id) end let(:user) { FactoryGirl.create(:user) } let(:custom_field) { FactoryGirl.create(:issue_custom_field) } diff --git a/spec/lib/journal_formatter/diff_spec.rb b/spec/lib/journal_formatter/diff_spec.rb index 96a0b3b9d9..0db314436e 100644 --- a/spec/lib/journal_formatter/diff_spec.rb +++ b/spec/lib/journal_formatter/diff_spec.rb @@ -38,12 +38,10 @@ describe OpenProject::JournalFormatter::Diff do Rails.application.routes.url_helpers end - Struct.new('TestJournal', :id, :journable) - let(:klass) { OpenProject::JournalFormatter::Diff } let(:id) { 1 } let(:journal) do - Struct::TestJournal.new(id, WorkPackage.new) + OpenStruct.new(id: id, journable: WorkPackage.new) end let(:instance) { klass.new(journal) } let(:key) { 'description' } diff --git a/spec/lib/tabular_form_builder_spec.rb b/spec/lib/tabular_form_builder_spec.rb index 5ebe345933..b033b813c7 100644 --- a/spec/lib/tabular_form_builder_spec.rb +++ b/spec/lib/tabular_form_builder_spec.rb @@ -29,12 +29,10 @@ require 'spec_helper' require 'ostruct' -TestViewHelper = Class.new(ActionView::Base) - describe TabularFormBuilder do include Capybara::RSpecMatchers - let(:helper) { TestViewHelper.new } + let(:helper) { ActionView::Base.new } let(:resource) { FactoryGirl.build(:user, firstname: 'JJ', diff --git a/spec/requests/api/v3/authentication_spec.rb b/spec/requests/api/v3/authentication_spec.rb index ba16883d8e..4826db214a 100644 --- a/spec/requests/api/v3/authentication_spec.rb +++ b/spec/requests/api/v3/authentication_spec.rb @@ -44,7 +44,7 @@ describe API::V3, type: :request do let(:expected_message) { 'You need to be authenticated to access this resource.' } - Strategies = OpenProject::Authentication::Strategies::Warden + strategies = OpenProject::Authentication::Strategies::Warden def basic_auth(user, password) credentials = ActionController::HttpAuthentication::Basic.encode_credentials user, password @@ -148,7 +148,7 @@ describe API::V3, type: :request do let(:password) { 'toor' } before do - Strategies::GlobalBasicAuth.configure! user: 'root', password: 'toor' + strategies::GlobalBasicAuth.configure! user: 'root', password: 'toor' end it_behaves_like 'it is basic auth protected' @@ -190,7 +190,7 @@ describe API::V3, type: :request do before do config = { user: 'global_account', password: 'global_password' } - Strategies::GlobalBasicAuth.configure! config + strategies::GlobalBasicAuth.configure! config end context 'without credentials' do