Call to fail() fails - puppet

I'm trying to setup a new puppetmaster (v5.0.1) and all goes well, except for one thing.
I can't call fail() in my manifests. When it tries to run any fail() function, it throws an Evaluation error.
This happens in manifests and with puppet apply as well.
$ puppet apply -e 'fail("Failure")' --trace
Will return the following error and trace:
Error: Evaluation Error: Error while evaluating a Function Call,
Failure at line 1:1 on node ***
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions/fail.rb:3:in
block in <top (required)>'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:174:in
block (2 levels) in newfunction'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:167:in
block in newfunction' :1:instack'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in
eval'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in
stack'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/runtime3_support.rb:316:in
call_function'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:949:in
call_function_with_block'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:918:in
eval_CallNamedFunctionExpression'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:48:in
block in visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in
each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in
visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:92:in
visit_this_1'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:81:in
evaluate' :in stack'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in
eval'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in
stack'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:723:in
eval_Program'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:48:in
block in visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in
each'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in
visit_this'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:92:in
visit_this_1'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:81:in
evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/parser/evaluating_parser.rb:63:in
evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast/pops_bridge.rb:132:in
evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast.rb:31:in
safeevaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/type.rb:136:in
evaluate_code'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:79:in
block in evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:71:in
evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:589:in
evaluate_main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:164:in
block (2 levels) in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:164:in
block in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in
override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:310:in
override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:153:in
compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:33:in
compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:282:in
block (2 levels) in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in
profile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:280:in
block in compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:224:in
block in benchmark'
/opt/puppetlabs/puppet/lib/ruby/2.4.0/benchmark.rb:308:inrealtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:223:in
benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:278:in
compile'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:52:in
find'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:195:in
find'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:258:in
block in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in
override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:310:in
override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:229:in
main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:170:in
run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:358:in
block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:666:in
exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:358:in
run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:132:in
run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in
execute' /opt/puppetlabs/puppet/bin/puppet:5:in `'
I'm sure it's me, but I can't figure out what causes this.

The fail() function is working as designed but the error message is confusing.
The fail() function is just a wrapper around raise Puppet::ParseError. Normally, Puppet::ParseError is raised when a Puppet function is not doing what it is supposed to do. In that context, the message Error while evaluating a Function Call makes sense.
Here, however, the error is raised because the function is doing exactly what it is supposed to do - raising an error for you. So, it is not an "error while evaluating a function call".
It has always been like this though.

Related

Why does the homrebrew formula test fail with a serde_json error "expected value at line 1 column 1"

I have a rust lib that I compile with cargo and the resulting binary should bundle a folder of json files. Those json files are read by my program via:
let filename = "./fonts/console.json";
let data = read_to_string(Path::new(filename).as_os_str())
.unwrap_or(format!("Unable to read file \"{}\"", color(filename, Colors::Red)));
serde_json::from_str(&data).unwrap_or_else(|error| {
panic!(
"JSON parsing error encountered for: \"{}\"\nError: {}",
color(filename, Colors::Red),
color(&format!("{}", error), Colors::Yellow)
)
})
When I run cargo build --release I get a binary that I run with like this:
λ my_thing test
test
And the code path for the rust code above is triggered without any errors.
I also like to add that cargo install mything works as expected as well. No issues which makes me think this is not a cargo bundle compile issue...?!
Now I'm trying to publish this lib on homebrew so I wrote this formula:
class Mything < Formula
desc "Description etc"
homepage "https://hpomepage.com"
url "https://github.com/path/to/archive/refs/tags/v3.0.0.tar.gz"
sha256 "547a8e3059e1543debd8e0f10e9efd05c27d13b0717echs7634e1c4cf49d44cb"
license "GPL-3.0-or-later"
depends_on "rust" => :build
def install
chdir "rust" do
system "make"
system "cargo", "build", "--release", "--bin", "mything"
bin.install "target/release/mything"
end
end
test do
print "#{bin}/mything test -f console\n"
# ^-- I added this for debugging to make 100% sure I'm not getting the binaries mixed up
assert_match "\n\n\ntest\n\n\n",
shell_output("#{bin}/mything test -f console")
end
end
Installing this works fine but when I run brew test mything I get:
λ brew test mything
==> Testing mything
/opt/homebrew/Cellar/mything/3.0.0/bin/mything test -f console
==> /opt/homebrew/Cellar/mything/3.0.0/bin/mything test -f console
thread 'main' panicked at 'JSON parsing error encountered for: "./fonts/console.json"
Error: expected value at line 1 column 1', src/font.rs:88:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: mything: failed
An exception occurred within a child process:
Minitest::Assertion: Expected: 0
Actual: 101
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:183:in `assert'
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:218:in `assert_equal'
/opt/homebrew/Library/Homebrew/formula_assertions.rb:26:in `shell_output'
/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/mything.rb:21:in `block in <class:Mything>'
/opt/homebrew/Library/Homebrew/formula.rb:2112:in `block (3 levels) in run_test'
/opt/homebrew/Library/Homebrew/utils.rb:595:in `with_env'
/opt/homebrew/Library/Homebrew/formula.rb:2111:in `block (2 levels) in run_test'
/opt/homebrew/Library/Homebrew/formula.rb:948:in `with_logging'
/opt/homebrew/Library/Homebrew/formula.rb:2110:in `block in run_test'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `run'
/opt/homebrew/Library/Homebrew/formula.rb:2363:in `mktemp'
/opt/homebrew/Library/Homebrew/formula.rb:2104:in `run_test'
/opt/homebrew/Library/Homebrew/test.rb:43:in `block in <main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/opt/homebrew/Library/Homebrew/test.rb:48:in `<main>'
Now I copy the printed first line of that output and run it the same way:
λ /opt/homebrew/Cellar/mything/3.0.0/bin/mything test -f console
test
And it works. That's the very same binary that brew is testing here.
I don't know much ruby so there is a good chance I'm getting the test wrong somehow?
I also tried to do this in the test:
system bin/"cfonts", "test", "-f", "console"
Which also fails with the same error.
When I run that binary now since it's installed via brew and in my PATH it all works as well which is nuts...
λ mything test -f console
test
λ which mything
/opt/homebrew/bin/mything
Any help is appreciated.
The issue was that of course the relative path was only working in certain directories where that folder was present.
A rust issue after-all.
So I used the include_str macro to include the contents of the json file into the binary at compile time:
let font_content = include_str!("../fonts/console.json");
serde_json::from_str(&font_content).unwrap_or_else(|error| {
panic!(
"JSON parsing error encountered for: \"{}\"\nError: {}",
color(filename, Colors::Red),
color(&format!("{}", error), Colors::Yellow)
)
})
Now the brew formula works fine:
class Mything < Formula
desc "Description etc"
homepage "https://hpomepage.com"
url "https://github.com/path/to/archive/refs/tags/v3.0.0.tar.gz"
sha256 "547a8e3059e1543debd8e0f10e9efd05c27d13b0717echs7634e1c4cf49d44cb"
license "GPL-3.0-or-later"
depends_on "rust" => :build
def install
chdir "rust" do
system "make"
system "cargo", "build", "--release", "--bin", "mything"
bin.install "target/release/mything"
end
end
test do
assert_match "\n\n\ntest\n\n\n",
shell_output("#{bin}/mything test -f console")
end
end
λ brew test cfonts
==> Testing cfonts
==> /opt/homebrew/Cellar/mything/3.0.0/bin/mything test -f console

Poltergeist current_url command is returning page_info hash instead of a URL

Problem
I have an rspec feature test that is using capybara/poltergeist with :js => true and is doing something really simple:
visit borrow_path
click_on "Get Started"
page.should have_content "Create Your Account"
Clicking Get Started takes the user to our sign up page and then poltergeist raises a Timeout Error on the page.should have_content assertion, despite the screenshot of the page confirming that the content is, in fact, on the page.
The error is:
Failure/Error: page.should have_content "Create Your Account"
Capybara::Poltergeist::TimeoutError:
Timed out waiting for response to {"name":"find","args":["xpath","/html"]}. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Poltergeist :timeout option to a higher value will help (see the docs for details). If increasing the timeout does not help, this is probably a bug in Poltergeist - please report it to the issue tracker.
# ./spec/features/borrower/signup_spec
We've tried upping the timeout to 5 minutes, still the same error.
This doesn't happen consistently, every few runs the test will pass.
Details
With that in mind, I turned :debug on in our setup as follows:
Capybara.register_driver :poltergeist do |app|
# use 'page.driver.debug' as a js debugger
# see https://github.com/jonleighton/poltergeist/tree/v1.5.0#remote-debugging-experimental
Capybara::Poltergeist::Driver.new(app, :timeout => 300, :inspector => true, :debug => false, :window_size => [1280, 1400], :js_errors => true)
end
and re-ran the tests. The failed spec's output looks as follows:
{"name"=>"current_url", "args"=>[]}
{"response"=>{"page_id"=>126, "ids"=>[0]}}
An error occurred in an after hook
URI::InvalidURIError: bad URI(is not URI?): {"page_id"=>126, "ids"=>[0]}
occurred at /home/rof/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/uri/common.rb:176:in `split'
{"name"=>"current_url", "args"=>[]}
{"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"}
{"name"=>"current_url", "args"=>[]}
{"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"}
{"name"=>"body", "args"=>[]}
{"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"}
I can't find any hints as to why a call to current_url is returning the page_id hash instead of a URL, but this actually breaks all subsequent feature tests and causes find to always return true:
{"name"=>"find", "args"=>["xpath","/html"]}
{"response"=>"true"}
Which causes this exception on all subsequent tests (whether they're tagged :js => true or not):
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `[]' for true:TrueClass
# /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/browser.rb:54:in `find'
# /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:114:in `find'
# /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:118:in `find_xpath'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:154:in `block in resolve_query'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/base.rb:77:in `synchronize'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:150:in `resolve_query'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:129:in `all'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/matchers.rb:107:in `block in assert_no_selector'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/base.rb:81:in `synchronize'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/matchers.rb:106:in `assert_no_selector'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/session.rb:396:in `block (2 levels) in <class:Session>'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/session.rb:81:in `reset!'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `block in reset_sessions!'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `each'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `reset_sessions!'
# /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:471:in `instance_eval'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:471:in `instance_eval_with_rescue'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:242:in `instance_eval_with_rescue'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:31:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `block in run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `each'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:446:in `run_hook'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:350:in `run_after_each_hooks'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:298:in `run_after_each'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:120:in `block in run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-rails-2.14.0/lib/rspec/rails/example/controller_example_group.rb:158:in `call'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-rails-2.14.0/lib/rspec/rails/example/controller_example_group.rb:158:in `block (2 levels) in <module:ControllerExampleGroup>'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:104:in `call'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:104:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:446:in `run_hook'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:111:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `map'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `run_examples'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:371:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `map'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block in run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/reporter.rb:58:in `report'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:25:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
# /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'
Any idea what's going on?

Why does script run in Firefox, but not IE8?

I have a script that runs OK in Firefox.
The script does not run in Internet Explorer. I would be grateful for assistance.
Here are first few lines:
require 'rubygems'
require 'watir'
require 'watir-webdriver'
require 'test/unit'
URL = "http://google.com/"
class TestGoogle < Test::Unit::TestCase
def setup
##browser = Watir::Browser.new :firefox
#browser = Watir::Browser.new :ie
end
def testSignInLink
#browser.goto URL
Here are selected error messages:
C:\Ruby193\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/RubymineProjects/ditto/Google_01_TU_03.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic/version.rb:3: warning: already initialized constant VERSION
...
...
1) Error:
testSignInLink(TestGoogle):
TypeError: superclass mismatch for class UnknownObjectException
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir- classic/exceptions.rb:12:in `<module:Exception>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir- classic/exceptions.rb:2:in `<module:Watir>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic/exceptions.rb:1:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic.rb:6:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.7.0/lib/watir-classic.rb:6:in `<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48:in `require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:48:in `load_driver'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:40:in `load_driver_for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-4.0.2-x86-mingw32/lib/watir/loader.rb:8:in `new'
C:/RubymineProjects/ditto/Google_01_TU_03.rb:11:in `setup'
Line 11 is:
#browser = Watir::Browser.new :ie
Based on #abe comment, I did the following.
For IE only, I removed "require 'watir'". That worked fine.
Restore "require 'watir'". Remove "require 'watir-webdriver'". That worked fine.
That's the answer to my question. But I don't understand that. It sounds as if the two APIs are interchangeable :)

Custom puppet type provider - exists? returning true causes 'undefined method' exception

I'm trying to develop a custom type provider for RabbitMQ, based on existing providers present in the puppetlabs rabbitmq module.
If exists? method returns false - everything works fine.
However, if exists? returns true, puppet fails with undefined method 'pattern' exception (stacktrace bellow).
Note that pattern is one of my type's parameters.
I'm using Puppet 3.1.1 on CentOS.
The stacktrace:
Error: /Stage[main]//Node[rabbitmq]/Rabbitmq_policy[ha-all#DMITRY_CBMS]: Could not evaluate: undefined method `pattern' for #<Puppet::Type::Rabbitmq_policy::ProviderRabbitmqctl:0x7f5e647471f0>
/usr/lib/ruby/site_ruby/1.8/puppet/property.rb:462:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/property.rb:462:in `retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:1027:in `retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:1022:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:1022:in `retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/type.rb:1041:in `retrieve_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:32:in `perform_changes'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction/resource_harness.rb:133:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:48:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:83:in `eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:103:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:351:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:350:in `thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:103:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:382:in `traverse'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:98:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:144:in `apply'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:122:in `apply_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:179:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:178:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:121:in `apply_catalog'
/usr/lib/ruby/site_ruby/1.8/puppet/configurer.rb:179:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:45:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent/locker.rb:20:in `lock'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:45:in `run'
/usr/lib/ruby/1.8/sync.rb:230:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:45:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:119:in `with_client'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:42:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:89:in `run_in_fork'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:86:in `fork'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:86:in `run_in_fork'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:41:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in `call'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:179:in `controlled_run'
/usr/lib/ruby/site_ruby/1.8/puppet/agent.rb:39:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:205:in `run_event_loop'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:167:in `loop'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:167:in `run_event_loop'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:145:in `start'
/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:357:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/agent.rb:313:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:364:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:456:in `plugin_hook'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:364:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:504:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:364:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:132:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:86:in `execute'
Type definition:
Puppet::Type.newtype(:rabbitmq_policy) do
desc 'Type for defining rabbitmq policies'
ensurable do
defaultto(:present)
newvalue(:present) do
provider.create
end
newvalue(:absent) do
provider.destroy
end
end
newparam(:name, :namevar => true) do
desc 'combination of policy-name#vhost to setup the policy'
newvalues(/^\S+#\S+$/)
end
newproperty(:pattern) do
desc 'regexp representing configuration permissions'
validate do |value|
resource.validate_permissions(value)
end
end
newproperty(:definition) do
desc 'definition of this policit, e.g: {"ha-mode":"all"}'
end
autorequire(:rabbitmq_vhost) do
[self[:name].split('#')[1]]
end
autorequire(:rabbitmq_policy) do
[self[:name].split('#')[0]]
end
# I may want to dissalow whitespace
def validate_permissions(value)
begin
Regexp.new(value)
rescue RegexpError
raise ArgumentError, "Invalid regexp #{value}"
end
end
end
Provider definition:
Puppet::Type.type(:rabbitmq_policy).provide(:rabbitmqctl) do
commands :rabbitmqctl => 'rabbitmqctl'
defaultfor :feature => :posix
def policy_name
if #cached_policy_name
#cached_policy_name
else
#cached_policy_name = resource[:name].split('#')[0]
end
end
def vhost
if #cached_vhost
#cached_vhost
else
#cached_vhost = resource[:name].split('#')[1]
end
end
def create
Puppet.debug "rabbitmq_policy.create"
rabbitmqctl('set_policy','-p', vhost, policy_name, resource[:pattern], resource[:definition])
end
def destroy
Puppet.debug "rabbitmq_policy.destroy"
rabbitmqctl('clear_policy', '-p', vhost, policy_name)
end
def exists?
out = rabbitmqctl('list_policies', '-p', vhost).split(/\n/)[1..-2].collect do |line|
parts = line.split(/\s+/)
Puppet.debug "rabbitmq_policy::list_policies line: #{line}| #{parts[1]} == #{policy_name} => #{parts[1] == policy_name} "
if parts[1] == policy_name
true
else
false
end
end
out = out.detect do |obj| obj end
Puppet.debug "rabbitmq_policy.exists: #{out.to_s}"
out
end
#def exists?
# false
#end
end
Any help is greatly appreciated.
Thanks
Found an answer (thanks to Daniel at ask.puppetlabs.com).
Every property defined using newproperty in type definition must have a corresponding getter and setter in the provider. And properties only make sense for types whose attributes can be updated individually.
For simple case newparam should be used.

Can't run Cuke4Nuke

I have installed, confirmed installation and followed the steps mentioned in the links below:
http://gojko.net/2010/01/01/bdd-in-net-with-cucumber-cuke4nuke-and-teamcity/
http://cuke4ninja.com/sec_hello_world_net.html
Once I try to run Cuke4Nuke bin\debug\Cuke4NukeExample.dll
I get an error message.
I tried to run Cuke4Nuke alone with no parameters and I see the same error message as with the bin\debug\Cuke4NukeExample.dll
Here is the error message:
E:\Visual Projects>cuke4nuke
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.1.5-x86-mingw32/lib/ffi/library.rb:249
:in attach_function': Function '_get_errno' not found in [msvcrt.dll]
(FFI::Not FoundError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-process-0.7.0/lib/win32/p
rocess/functions.rb:12:inattach_pfunc'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-process-0.7.0/lib/win32/p
rocess/functions.rb:64:in <module:Functions>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-process-0.7.0/lib/win32/p
rocess/functions.rb:8:in'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-process-0.7.0/lib/win32/p
rocess.rb:1:in <top (required)>'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/cuke4nuke-0.4.0/lib/cuke4nuke/m
ain.rb:4:in'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:i n
require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/cuke4nuke-0.4.0/bin/cuke4nuke:4
:in <top (required)>'
from C:/Ruby193/bin/cuke4nuke:23:inload'
from C:/Ruby193/bin/cuke4nuke:23:in `'
Thanks

Resources