spec/beaker/dsl/helpers_spec.rb in beaker-1.16.0 vs spec/beaker/dsl/helpers_spec.rb in beaker-1.17.0

- old
+ new

@@ -2,10 +2,11 @@ class ClassMixedWithDSLHelpers include Beaker::DSL::Helpers include Beaker::DSL::Wrappers include Beaker::DSL::Roles + include Beaker::DSL::Patterns def logger @logger ||= RSpec::Mocks::Mock.new('logger').as_null_object end end @@ -30,10 +31,11 @@ result.stderr = 'stderr' result.exit_code = 0 end it 'allows the environment the command is run within to be specified' do + subject.stub( :hosts ).and_return( hosts ) Beaker::Command.should_receive( :new ). with( 'ls ~/.bin', [], {'ENV' => { :HOME => '/tmp/test_home' }} ) subject.on( host, 'ls ~/.bin', :environment => {:HOME => '/tmp/test_home' } ) @@ -56,10 +58,11 @@ subject.on( :master, 'echo hello') end it 'delegates to itself for each host passed' do + subject.stub( :hosts ).and_return( hosts ) expected = [] hosts.each_with_index do |host, i| expected << i host.should_receive( :exec ).and_return( i ) end @@ -68,10 +71,11 @@ expect( results ).to be == expected end context 'upon command completion' do before :each do + subject.stub( :hosts ).and_return( hosts ) host.should_receive( :exec ).and_return( result ) @res = subject.on( host, command ) end it 'returns the result of the action' do @@ -91,10 +95,11 @@ end end context 'when passed a block with arity of 1' do before :each do + subject.stub( :hosts ).and_return( hosts ) host.should_receive( :exec ).and_return( result ) end it 'yields result' do subject.on host, command do |containing_class| @@ -122,10 +127,11 @@ end end context 'when passed a block with arity of 0' do before :each do + subject.stub( :hosts ).and_return( hosts ) host.should_receive( :exec ).and_return( result ) end it 'yields self' do subject.on host, command do @@ -165,10 +171,11 @@ end end describe '#scp_from' do it 'delegates to the host' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :logger ).exactly( hosts.length ).times result.should_receive( :log ).exactly( hosts.length ).times hosts.each do |host| host.should_receive( :do_scp_from ).and_return( result ) @@ -178,10 +185,11 @@ end end describe '#scp_to' do it 'delegates to the host' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :logger ).exactly( hosts.length ).times result.should_receive( :log ).exactly( hosts.length ).times hosts.each do |host| host.should_receive( :do_scp_to ).and_return( result ) @@ -382,12 +390,50 @@ subject.on( host, '/sbin/zonename' ).stdout =~ /:global/ end end end + describe '#select_hosts' do + let(:logger) { double.as_null_object } + before do + subject.stub( :logger ).and_return( logger ) + end + + it 'it returns an empty array if there are no applicable hosts' do + hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'} ] + + expect(subject.select_hosts( {'thing' => 'nope'}, hosts )).to be == [] + end + + it 'selects hosts that match a list of criteria' do + hosts = [ {'thing' => 'foo'}, {'thing' => 'bar'}, {'thing' => 'baz'} ] + + expect(subject.select_hosts( {:thing => ['foo', 'baz']}, hosts )).to be == [ {'thing' => 'foo'}, {'thing' => 'baz'} ] + end + + it 'selects hosts when a passed block returns true' do + host1 = {'platform' => 'solaris1'} + host2 = {'platform' => 'solaris2'} + host3 = {'platform' => 'windows'} + ret1 = (Struct.new('Result1', :stdout)).new(':global') + ret2 = (Struct.new('Result2', :stdout)).new('a_zone') + hosts = [ host1, host2, host3 ] + subject.should_receive( :hosts ).and_return( hosts ) + + subject.should_receive( :on ).with( host1, '/sbin/zonename' ).once.and_return( ret1 ) + subject.should_receive( :on ).with( host2, '/sbin/zonename' ).once.and_return( ret2 ) + + selected_hosts = subject.select_hosts 'platform' => 'solaris' do |host| + subject.on(host, '/sbin/zonename').stdout =~ /:global/ + end + expect( selected_hosts ).to be == [ host1 ] + end + end + describe '#apply_manifest_on' do it 'calls puppet' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). # with( 'apply', '--verbose', 'agent' ). and_return( 'puppet_command' ) @@ -397,10 +443,11 @@ subject.apply_manifest_on( agent, 'class { "boo": }') end it 'operates on an array of hosts' do + subject.stub( :hosts ).and_return( hosts ) the_hosts = [master, agent] subject.should_receive( :create_remote_file ).twice.and_return( true ) the_hosts.each do |host| subject.should_receive( :puppet ). @@ -413,10 +460,11 @@ result = subject.apply_manifest_on( the_hosts, 'include foobar' ) result.should(be_an(Array)) end it 'adds acceptable exit codes with :catch_failures' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ). @@ -426,10 +474,11 @@ subject.apply_manifest_on( agent, 'class { "boo": }', :catch_failures => true ) end it 'allows acceptable exit codes through :catch_failures' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ). @@ -440,10 +489,11 @@ 'class { "boo": }', :acceptable_exit_codes => [4], :catch_failures => true ) end it 'enforces a 0 exit code through :catch_changes' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ).with( @@ -457,10 +507,11 @@ 'class { "boo": }', :catch_changes => true ) end it 'enforces a 2 exit code through :expect_changes' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ).with( @@ -474,10 +525,11 @@ 'class { "boo": }', :expect_changes => true ) end it 'enforces exit codes through :expect_failures' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ).with( @@ -491,20 +543,22 @@ 'class { "boo": }', :expect_failures => true ) end it 'enforces exit codes through :expect_failures' do + subject.stub( :hosts ).and_return( hosts ) expect { subject.apply_manifest_on( agent, 'class { "boo": }', :expect_failures => true, :catch_failures => true ) }.to raise_error ArgumentError, /catch_failures.+expect_failures/ end it 'enforces added exit codes through :expect_failures' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) subject.should_receive( :puppet ). and_return( 'puppet_command' ) subject.should_receive( :on ).with( @@ -520,10 +574,11 @@ :expect_failures => true ) end it 'can set the --parser future flag' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) expect( subject ).to receive( :on ).with {|h, command, opts| cmdline = command.cmd_line( h ) expect( h ).to be == agent @@ -541,10 +596,11 @@ :expect_failures => true ) end it 'can set the --noops flag' do + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :create_remote_file ).and_return( true ) expect( subject ).to receive( :on ).with {|h, command, opts| cmdline = command.cmd_line( h ) expect( h ).to be == agent expect( cmdline ).to include('puppet apply') @@ -573,10 +629,11 @@ end end describe '#stub_hosts_on' do it 'executes puppet on the host passed and ensures it is reverted' do + subject.stub( :hosts ).and_return( hosts ) logger = double.as_null_object subject.stub( :logger ).and_return( logger ) subject.should_receive( :on ).twice subject.should_receive( :teardown ).and_yield @@ -587,11 +644,11 @@ subject.should_receive( :puppet ).once. with( 'resource', 'host', 'puppetlabs.com', 'ensure=absent' ) - subject.stub_hosts_on( 'my_host', 'puppetlabs.com' => '127.0.0.1' ) + subject.stub_hosts_on( make_host('my_host', {}), 'puppetlabs.com' => '127.0.0.1' ) end end describe "#stub_hosts" do it "delegates to #stub_hosts_on with the default host" do @@ -604,19 +661,20 @@ end end describe '#stub_forge_on' do it 'stubs forge.puppetlabs.com with the value of `forge`' do - subject.stub( :options ).and_return( {} ) + subject.stub( :hosts ).and_return( hosts ) + host = make_host('my_host', {}) Resolv.should_receive( :getaddress ). with( 'my_forge.example.com' ).and_return( '127.0.0.1' ) subject.should_receive( :stub_hosts_on ). - with( 'my_host', 'forge.puppetlabs.com' => '127.0.0.1' ) + with( host, 'forge.puppetlabs.com' => '127.0.0.1' ) subject.should_receive( :stub_hosts_on ). - with( 'my_host', 'forgeapi.puppetlabs.com' => '127.0.0.1' ) + with( host, 'forgeapi.puppetlabs.com' => '127.0.0.1' ) - subject.stub_forge_on( 'my_host', 'my_forge.example.com' ) + subject.stub_forge_on( host, 'my_forge.example.com' ) end end describe "#stub_forge" do it "delegates to #stub_forge_on with the default host" do @@ -673,10 +731,11 @@ it 'runs the pe-puppet on a system without pe-puppet-agent' do vardir = '/var' deb_agent = make_host( 'deb', :platform => 'debian-7-amd64' ) deb_agent.stub( :puppet ).and_return( { 'vardir' => vardir } ) + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :on ).with( deb_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail ) subject.should_receive( :on ).with( deb_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail ) subject.should_receive( :puppet_resource ).with( "service", "pe-puppet", "ensure=stopped").once subject.should_receive( :on ).once @@ -687,10 +746,11 @@ it 'runs the pe-puppet-agent on a unix system with pe-puppet-agent' do vardir = '/var' el_agent = make_host( 'el', :platform => 'el-5-x86_64' ) el_agent.stub( :puppet ).and_return( { 'vardir' => vardir } ) + subject.stub( :hosts ).and_return( hosts ) subject.should_receive( :on ).with( el_agent, "[ -e '#{vardir}/state/agent_catalog_run.lock' ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_fail ) subject.should_receive( :on ).with( el_agent, "[ -e /etc/init.d/pe-puppet-agent ]", :acceptable_exit_codes => [0,1] ).once.and_return( result_pass ) subject.should_receive( :puppet_resource ).with("service", "pe-puppet-agent", "ensure=stopped").once subject.should_receive( :on ).once @@ -758,20 +818,18 @@ end describe '#with_puppet_running_on' do let(:test_case_path) { 'testcase/path' } let(:tmpdir_path) { '/tmp/tmpdir' } - let(:puppet_path) { '/puppet/path' } - let(:puppetservice) { nil } let(:is_pe) { false } + let(:use_service) { false } + let(:platform) { 'redhat' } let(:host) do - FakeHost.new(:pe => is_pe, - :options => { - 'puppetpath' => puppet_path, - 'puppetservice' => puppetservice, - 'platform' => 'el' - }) + FakeHost.create('fakevm', "#{platform}-version-arch", + 'type' => is_pe ? 'pe': 'git', + 'use-service' => use_service + ) end def stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created subject.instance_variable_set(:@path, test_case_path) host.stub(:tmpdir).and_return(tmpdir_path) @@ -779,10 +837,11 @@ subject.stub( :options ).and_return( {} ) end before do stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created + subject.stub(:curl_with_retries) end it "raises an ArgumentError if you try to submit a String instead of a Hash of options" do expect { subject.with_puppet_running_on(host, '--foo --bar') }.to raise_error(ArgumentError, /conf_opts must be a Hash. You provided a String: '--foo --bar'/) end @@ -792,41 +851,154 @@ expect { subject.with_puppet_running_on(host, {}) }.to raise_error(RuntimeError, /puppet conf backup failed/) end + describe 'with jvm puppet' do + let(:default_confdir) { "/etc/puppet" } + let(:default_vardir) { "/var/lib/puppet" } + + let(:custom_confdir) { "/tmp/etc/puppet" } + let(:custom_vardir) { "/tmp/var/lib/puppet" } + + let(:command_line_args) {"--vardir=#{custom_vardir} --confdir=#{custom_confdir}"} + let(:conf_opts) { {:__commandline_args__ => command_line_args, + :is_jvm_puppet => true}} + + let(:default_jvm_puppet_opts) {{ "jruby-puppet" => { + "master-conf-dir" => default_confdir, + "master-var-dir" => default_vardir, + }}} + + let(:custom_jvm_puppet_opts) {{ "jruby-puppet" => { + "master-conf-dir" => custom_confdir, + "master-var-dir" => custom_vardir, + }}} + + let(:jvm_puppet_conf) { "/etc/jvm-puppet/conf.d/jvm-puppet.conf" } + let(:logger) { double } + + def stub_post_setup + subject.stub( :restore_puppet_conf_from_backup) + subject.stub( :bounce_service) + subject.stub( :stop_puppet_from_source_on) + subject.stub( :dump_puppet_log) + subject.stub( :restore_puppet_conf_from_backup) + subject.stub( :puppet_master_started) + subject.stub( :start_puppet_from_source_on!) + subject.stub( :lay_down_new_puppet_conf) + subject.stub( :logger) .and_return( logger ) + logger.stub( :error) + logger.stub( :debug) + end + + before do + stub_post_setup + subject.stub( :options) .and_return( {:is_jvm_puppet => true}) + subject.stub( :modify_tk_config) + host.stub(:puppet).with('master') .and_return({'confdir' => default_confdir, + 'vardir' => default_vardir}) + end + + describe 'and command line args passed' do + it 'modifies SUT trapperkeeper configuration w/ command line args' do + subject.should_receive( :modify_tk_config).with(host, jvm_puppet_conf, + custom_jvm_puppet_opts) + subject.with_puppet_running_on(host, conf_opts) + end + end + + describe 'and no command line args passed' do + let(:command_line_args) { nil } + it 'modifies SUT trapperkeeper configuration w/ puppet defaults' do + subject.should_receive( :modify_tk_config).with(host, jvm_puppet_conf, + default_jvm_puppet_opts) + subject.with_puppet_running_on(host, conf_opts) + end + end + end + describe "with valid arguments" do before do Tempfile.should_receive(:open).with('beaker') end - context 'with puppetservice and service-path defined' do - let(:puppetservice) { 'whatever' } + context 'for pe hosts' do + let(:is_pe) { true } + let(:service_restart) { true } it 'bounces puppet twice' do + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times + end + + it 'yields to a block after bouncing service' do + execution = 0 subject.stub(:curl_with_retries) + expect do + subject.with_puppet_running_on(host, {}) do + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(1).times + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(1).times + execution += 1 + end + end.to change { execution }.by(1) + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times + end + end + + context 'for foss packaged hosts using passenger' do + before(:each) do + host.uses_passenger! + end + + it 'bounces puppet twice' do + subject.stub(:curl_with_retries) subject.with_puppet_running_on(host, {}) - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).exactly(2).times - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/apache2ctl graceful/).exactly(2).times end - it 'yield to a block after bouncing service' do + it 'yields to a block after bouncing service' do execution = 0 subject.stub(:curl_with_retries) expect do subject.with_puppet_running_on(host, {}) do - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).once - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).once + expect(host).to execute_commands_matching(/apache2ctl graceful/).once execution += 1 end end.to change { execution }.by(1) - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).exactly(2).times - expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/apache2ctl graceful/).exactly(2).times end end + context 'for foss packaged hosts using webrick' do + let(:use_service) { true } + + it 'stops and starts master using service scripts' do + subject.stub(:curl_with_retries) + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times + end + + it 'yields to a block after stopping and starting service' do + execution = 0 + expect do + subject.with_puppet_running_on(host, {}) do + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).once + execution += 1 + end + end.to change { execution }.by(1) + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times + expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times + end + end + context 'running from source' do + let('use-service') { false } it 'does not try to stop if not started' do subject.should_receive(:start_puppet_from_source_on!).and_return false subject.should_not_receive(:stop_puppet_from_source_on) @@ -866,34 +1038,53 @@ end end end describe 'backup and restore of puppet.conf' do - let(:original_location) { "#{puppet_path}/puppet.conf" } + let(:original_location) { "#{host['puppetpath']}/puppet.conf" } let(:backup_location) { "#{tmpdir_path}/puppet.conf.bak" } let(:new_location) { "#{tmpdir_path}/puppet.conf" } - before do - host.should_receive(:port_open?).with(8140).and_return(true) - end + context 'when a puppetservice is used' do + let(:use_service) { true } - it 'backs up puppet.conf' do - subject.with_puppet_running_on(host, {}) - expect(host).to execute_commands_matching(/cp #{original_location} #{backup_location}/).once - expect(host).to execute_commands_matching(/cat #{new_location} > #{original_location}/).once + it 'backs up puppet.conf' do + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching(/cp #{original_location} #{backup_location}/).once + expect(host).to execute_commands_matching(/cat #{new_location} > #{original_location}/).once + end + it 'restores puppet.conf before restarting' do + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching_in_order(/cat '#{backup_location}' > '#{original_location}'/, + /ensure=stopped/, + /ensure=running/) + end end - it 'restores puppet.conf' do - subject.with_puppet_running_on(host, {}) - expect(host).to execute_commands_matching(/cat '#{backup_location}' > '#{original_location}'/).once - end + context 'when a puppetservice is not used' do + before do + host.should_receive(:port_open?).with(8140).and_return(true) + end - it "doesn't restore a non-existent file" do - subject.stub(:backup_the_file) - subject.with_puppet_running_on(host, {}) - expect(host).to execute_commands_matching(/rm -f '#{original_location}'/) + it 'backs up puppet.conf' do + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching(/cp #{original_location} #{backup_location}/).once + expect(host).to execute_commands_matching(/cat #{new_location} > #{original_location}/).once + end + + it 'restores puppet.conf after restarting when a puppetservice is not used' do + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching_in_order(/kill [^-]/, + /cat '#{backup_location}' > '#{original_location}'/m) + end + + it "doesn't restore a non-existent file" do + subject.stub(:backup_the_file) + subject.with_puppet_running_on(host, {}) + expect(host).to execute_commands_matching(/rm -f '#{original_location}'/) + end end end describe 'handling failures' do before do @@ -952,16 +1143,29 @@ end end describe '#fact_on' do - it 'retreives a fact on host(s)' do + it 'retrieves a fact on a single host' do + result.stdout = "family\n" subject.should_receive(:facter).with('osfamily',{}).once subject.should_receive(:on).and_return(result) - subject.fact_on('host','osfamily') + expect( subject.fact_on('host','osfamily') ).to be === result.stdout.chomp end + + it 'retrieves an array of facts from multiple hosts' do + subject.stub( :hosts ).and_return( hosts ) + times = hosts.length + result.stdout = "family\n" + hosts.each do |host| + host.should_receive(:exec).and_return(result) + end + + expect( subject.fact_on(hosts,'osfamily') ).to be === [result.stdout.chomp] * hosts.length + + end end describe '#fact' do it 'delegates to #fact_on with the default host' do subject.stub(:hosts).and_return(hosts) @@ -969,11 +1173,66 @@ subject.fact('osfamily') end end + describe 'modify_tk_config' do + let(:host) { double.as_null_object } + let(:config_file_path) { 'existing-file-path'} + let(:invalid_config_file_path) { 'nonexisting-file-path'} + let(:options_hash) { {:key => 'value'} } + let(:replace) { true } + shared_examples 'modify-tk-config-without-error' do + it 'dumps to the SUT config file path' do + JSON.stub(:dump) + subject.stub(:create_remote_file).with(host, config_file_path, anything()) + subject.modify_tk_config(host, config_file_path, options_hash, replace) + end + end + + before do + host.stub(:file_exist?).with(invalid_config_file_path).and_return(false) + host.stub(:file_exist?).with(config_file_path).and_return(true) + end + + describe 'if file does not exist on SUT' do + it 'raises Runtime error' do + expect do + subject.modify_tk_config(host, invalid_config_file_path, options_hash) + end.to raise_error(RuntimeError, /.* does not exist on .*/) + end + end + + describe 'given an empty options hash' do + it 'returns nil' do + expect(subject.modify_tk_config(host, 'blahblah', {})).to eq(nil) + end + end + + describe 'given a non-empty options hash' do + + describe 'given a false value to its `replace` parameter' do + let(:replace) { false } + before do + subject.should_receive(:read_tk_config_string).with(anything()) + end + include_examples('modify-tk-config-without-error') + end + + describe 'given a true value to its `replace` parameter' do + before do + JSON.should_receive(:dump) + subject.should_receive(:create_remote_file).with(host, config_file_path, anything()) + end + include_examples('modify-tk-config-without-error') + end + + end + + end + describe 'copy_module_to' do let(:ignore_list){%w(.git .idea .vagrant .vendor acceptance spec tests log . ..)} let(:source){'./'} let(:target){'/etc/puppetlabs/puppet/modules/testmodule'} let(:module_parse_name){'testmodule'} @@ -1069,18 +1328,7 @@ subject.logger.should_receive(:debug).with("No Modulefile found at #{directory}, moving up") subject.logger.should_receive(:error).with("At root, can't parse for another directory") expect(subject.parse_for_moduleroot(directory)).to eq(nil) end - end -end - -module FakeFS - class File < StringIO - def self.absolute_path(filepath) - RealFile.absolute_path(filepath) - end - def self.expand_path(filepath) - RealFile.expand_path(filepath) - end end end