在/spec/controllers/postbacks_controller_spec.rb
中,我有:
require 'spec_helper'
describe PostbacksController, :type => :controller do
include RSpec::Rails::ControllerExampleGroup
describe "receive" do
etc etc ... ... etc etc
post "postbacks/#{@postback.id}/receive", @parameters
@postback.content.should == @parameters
end
end
为什么我会收到以下错误?
NoMethodError: undefined method `post' for #
Gemfile 包括:
group :test do
gem "binding_of_caller"
gem "capybara"
gem "database_cleaner"
gem "launchy"
gem "respec"
gem "rspec-rails"
gem "parallel_tests"
gem "zeus-parallel_tests"
gem "better_errors"
end
/spec/spec_helper.rb
是:
require "rubygems"
require "database_cleaner"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "capybara/rspec"
require "capybara/rails"
require "capybara/dsl"
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fail_fast = true
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.before(:each) { ActionMailer::Base.deliveries.clear }
config.use_instantiated_fixtures = false
config.include(Capybara, :type => :integration)
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy = :deletion
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.after do
if example.metadata[:type] == :feature && example.exception.present? && page.current_path.present?
save_and_open_page
end
end
end