Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After days of beating my head against the wall, I have everything mostly working (I say mostly working because I'm not sure if there is something wrong that I haven't discovered yet). The fix was actually pretty simple once I figured it out.</p> <p>To resolve the issue, and get my <a href="http://cukes.info/" rel="nofollow noreferrer">cucumber</a> steps working with <a href="http://github.com/ianwhite/pickle" rel="nofollow noreferrer">pickle</a>, I changed <code>MongoMapper::Document</code> to include <code>Pickle::Adapter::Base</code>. I used lib/pickle/adapters/active_record.rb and data_mapper.rb (same path as active_record.rb) that come with <a href="http://github.com/ianwhite/pickle" rel="nofollow noreferrer">pickle</a> as an example. I did still need <a href="http://github.com/nmerouze/machinist_mongo" rel="nofollow noreferrer">machinist_mongo</a>, presumably to hook up pickle to my machinist blueprints.</p> <p>I can't take credit for the code in <code>def self.model_classes</code> - it is stolen from <a href="http://github.com/tjtuom/pickle/blob/master/lib/pickle/adapter.rb" rel="nofollow noreferrer">tjtuom's pickle fork</a>.</p> <p>PS. If this is the completely wrong way to do it, please feel free to criticize or give suggestions, I am a complete ruby noob.</p> <pre><code>module MongoMapper::Document module PickleAdapter include Pickle::Adapter::Base def self.model_classes @@model_classes ||= ::MongoMapper::Document.descendants.to_a + ::MongoMapper::Document.descendants.map { |klass| klass.subclasses }.flatten end # get a list of column names for a given class def self.column_names(klass) klass.column_names end # Get an instance by id of the model def self.get_model(klass, id) klass.find(id) end # Find the first instance matching conditions def self.find_first_model(klass, conditions) klass.find(:first, :conditions =&gt; conditions) end # Find all models matching conditions def self.find_all_models(klass, conditions) klass.find(:all, :conditions =&gt; conditions) end end end </code></pre> <p>Set up pickle for machinist:</p> <pre><code>Pickle.configure do |config| config.adapters = [:machinist] end </code></pre> <p>To configure <a href="http://github.com/bmabey/database_cleaner" rel="nofollow noreferrer">database_cleaner</a> for mongo:</p> <pre><code>require 'database_cleaner' require 'database_cleaner/cucumber' DatabaseCleaner.orm = 'mongo_mapper' DatabaseCleaner.strategy = :truncation </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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