Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I used to work with hibernate too. The ActiveRecord way is very different from hibernate. You need to set your mind free, for better or for worse. In java and Hibernate you often have the aggregate root and the object graph. Generally, both the object graphs and code base are smaller in ruby somehow too. I don't know your particular case, so I'll tread carefully, but I warn you to try fit ruby, and rails, to your java habits.</p> <p>You may use custom directories with rspec to organize in a way that makes sense for you and your team. </p> <pre><code>#spec/queries/my_custom_search_spec.rb require 'spec_helper' describe MyModel do it "should do this query and return X" do subject.some_defined_scope_search.should == "something" end end </code></pre> <p>and you may have subdirectories, automatically getting picked up by rspec, like <code>spec/models/account/..</code></p> <p>The spec will automatically be picked up by <code>rake spec</code> or <code>rspec spec</code>. I just wrote a simple example above, as I don't know your case. Do you define scopes with queries, or define specialized methods? </p> <p>I strongly recommend abandoning the fixtures (same as the inserts - anti pattern, to me) for something more refactorable, like factories. I like <a href="https://github.com/thoughtbot/factory_girl" rel="nofollow">factory_girl</a>. It let's your app evolve in a more agile manner, IMO.</p> <p>EDIT: adding my spec_helper.rb with settings for enable/disable automatic cleanup</p> <pre><code>RSpec.configure do |config| require 'database_cleaner' config.add_setting :skip_database_clean config.skip_database_clean = false config.before(:suite) do DatabaseCleaner.strategy = :truncation end config.before(:each) do end config.after(:each) do MongoMapper.database.collections.each(&amp;:remove) DatabaseCleaner.clean unless config.skip_database_clean end </code></pre> <p>I add the variable <code>skip_database_clean</code> so that I can enable/disable the autocleanup after each spec (each "it"). </p> <pre><code> before :all do @an_object = some_expensive_test_buildup RSpec.configuration.skip_database_clean = true end after :all do RSpec.configuration.skip_database_clean = false DatabaseCleaner.clean end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload