NoBrainerORM/nobrainer

Fixtures?

Closed this issue · 4 comments

Is it possible to use fixtures with the NoBrainer ORM when testing? I have not been successful trying to get this to work. On Github- rethinkdb/rails-nobrainer-blog has the file './test/test_helper.rb'

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  #
  # Note: You'll currently still have to declare fixtures explicitly in integration tests
  # -- they do not yet inherit this setting
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

How do I declare fixtures explicitly? (I've pasted the below line from above)
Note: You'll currently still have to declare fixtures explicitly in integration tests

You should be able to use fixtures. I've never used them, so I don't know how they work.
I've always used Factory Girl, and works great with it.

Sorry for the delayed response-
When I run tests with Ruby, Rails, & NoBrainer out of the box:
localhost-2:react Stephan$ rake test

rake aborted!
NoMethodError: undefined method `fixtures' for ActiveSupport::TestCase:Class
/Users/Stephan/ruby/react/test/test_helper.rb:7:in `<class:TestCase>'
/Users/Stephan/ruby/react/test/test_helper.rb:5:in `<top (required)>'
/Users/Stephan/ruby/react/test/models/blog_image_test.rb:1:in `require'
/Users/Stephan/ruby/react/test/models/blog_image_test.rb:1:in `<top (required)>'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:11:in `require'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in `each'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/minitest_plugin.rb:62:in `rake_run'
/Users/Stephan/.rvm/gems/ruby-2.4.0/gems/railties-5.0.2/lib/rails/test_unit/testing.rake:15:in `block in <top (required)>'
/Users/Stephan/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)

It appears the line 7 in test_helper.rb (*see below for full file code):
fixtures :all
causes some sort of problem when running tests. I haven't been able to find a work around to load the fixtures. Currently, to allow testing, I have that line of test_helper.rb commented out.

Any thoughts so I can work with fixtures instead of defining them in each unit test file?

*Note: Here is test_helper.rb for reference:

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

I've never used fixtures, so I'm afraid I'm useless here

For the record, one could check this SO in order to see if fixtures are working with nobrainer.