Request tests failing with "NoMethodError: undefined method `post'"

695 views
Skip to first unread message

Samuel Mullen

unread,
May 19, 2013, 9:12:44 AM5/19/13
to minites...@googlegroups.com
It fails with `get` as well.

I have a fresh Rails app installed with minitest-rails
Rails: 3.2.13
minitest-rails: 0.9.2
minitest-rails-capybara: 0.9.0
minitest: 4.7.4

I've followed all the install instructions and everything works except when I try to do "get" or "post" calls to the app's resources. I've seen those methods in other apps, so I figure I'm doing something wrong.

Here's the error I'm seeing:
POST :: /users/:id/authentications request::successful request#test_0001_Adds an authentication record to a user:
NoMethodError: undefined method `post' for #<#<Class:0x007fa607163028>:0x007fa6070012c0>
  test/requests/authentications_test.rb:9:in `block (3 levels) in <main>'

Here's my test_helper:
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/autorun"
require "minitest/rails"
require "minitest/rails/capybara"

Dir[Rails.root.join("test/support/**/*.rb")].each {|f| require f}

class ActiveSupport::TestCase
end

# database cleaner
DatabaseCleaner.strategy = :transaction

class MiniTest::Spec
  before :each do
    DatabaseCleaner.start
  end

  after :each do
    DatabaseCleaner.clean
  end
end

class RequestTest < MiniTest::Spec
  include Rails.application.routes.url_helpers

  register_spec_type(/request$/, self)
end

and Here's the test:
require "minitest_helper"

describe "POST :: /users/:id/authentications request" do
  describe "successful request" do
    it "Adds an authentication record to a user" do
      user = create_user

      post user_authentications_path(user)

      response.status.must_equal "200"
    end
  end
end


I really want to use MiniTest instead of RSpec, but this has happened to me every time I try to switch over to MiniTest.

Thanks

Mike Moore

unread,
May 19, 2013, 2:36:40 PM5/19/13
to minites...@googlegroups.com
Answered on StackOverflow


--
-- You received this message because you are subscribed to the Google Groups minitest-rails group. To post to this group, send email to minites...@googlegroups.com. To unsubscribe from this group, send email to minitest-rail...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/minitest-rails?hl=en
---
You received this message because you are subscribed to the Google Groups "minitest-rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minitest-rail...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Samuel Mullen

unread,
May 19, 2013, 2:45:13 PM5/19/13
to minites...@googlegroups.com
I love you so much right now. 

For future reference, where is this documented so I can dig deeper into this? If it's not, what can I do to help?

Thanks again for the quick response and for the gem.

Samuel
Reply all
Reply to author
Forward
0 new messages