ruby on rails - inserting binding.pry changes which rspec tests pass -


tl;dr: trying test correct items added array. when ran test, said things being added array indiscriminately. however, when put binding.pry in first line of lessonpackage.available, tests pass... now, 2 other tests fail.

now here's code.

in original test, test correct number of items added array. tests :current scope. here's test:

describe 'manage multiple lessons'   before :all     @six_package = create(:lesson_package)     @thirteen_package = create(:lesson_package, name: 'thirteen', number_of_lessons: 13)     @old_package = create(:lesson_package, name: 'canceled', current: false)     @instructor = create(:instructor, base_lesson_price: 50, contract_rate: 40)   end    context 'available'     'return array of available package managers when given defaults'       packages = lessonpackage.available(@instructor)       packages.length.should 2       packages[0].class.should lessonpackagemanager     end   end end 

notice @old_package should have 'current' attribute of false. here's code under test:

class lessonpackage < activerecord::base   ...   scope :current, where(current: true)   ...   def self.available(instructor, method = 'self', lesson_type = 'private')     lessonpackage.current.map |package|       manager = lessonpackagemanager.make_package(instructor, package, lesson_type)       manager.send(method)     end   end end 

the test fails! know code works, not because works in development mode, because when put binding.pry in first line of lessonpackage.available, works! test broken:

describe 'managed lesson'   before :all     @six_package = create(:lesson_package)     @instructor = create(:instructor, base_lesson_price: 50, contract_rate: 35)   end      describe 'booking lessons student'       before :each         @student = create(:student, area: 'herethere')         package_manager = lessonpackage.manage('six', @instructor)         package_manager.add_to_cart(@student)       end        subject {lessonbooking.first}        its(:lesson_package)    {should eq @six_package}     end   end end 

the reason given lesson package attached first lesson booking has different id original lesson package created. note: test working before. thing different binding.pry.

i'm using database_cleaner, , how have configured:

  config.before(:suite)     databasecleaner.strategy = :transaction     databasecleaner.clean_with(:truncation)   end    config.before(:each)     databasecleaner.start   end    config.after(:each)     databasecleaner.clean   end 


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -