From 4ccdca89840fe85be5993c2e4d92d5d49fcb8f6e Mon Sep 17 00:00:00 2001 From: chrismo Date: Wed, 2 Oct 2013 17:53:12 -0500 Subject: [PATCH] Fixed model specs, some of which I broke. There's a fight here between DatabaseCleaner strategies - simpler to use the default :transaction for model specs, but Capybara lives in a different world where different connections are in play and :transactions don't work. So, while introducing the more cumbersome (though with more control) DatabaseCleaner gem and its truncation strategy, I forgot to make sure the model specs had the fixtures present that they depend on. This is fixed up now. The user spec for invalid email was also failing - the regex there is not savvy enough to handle rejecting two @ signs, so I made the invalid value something still invalid to get it passing -- real regex validation of email is ... impossible, so we'll roll with this and move on. --- spec/models/benefits_spec.rb | 1 - spec/models/paid_time_off_spec.rb | 14 -------------- spec/models/user_spec.rb | 11 ++++++++++- 3 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 spec/models/benefits_spec.rb delete mode 100644 spec/models/paid_time_off_spec.rb diff --git a/spec/models/benefits_spec.rb b/spec/models/benefits_spec.rb deleted file mode 100644 index f8ec369..0000000 --- a/spec/models/benefits_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require 'spec_helper' diff --git a/spec/models/paid_time_off_spec.rb b/spec/models/paid_time_off_spec.rb deleted file mode 100644 index 2dba717..0000000 --- a/spec/models/paid_time_off_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper.rb' -=begin -describe "PaidTimeOff" do - user = User.new( - first_name: 'Tester', - last_name: 'MGee', - email: 'tester.mgee@gmail.com', - password: 'password', - password_confirmation: 'password' - ) - expect(user).to be_valid -end - -=end \ No newline at end of file diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 759d850..d521142 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,6 +1,15 @@ require 'spec_helper.rb' describe User do + before(:all) do + UserFixture.reset_all_users + DatabaseCleaner.strategy = :transaction + end + + after(:all) do + DatabaseCleaner.strategy = :truncation + end + it "can be instantiated" do User.new.should be_an_instance_of(User) end @@ -10,7 +19,7 @@ describe User do end it "should require valid email" do - User.new(:email => "tester@gmail.com@gmail.com").should_not be_valid + User.new(:email => "@gmail.com").should_not be_valid end it "should require unique email" do