From c84c99f9933431dcc2e7b3d3b0f153db11e706d1 Mon Sep 17 00:00:00 2001 From: maxwell Date: Sun, 13 Jun 2010 16:12:32 -0700 Subject: [PATCH] created the rspec runner so you dont have to worry about cleaning mongoid every run completed chore MS --- spec/controllers/users_controller_spec.rb | 5 +---- spec/models/misc_spec.rb | 27 +++++++++++++++++++++++ spec/spec_helper.rb | 3 +++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 spec/models/misc_spec.rb diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 401d50a17..d35a395a5 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -3,10 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe UsersController do render_views #fixtures here? - it 'should, after logging in redirect to the dashboard page' do - post 'index' - puts "boner!" - end + end end diff --git a/spec/models/misc_spec.rb b/spec/models/misc_spec.rb new file mode 100644 index 000000000..abbf71e45 --- /dev/null +++ b/spec/models/misc_spec.rb @@ -0,0 +1,27 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe 'making sure the spec runner works' do + + it 'should not delete the database mid-spec' do + User.count.should == 0 + billy = User.create(:email => "billy@aol.com", :password => "foobar") + User.count.should == 1 + end + + it 'should make sure the last user no longer exsists' do + User.count.should == 0 + end + + describe 'testing a before do block' do + before do + @bill = User.create(:email => "billy@aol.com", :password => "foobar") + + end + + it 'should have cleaned before the before do block runs' do + User.count.should == 1 + end + + end + +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b652dadd1..341d78949 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,6 +19,9 @@ Rspec.configure do |config| config.mock_with :rspec config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.before(:each) do + Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop) + end # If you're not using ActiveRecord, or you'd prefer not to run each of your