Guest User

Untitled

a guest
May 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. %w(rubygems active_record spec sqlite3).each {|lib| require lib}
  2.  
  3. ActiveRecord::Base.establish_connection({:adapter => 'sqlite3',
  4. :database => 'rtest.sqlite3'
  5. })
  6.  
  7. # ActiveRecord transactional specs (without Rails)
  8. Spec::Runner.configure do |config|
  9. config.before do
  10. ActiveRecord::Base.connection.begin_db_transaction
  11. ActiveRecord::Base.connection.increment_open_transactions
  12. end
  13. config.after do
  14. if ActiveRecord::Base.connection.open_transactions != 0
  15. ActiveRecord::Base.connection.rollback_db_transaction
  16. ActiveRecord::Base.connection.decrement_open_transactions
  17. end
  18. end
  19. end
  20.  
  21. class Joon < ActiveRecord::Base
  22. end
  23.  
  24. describe "test to see if the data saves" do
  25. it "should remove the data once this is done" do
  26. Joon.new({:name => 'Sydney', :status => 'daughter'}).save
  27. Joon.all.size.should eql(3)
  28. end
  29. end
Add Comment
Please, Sign In to add comment