You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My test file looks like this with some other tests stripped out for readability:
describe 'Cookbooks' do
describe 'TestRunner' do
include RR::Adapters::RRMethods
before(:each) do
@run_list = 'role[base],role[testrun]'
@box = "ubuntu"
@test_runner = TestRunner.new(@run_list, @box)
end
describe '#initialize' do
before(:each) do
mock(Vagrant::Environment).new(:ui_class => Vagrant::UI::Colored, :cwd => @root_dir)
end
it "should do something" do
some test here to use the mock
end
end
describe '#run' do
it "should run vagrant" do
@test_runner.run
end
end
end
end
Here is the code being tested:
module Cookbooks
class TestRunner
class TestRunnerException < Exception
end
attr_reader :run_list, :box
# Initialize
#
# @param[String] run_list to use for test run
# @param[String] box to use for test run (i.e. ubuntu, centos)
def initialize(run_list, box)
@run_list = run_list
@box = box
ENV['CHEF_RUN_LIST'] = @run_list
@vagrant = Vagrant::Environment.new(:ui_class => Vagrant::UI::Colored, :cwd => ROOT_DIR)
end
# Execute test run by provisioning vagrant box
# with run list provided
def run
begin
@vagrant.cli("provision", @box)
rescue Exception => e
raise TestRunnerException, "Provisioning Failed: #{e}"
end
end
end
end
The test in the '#run' example group fails because the mock thinks it is called a second time. Since the mock is in another example group wouldn't this have been cleared? Is this a limitation in minitest and not rr's fault?
Thanks,
Jay
The text was updated successfully, but these errors were encountered:
There is a known issue with stubbing/mocking classes where they do not reset properly, see #43. This may be related to that. I'll keep this bug open for now.
Hi,
My test file looks like this with some other tests stripped out for readability:
Here is the code being tested:
The failure I get is this:
The test in the '#run' example group fails because the mock thinks it is called a second time. Since the mock is in another example group wouldn't this have been cleared? Is this a limitation in minitest and not rr's fault?
Thanks,
Jay
The text was updated successfully, but these errors were encountered: