Highlight Active Record abstract class and how to stub a null object in rails test :: unit / mocha?

I have two questions

1.How do I close the null object in rails test cases.

2.Mock Active Record Abstract Class

  • I have an X application with the X_test test database, now I need to close the y_test database, which does not exist and which implements an Active Record object and is an abstract class.

eg

Y::table.find_by_email("hello@gmail.com").selected_lan["iden"]

      module Y
        class table <Base
          belongs_to:selected_lan, :class =>lan
          def self.find_by_email(iden)
           find_by_email(license_iden)
          end
        end
     end

    module Y
       class Base <ActiveRecord::Base
         self.abstract_class = true
       end
    end
+5
source share
1 answer
Y::table.expects(:find_by_email).with('some@email.com').returns(nil)
+2
source

All Articles