#<RSpec :: ExampleGroups的未定义局部变量或方法`clientid'

用户4443990

我是factory_girl gem的新手。我的Ruby gem具有静态的clientid,会话和主机。

我的工厂代码就像

FactoryGirl.define  do
 factory :session do |f|
        f.clientid "clientid string"
        f.secret " secret string"
        f.host "host string"
    end
end

我的规范代码就像

describe '#new' do
    it 'works' do
      result = FactoryGirl.build(clientid, secret, host)
      expect(result).not_to be_nil
    end
end

我的spec_helper文件是

require 'rspec'
require 'factory_girl'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'mydemogem'

我正试图为此建立一个工厂。但这给了我以下错误:

undefined local variable or method `clientid' for #<RSpec::ExampleGroups::
吉姆·德维尔

您的规格有

result = FactoryGirl.build(clientid, secret, host)

但你没有定义clientidsecrethost您无法访问未定义的变量

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Rspec测试中未定义的局部变量或方法?

RSPEC未定义的局部变量或方法“响应”

Rspec 3.#<RSpec :: ExampleGroups :: ConfigsAPI :: GETApiConfig:0x007f84d93fbb90>的未定义局部变量或方法“响应”

RSpec分配返回的未定义局部变量错误

Rspec和Capybara未定义的局部变量或方法`page'

#<RSpec :: ExampleGroups ::的Rails rspec未定义方法'receive'

#<RSpec :: ExampleGroups :: UserName:>的未定义方法`build'

NoMethodError:#<RSpec :: ExampleGroups :: CompetitionsController :: Create>的未定义方法'mock'

NoMethodError:RSpec :: ExampleGroups :: ApplicationsController:Class的未定义方法“ setup”

RSpec :: ExampleGroups :: User :: Validations的未定义方法`validate_presence_of'

未定义的局部变量或方法

RSpec-未定义的方法“键?”

NoMethodError:RSpec 的未定义方法“get”

Rspec未定义方法“至”

Rspec 未定义的方法“belong_to”

局部变量未定义的外部方法

未定义的局部变量或方法“sub_task”

Contact:Class的未定义局部变量或方法“ email”

未定义的局部变量或方法“ arr”

未定义的局部变量或模块的方法

未定义的局部变量或方法“ recipient_email”

main:Object的未定义局部变量或方法`'

未定义的局部变量或方法“ place”

错误:顶级未定义的局部变量或方法'var'

在Rails中未定义的局部变量或方法to_a?

(未定义的局部变量或方法“ byebug”

未定义的局部变量或方法“ main_page”

Rails:未定义的局部变量或方法`options'

NameError未定义的局部变量或方法“ drink”