Skip to content

Commit

Permalink
wth - Model Specs instantiated incorrectly
Browse files Browse the repository at this point in the history
Many of our model specs begin with something like this:
RSpec.describe 'Protocol' do
When they should be something like this:
Rspec describe Protocol, type: :model do
Both work, but I found that the easy way to test model validations using
shoulda-matchers doesn't work using the string syntax.

[#147443143]

Story - https://www.pivotaltracker.com/story/show/147443143
  • Loading branch information
William Holt committed Jul 11, 2017
1 parent 4fa8ce6 commit 28e37bb
Show file tree
Hide file tree
Showing 48 changed files with 58 additions and 64 deletions.
2 changes: 1 addition & 1 deletion spec/models/arm/name_equals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@

expect(arm.name).to eq("name with spaces 1 + 2 1+2")
end
end
end
2 changes: 1 addition & 1 deletion spec/models/arm/validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@
expect(arm.errors.full_messages[0]).to eq("Subject count must be greater than 0")
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe 'Catalog' do
RSpec.describe Catalog, type: :model do
context "providers and programs with valid pricing setups" do
let!(:institution) { create(:institution) }
let!(:provider1) { create(:provider, parent_id: institution.id) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/cover_letter_sanitizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require 'rails_helper'

RSpec.describe CoverLetterSanitizer do
RSpec.describe CoverLetterSanitizer, type: :model do
subject(:sanitizer){ CoverLetterSanitizer.new }
it 'strips out <em> tags, but leaves the contents of those tags' do
expect(sanitizer.sanitize("<p>hello <em>world</em></p>")).to eq "<p>hello world</p>"
Expand Down
2 changes: 1 addition & 1 deletion spec/models/cover_letter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe CoverLetter do
RSpec.describe CoverLetter, type: :model do
it{ should belong_to :sub_service_request }
it{ should validate_presence_of :content }
end
2 changes: 1 addition & 1 deletion spec/models/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe Document do
RSpec.describe Document, type: :model do
it { should belong_to(:protocol) }
it { should have_and_belong_to_many(:sub_service_requests) }

Expand Down
6 changes: 0 additions & 6 deletions spec/models/feedback_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/models/identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe "Identity" do
RSpec.describe Identity, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_project
Expand Down
2 changes: 1 addition & 1 deletion spec/models/invalid_identities_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

RSpec.describe InvalidIdentities do
RSpec.describe InvalidIdentities, type: :model do
describe '#remove_from_db' do
it 'should delete identities if they meet requirements for deletion' do
identity = create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'rails_helper'

RSpec.describe 'LineItem' do
RSpec.describe LineItem, type: :model do
let!(:logged_in_user) { create(:identity) }

before :each do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/line_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require 'rails_helper'

RSpec.describe "Line Item" do
RSpec.describe LineItem, type: :model do

let_there_be_lane
let_there_be_j
Expand Down
2 changes: 1 addition & 1 deletion spec/models/line_items_counter_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe "Line items counter cache" do
RSpec.describe LineItem, type: :model do

let!(:new_service) { create(:service, name: "New Service") }
let!(:service_request) { FactoryGirl.create(:service_request_without_validations) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/line_items_visit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe LineItemsVisit do
RSpec.describe LineItemsVisit, type: :model do

let_there_be_lane
let_there_be_j
Expand Down
2 changes: 1 addition & 1 deletion spec/models/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require "rails_helper"

RSpec.describe Notification do
RSpec.describe Notification, type: :model do
describe ".of_ssr" do
context "with :sub_service_request_id" do
it "should return all Notifications belonging to SubServiceRequest" do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'organization' do
RSpec.describe Organization, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_project
Expand Down
2 changes: 1 addition & 1 deletion spec/models/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require 'rails_helper'

RSpec.describe Payment do
RSpec.describe Payment, type: :model do
it{ should validate_presence_of :date_submitted }
it{ should validate_numericality_of :amount_invoiced }
it{ should validate_numericality_of :amount_received }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/pricing_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require 'rails_helper'

RSpec.describe 'PricingMap' do
RSpec.describe PricingMap, type: :model do

describe "validations" do
let!(:core) { create(:core) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/pricing_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe 'PricingSetup' do
RSpec.describe PricingSetup, type: :model do
describe 'rate_type' do
[
'college',
Expand Down
2 changes: 1 addition & 1 deletion spec/models/program_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe Program do
RSpec.describe Program, type: :model do
describe "has_pricing_setup" do
context 'neither program nor parent provider has a pricing setup' do
it 'should return false' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/project_role/project_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe 'Project Role' do
RSpec.describe ProjectRole, type: :model do

let!(:user) {create(:identity)}
let!(:user2) {create(:identity)}
Expand Down
4 changes: 2 additions & 2 deletions spec/models/protocol/activate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand All @@ -42,4 +42,4 @@
end
end
end
end
end
4 changes: 2 additions & 2 deletions spec/models/protocol/active?_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -78,4 +78,4 @@
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down
4 changes: 2 additions & 2 deletions spec/models/protocol/funding_source_based_on_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -61,4 +61,4 @@
expect(lambda { study.funding_source_based_on_status }).to raise_exception ArgumentError
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let!(:logged_in_user) { create(:identity) }

before :each do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/protocol/notify_remote_around_update?_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -56,4 +56,4 @@
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/protocol/push_to_epic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down
2 changes: 1 addition & 1 deletion spec/models/protocol/valid?_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@

it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(0) }
it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_less_than_or_equal_to(1000) }
end
end
4 changes: 2 additions & 2 deletions spec/models/protocol/version_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -68,4 +68,4 @@
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/protocol/with_organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down
2 changes: 1 addition & 1 deletion spec/models/protocol/with_owner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down
2 changes: 1 addition & 1 deletion spec/models/protocol/with_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down
2 changes: 1 addition & 1 deletion spec/models/protocol_authorizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
require 'date'
require 'rails_helper'

RSpec.describe 'ProtocolAuthorizer', type: :model do
RSpec.describe ProtocolAuthorizer, type: :model do
# data that can be setup and references memoized
# these can persist between tests
def protocol
Expand Down
2 changes: 1 addition & 1 deletion spec/models/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe Report do
RSpec.describe Report, type: :model do
it { should have_attached_file :xlsx }
it { should belong_to :sub_service_request }
end
2 changes: 1 addition & 1 deletion spec/models/service_request/update_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,4 @@
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/models/service_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require 'rails_helper'

RSpec.describe 'ServiceRequest' do
RSpec.describe ServiceRequest, type: :model do

let_there_be_lane
let_there_be_j
Expand Down
4 changes: 2 additions & 2 deletions spec/models/study/determine_study_type_note_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -50,4 +50,4 @@ def update_answers (answer_array)
answer6_version_3.update_attributes(answer: answer_array[5])
answer7_version_3.update_attributes(answer: answer_array[6])
end
end
end
4 changes: 2 additions & 2 deletions spec/models/study/determine_study_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -98,4 +98,4 @@ def update_answers (version, answer_array)
answer6_version_1.update_attributes(answer: answer_array[5])
end
end
end
end
4 changes: 2 additions & 2 deletions spec/models/study/display_answers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'rails_helper'

RSpec.describe 'Protocol' do
RSpec.describe Protocol, type: :model do
let_there_be_lane
let_there_be_j
build_service_request_with_study()
Expand Down Expand Up @@ -96,4 +96,4 @@ def update_answers (version, answer_array)
answer6_version_1.update_attributes(answer: answer_array[5])
end
end
end
end

0 comments on commit 28e37bb

Please sign in to comment.