Shoulda not working in Padrino, fails with undefined method `delegate'

452 views Asked by At

I've recently set up a couple of Padrino projects and each time I generated the project, I used Shoulda as the test option. But when I try to run 'padrino rake test,' it fails with the following error:

Sonnys-MacBook-Pro:sample_blog sonnyjitsu$ padrino rake test
=> Executing Rake test ...
/Users/sonnyjitsu/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -I"lib" -I"/Users/sonnyjitsu/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib" "/Users/sonnyjitsu/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.0/lib/rake/rake_test_loader.rb" "test/app/**/*_test.rb" 
/Users/sonnyjitsu/.rvm/gems/ruby-2.0.0-p353/gems/shoulda-matchers-2.4.0/lib/shoulda/matchers/active_record/association_matcher.rb:77:in `<class:AssociationMatcher>': undefined method `delegate' for Shoulda::Matchers::ActiveRecord::AssociationMatcher:Class (NoMethodError)

Here is my gem list

    actionmailer (4.0.1, 3.2.3)
    actionpack (4.0.1, 3.2.3)
    activemodel (4.0.1, 3.2.15, 3.2.3)
    activerecord (4.0.1, 3.2.15, 3.2.3)
    activerecord-deprecated_finders (1.0.3)
    activeresource (3.2.3)
    activesupport (4.0.1, 3.2.15, 3.2.3)
    addressable (2.3.5)
    arel (4.0.1, 3.0.3, 3.0.2)
    atomic (1.1.14)
    backports (3.3.5)
    bcrypt-ruby (3.1.2)
    bigdecimal (1.2.0)
    builder (3.1.4, 3.0.4, 3.0.0)
    bundler (1.3.5)
    bundler-unload (1.0.2)
    classifier (1.3.3)
    coffee-rails (4.0.1, 3.2.2)
    coffee-script (2.2.0)
    coffee-script-source (1.6.3, 1.3.3)
    colorator (0.1)
    commander (4.1.5)
    daemons (1.1.9)
    data_mapper (1.2.0)
    data_objects (0.10.13)
    dm-aggregates (1.2.0)
    dm-constraints (1.2.0)
    dm-core (1.2.1)
    dm-do-adapter (1.2.0)
    dm-migrations (1.2.0)
    dm-mysql-adapter (1.2.0)
    dm-serializer (1.2.2)
    dm-sqlite-adapter (1.2.0)
    dm-timestamps (1.2.0)
    dm-transactions (1.2.0)
    dm-types (1.2.2)
    dm-validations (1.2.0)
    do_mysql (0.10.13)
    do_sqlite3 (0.10.13)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (2.0.2, 1.4.0)
    executable-hooks (1.2.6)
    fast-stemmer (1.0.2)
    fastercsv (1.5.5)
    ffi (1.9.3)
    git (1.2.6)
    haml (4.0.4)
    highline (1.6.20)
    hike (1.2.3, 1.2.1)
    htmlentities (4.3.1)
    http_router (0.11.0, 0.5.4)
    i18n (0.6.5, 0.6.0)
    io-console (0.4.2)
    jbuilder (1.5.2)
    jekyll (1.3.1)
    jekyll-import (0.1.0.rc1)
    journey (1.0.4)
    jquery-rails (3.0.4, 2.0.2)
    json (1.8.1, 1.7.7, 1.7.3)
    json_pure (1.8.1)
    libv8 (3.16.14.3 x86_64-darwin-13)
    liquid (2.5.4)
    listen (1.3.1)
    mail (2.5.4, 2.4.4)
    maruku (0.6.1)
    metaclass (0.0.1)
    mime-types (1.25.1, 1.18)
    mini_portile (0.5.2)
    minitest (4.7.5, 4.3.2)
    mocha (0.14.0)
    multi_json (1.8.2, 1.3.6)
    mysql2 (0.3.14)
    nokogiri (1.6.0)
    padrino (0.11.4, 0.9.21)
    padrino-admin (0.11.4, 0.9.21)
    padrino-cache (0.11.4, 0.9.21)
    padrino-core (0.11.4, 0.9.21)
    padrino-gen (0.11.4, 0.9.21)
    padrino-helpers (0.11.4, 0.9.21)
    padrino-mailer (0.11.4, 0.9.21)
    polyglot (0.3.3)
    pony (1.6.1, 1.5.1)
    posix-spawn (0.3.6)
    psych (2.0.0)
    pygments.rb (0.5.4)
    rack (1.5.2, 1.4.1)
    rack-cache (1.2)
    rack-protection (1.5.1)
    rack-ssl (1.3.2)
    rack-test (0.6.2, 0.6.1)
    rails (3.2.3)
    railties (4.0.1, 3.2.3)
    rake (10.1.0, 0.9.6, 0.9.2.2)
    rb-fsevent (0.9.3)
    rb-inotify (0.9.2)
    rb-kqueue (0.2.0)
    rdoc (4.0.0, 3.12.2, 3.12)
    redcarpet (2.3.0)
    ref (1.0.5)
    rubygems-bundler (1.4.2)
    rvm (1.11.3.8)
    safe_yaml (0.9.7)
    sass (3.2.12, 3.1.19)
    sass-rails (4.0.1, 3.2.5)
    sdoc (0.3.20)
    sequel (4.4.0)
    shoulda (3.5.0)
    shoulda-context (1.1.6)
    shoulda-matchers (2.4.0)
    sinatra (1.4.4)
    sinatra-contrib (1.4.1)
    sinatra-extension (1.0)
    sinatra-flash (0.3.0)
    slim (2.0.2)
    sprockets (2.10.1, 2.1.3)
    sprockets-rails (2.0.1)
    sqlite3 (1.3.8, 1.3.6)
    sqlite3-ruby (1.3.3)
    stringex (1.5.1)
    syntax (1.0.0)
    temple (0.6.7)
    test-unit (2.0.0.0)
    therubyracer (0.12.0)
    thin (1.6.1)
    thor (0.18.1, 0.17.0, 0.14.6)
    thread_safe (0.1.3)
    tilt (1.4.1, 1.3.3)
    treetop (1.4.15, 1.4.10)
    turbolinks (1.3.1)
    tzinfo (0.3.38, 0.3.33)
    uglifier (2.3.1, 1.2.4)
    url_mount (0.2.1)
    uuidtools (2.1.4)
    yajl-ruby (1.1.0)
2

There are 2 answers

0
Derek Prior On

I've not tried to use shoulda-matchers outside of rails before, but it looks like they make use of the delegate macro provided by ActiveSupport. Try require 'activesupport' (or a more limited subset if you'd rather) in your tests to see if that helps.

0
jdar On

require 'active_support/core_ext/module/delegation'

worked for me