Note that there are some explanatory texts on larger screens.

plurals
  1. POPadrino and RSpec don't work with Sequel?
    primarykey
    data
    text
    <p>Recently, I've started diving into Ruby MVCs, in order to find the best, fastest, most minimal framework to build my app. Being unsatisfied with Rails, I decided to try out <a href="http://www.padrinorb.com" rel="nofollow">Padrino</a>. I'm also trying out Outside-in TDD for a full app for the first time, so being able to write tests for all components is critical. Unfortunately, I cannot get past making models in Padrino, so I'm wondering if it's just a cause of beta software, or just error on my part.</p> <p>I start off by creating my project with Cucumber and RSpec for testing and Sequel for my ORM.</p> <pre><code>$ padrino g project test -d sequel -t cucumber -c sass -b </code></pre> <p>Next, I create some model and migration:</p> <pre><code>$ padrino g model user # ./db/migrate/001_create_users.rb Sequel.migration do change do create_table :users do primary_key :id String :name String :password end end end </code></pre> <p>Next, of course, comes the spec. For sake of example, just something simple:</p> <pre><code># ./spec/models/user_spec.rb require 'spec_helper' describe User do it 'can be created' do user = User.create end end </code></pre> <p>Now, migrate and run the spec:</p> <pre><code>$ padrino rake sq:migrate:up $ rspec spec F Failures: 1) User can be created Failure/Error: user = User.create Sequel::DatabaseError: SQLite3::SQLException: no such table: users # ./spec/models/user_spec.rb:5:in `block (2 levels) in &lt;top (required)&gt;' Finished in 0.00169 seconds 1 example, 1 failure Failed examples: rspec ./spec/models/user_spec.rb:4 # User can be created </code></pre> <p>This is very confusing. It was at this point that I thought going into the Padrino console would help me solve this strange issue. I was wrong.</p> <pre><code>$ padrino c &gt; User.create =&gt; #&lt;User @values={:id=&gt;1, :name=&gt;nil, :password=&gt;nil}&gt; &gt; User.all =&gt; [#&lt;User @values={:id=&gt;1, :name=&gt;nil, :password=&gt;nil}&gt;] </code></pre> <p>Fair enough results, but then I try it with the <code>test</code> environment:</p> <pre><code>$ padrino c -e test &gt; User.create Sequel::DatabaseError: SQLite3::SQLException: no such table: users </code></pre> <p>I know that in RoR, to get integrated models to run, you have to do something like <code>rake db:test:prepare</code>, but doing <code>padrino rake -T</code> doesn't seem to reveal any equivalent (tested with Sequel, DataMapper, and ActiveRecord; none seem to have the <code>db:test:prepare</code>). So, my question is: how do I get integrated database tests running within Padrino?</p>
    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.
    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