我正在学习使用rspec在我的木偶模块上进行单元测试,但不知何故,我的简单模块“rspec_test”无法通过测试。该模块只包含一个 init.pp 文件,如下所示:
init.pp
class rspec_test {
class { 'test_class': }
}
以下是执行“$ 佣金规范”的错误消息:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I/Library/Ruby/Gems/2.0.0/gems/rspec-support-3.2.1/lib:/Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/exe/rspec --pattern spec/\*/\*_spec.rb
F
Failures:
1) rspec_test should contain Class[rspec_test]
Failure/Error: it { should create_class('rspec_test')}
Puppet::Error:
Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class test_class at /Users/gli/service/modules/rspec_test/spec/fixtures/modules/rspec_test/manifests/init.pp:2 on node oakm01154b9d1.iparadigms.com
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/resource.rb:252:in `initialize'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/resource.rb:118:in `initialize'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:44:in `new'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:44:in `block (3 levels) in evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/errors.rb:62:in `exceptwrap'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:43:in `block (2 levels) in evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:42:in `collect'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:42:in `block in evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/branch.rb:12:in `block in each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/branch.rb:11:in `each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/branch.rb:11:in `each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:25:in `collect'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/resource.rb:25:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast.rb:61:in `safeevaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:11:in `block in evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:10:in `each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:10:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast.rb:61:in `safeevaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/resource/type.rb:127:in `evaluate_code'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/resource.rb:79:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:233:in `each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:233:in `evaluate_classes'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/functions/include.rb:31:in `block in <top (required)>'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/functions.rb:164:in `block (2 levels) in newfunction'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler.rb:51:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/functions.rb:157:in `block in newfunction'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/function.rb:42:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast.rb:61:in `safeevaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:11:in `block in evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:10:in `each'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast/block_expression.rb:10:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/ast.rb:61:in `safeevaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/resource/type.rb:127:in `evaluate_code'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/resource.rb:79:in `evaluate'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:425:in `evaluate_main'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:131:in `block (2 levels) in compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler.rb:51:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:131:in `block in compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/context.rb:64:in `override'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet.rb:244:in `override'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:117:in `compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/parser/compiler.rb:34:in `compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/indirector/catalog/compiler.rb:95:in `block (2 levels) in compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util/profiler.rb:51:in `profile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/indirector/catalog/compiler.rb:93:in `block in compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util.rb:161:in `block in benchmark'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/util.rb:160:in `benchmark'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/indirector/catalog/compiler.rb:92:in `compile'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/indirector/catalog/compiler.rb:52:in `find'
# /Library/Ruby/Gems/2.0.0/gems/puppet-3.7.4/lib/puppet/indirector/indirection.rb:201:in `find'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/support.rb:162:in `build_catalog_without_cache'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/support.rb:171:in `build_catalog'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/support.rb:21:in `load_catalogue'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/example/class_example_group.rb:7:in `catalogue'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/support.rb:7:in `block in subject'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/matchers/create_generic.rb:82:in `call'
# /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/matchers/create_generic.rb:82:in `matches?'
# ./spec/classes/init_spec.rb:5:in `block (2 levels) in <top (required)>'
Deprecation Warnings:
Filtering by an `:example_group` subhash is deprecated. Use the subhash to filter directly instead. Called from /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/example.rb:13:in `block in <top (required)>'.
Filtering by an `:example_group` subhash is deprecated. Use the subhash to filter directly instead. Called from /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/example.rb:16:in `block in <top (required)>'.
Filtering by an `:example_group` subhash is deprecated. Use the subhash to filter directly instead. Called from /Library/Ruby/Gems/2.0.0/gems/rspec-puppet-2.0.0/lib/rspec-puppet/example.rb:19:in `block in <top (required)>'.
Too many uses of deprecated 'Filtering by an `:example_group` subhash'. Pass `--deprecation-out` or set `config.deprecation_stream` to a file for full output.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
4 deprecation warnings total
Finished in 0.06932 seconds (files took 0.66053 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/classes/init_spec.rb:5 # rspec_test should contain Class[rspec_test]
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I/Library/Ruby/Gems/2.0.0/gems/rspec-support-3.2.1/lib:/Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/lib /Library/Ruby/Gems/2.0.0/gems/rspec-core-3.2.0/exe/rspec --pattern spec/\*/\*_spec.rb failed
我将测试文件命名为“init_spec.rb ”,内容如下:
require 'spec_helper'
describe "rspec_test" do
it { should create_class('rspec_test')}
end
和其他文件...
耙
require 'rake'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/*/*_spec.rb'
end
spec_helper.rb
require 'rspec-puppet'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
end
我在模块的根目录中执行了“$ rspec-puppet-init”来设置测试环境,所以文件结构应该是标准的。有人能告诉我哪里做错了吗?谢谢!
在我看来,它的工作原理和设计的一样。
您的清单无法编译。它声明了一个类< code>test_class,但该类没有在任何地方定义。
您应该从一个空类< code>rspec_test开始,实现第一个测试,然后从那里开始工作。
我正在处理一个scala项目,这是我的规范: 我知道这里已经有人问过这个问题,但提供的解决办法并不奏效,我很绝望,我试过: 但这并不奏效。
问题内容: 我有弹簧罐,并试图 从此处给出的教程中实现程序。xml配置文件为: 主要: 我不知道这些豆怎么了。到目前为止,关于其他问题的任何建议都无济于事。有什么帮助吗? 问题答案: 假设您使用的是Spring 3.1,请尝试以下操作: 在最后一行用您使用的 主要 Spring版本替换。含义:即使有Spring版本,也没有XSD 。
我有这个问题 XML格式的文档 我的XSD 我有个神经衰弱的问题。有什么想法吗? 问候
在spring中,每当我在dispatcher-servlet.xml中编写时,我都会得到这样的错误:-
我从GitHub获取了一个android项目,并将其克隆到了我的android Studio中。当我试图运行ActivityMain时。xml文件为了检查项目是否正常工作,我遇到了这个错误“找不到元素'RelativeLayout'的声明”。我不知道怎么解决这个问题。如果任何人有任何其他方式运行该项目,请建议太多。 github文件的链接如下所示 https://github.com/PedroC
我完全卸载了IntelliJ,现在已经重新安装并导入了我的项目。我使用gradle导入,可以看到我项目中的所有文件。然而,当我打开一个文件时,我找不到任何声明可以通过执行cmd+click来转到。我已经安装了Java7SDK,我甚至无法在自己的项目中进行类的声明。转到像或这样的Java核心类也不起作用。如何使IDE能够找到我的类? 我在OSX优胜美地,IntelliJ 2016.1.2 build