Ruby on rails 是否可以在Capybara/Rspec集成测试中调用GET?

Ruby on rails 是否可以在Capybara/Rspec集成测试中调用GET?,ruby-on-rails,ruby,rspec,capybara,Ruby On Rails,Ruby,Rspec,Capybara,我有一个Rails 4.2应用程序…我正在添加,但我得到一个错误,例如: undefined method `get' for #<RSpec::ExampleGroups::Compression:0x00000009aa4cc8> 在水豚测试中,您可以使用visitnotget(),但这个答案实际上对您没有帮助,因为您上面编写的测试不是集成测试,而是控制器测试 将其移动到spec/controllers,并使用特定于控制器的帮助程序descripe/context/it等为控制

我有一个Rails 4.2应用程序…我正在添加,但我得到一个错误,例如:

undefined method `get' for #<RSpec::ExampleGroups::Compression:0x00000009aa4cc8>

在水豚测试中,您可以使用
visit
not
get
(),但这个答案实际上对您没有帮助,因为您上面编写的测试不是集成测试,而是控制器测试

将其移动到
spec/controllers
,并使用特定于控制器的帮助程序descripe/context/it等为控制器构建测试。您可以设置标题,并在显示的代码中执行各种检查

# spec/integration/compression_spec.rb
require 'spec_helper'

feature 'Compression' do
  scenario "a visitor has a browser that supports compression" do
    ['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
      get root_path, {}, {'HTTP_ACCEPT_ENCODING' => compression_method }
      response.headers['Content-Encoding'].should be
    end
  end

  scenario "a visitor's browser does not support compression" do
    get root_path
    response.headers['Content-Encoding'].should_not be
  end
end