diff --git a/.rspec b/.rspec index e67c38c9..43ae2036 100644 --- a/.rspec +++ b/.rspec @@ -1,4 +1,3 @@ --color ---warnings --require spec_helper --format documentation diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 4e63f038..501380c9 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -138,9 +138,9 @@ context "with invalid attributes" do it "does not save the new contact in the database" do expect{ - post :create, contact: - attributes_for(:invalid_contact) - }.to_not change(Contact, :count) + post :create, + contact: attributes_for(:invalid_contact) + }.not_to change(Contact, :count) end it "re-renders the :new template" do @@ -161,8 +161,10 @@ context "valid attributes" do it "locates the requested @contact" do - allow(contact).to receive(:update).with(valid_attributes.stringify_keys) { true } - patch :update, id: @contact, contact: valid_attributes + allow(contact).to \ + receive(:update).with(valid_attributes.stringify_keys) { true } + patch :update, id: @contact, + contact: attributes_for(:contact) expect(assigns(:contact)).to eq @contact end diff --git a/spec/features/about_us_spec.rb b/spec/features/about_us_spec.rb index 3d8f6240..84435ccd 100644 --- a/spec/features/about_us_spec.rb +++ b/spec/features/about_us_spec.rb @@ -4,8 +4,8 @@ scenario "toggles display of the modal about display", js: true do visit root_path - expect(page).to_not have_content 'About BigCo' - expect(page).to_not \ + expect(page).not_to have_content 'About BigCo' + expect(page).not_to \ have_content 'BigCo produces the finest widgets in all the land' click_link 'About Us' @@ -18,8 +18,8 @@ click_button 'Close' end - expect(page).to_not have_content 'About BigCo' - expect(page).to_not \ + expect(page).not_to have_content 'About BigCo' + expect(page).not_to \ have_content 'BigCo produces the finest widgets in all the land' end end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index bbb64877..4b1d1e54 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' describe Contact do - it "is has a valid factory" do + it "has a valid factory" do expect(build(:contact)).to be_valid end - it { should validate_presence_of :firstname } - it { should validate_presence_of :lastname } - it { should validate_presence_of :email } - it { should validate_uniqueness_of(:email) } + it { is_expected.to validate_presence_of :firstname } + it { is_expected.to validate_presence_of :lastname } + it { is_expected.to validate_presence_of :email } + it { is_expected.to validate_uniqueness_of(:email) } it "returns a contact's full name as a string" do contact = build_stubbed(:contact, diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ee930d79..6571e07b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -29,15 +29,16 @@ # Include custom login macros config.include LoginMacros - # Set config.use_transactional_fixtures to false - config.use_transactional_fixtures = false - + # Configure DatabaseCleaner to reset data between tests config.before(:suite) do - DatabaseCleaner.strategy = :truncation + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean_with :truncation end - config.before(:each) do - DatabaseCleaner.start + config.around(:each) do |example| + DatabaseCleaner.cleaning do + example.run + end end config.after(:each) do