`ArgumentError:不是公认的提供者`当使用paperclip,rspec和fog作为存储测试模型的简单文件上传时

时间:2017-06-26 10:12:25

标签: ruby-on-rails ruby rspec paperclip fog

我使用Paperclip上传文件,fog-google用作存储空间。 从rails consoleAPI上传文件时,一切正常。但是当我尝试在我的模型上测试上传功能时,我收到ArgumentError: is not a recognized provider错误。 以下是测试片段 ```红宝石

context "saving images" do
    it "save image to google cloud storoge" do
        user = FactoryGirl.create(:user)
        user.image = File.new("spec/fixtures/some_image.jpg")
        user.save!
        expect(user.reload.image.exists?).to eq(true)
    end
end

```

附加Google生成的JSON密码文件

{
    "type": "service_account",
    "project_id": "some-project",
    "private_key_id": "---somekeys----",
    "private_key": "-----BEGIN PRIVATE KEY-----\n----private key------\n-----END PRIVATE KEY-----\n",
    "client_email": "new-service-account@some-project.iam.gserviceaccount.com",
    "client_id": "---client-id----------",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "auth_provider_x509_cert_url": 
    "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": 
    "https://www.googleapis.com/robot/v1/metadata/x509/new-service-account%40some-project.iam.gserviceaccount.com"
}

Fog配置文件附在下面:

google_project: some-project
google_client_email: new-service-account@some-project.iam.gserviceaccount.com
google_json_key_location: ~/Desktop/some-project-8c5573bf9f32.json

0 个答案:

没有答案