Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
Merge branch '09_speedup' into 11_tdd
Browse files Browse the repository at this point in the history
  • Loading branch information
ruralocity committed Dec 14, 2014
2 parents dd24ed6 + 91e5896 commit 9394b4c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
--color
--warnings
--require spec_helper
--format documentation
12 changes: 7 additions & 5 deletions spec/controllers/contacts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions spec/features/about_us_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
10 changes: 5 additions & 5 deletions spec/models/contact_spec.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
13 changes: 7 additions & 6 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9394b4c

Please sign in to comment.