spec/stub_commands_spec.rb in capistrano-spec-0.3.2 vs spec/stub_commands_spec.rb in capistrano-spec-0.3.3

- old
+ new

@@ -25,52 +25,55 @@ nil end end end + subject(:configuration) { @configuration } + it 'should allow to stub command output' do - @configuration.stub_command 'pwd', :data => '/stubded/path' - @configuration.remote_pwd.should == '/stubded/path' + configuration.stub_command 'pwd', :data => '/stubded/path' + expect { remote_pwd.should == '/stubded/path' } end it 'should allow to stub sudo command output' do - @configuration.stub_command "sudo -p 'sudo password: ' pwd", :data => '/stubbed/path' - @configuration.remote_sudo_pwd.should == '/stubbed/path' + configuration.stub_command "sudo -p 'sudo password: ' pwd", :data => '/stubbed/path' + expect { remote_sudo_pwd.should == '/stubbed/path' } end it 'should allow to stub custom command output' do - @configuration.stub_command 'pwd', :data => '/stubbed/path' - @configuration.custom_pwd.should == 'out: /stubbed/path' + configuration.stub_command 'pwd', :data => '/stubbed/path' + expect { custom_pwd.should == 'out: /stubbed/path' } end it 'should allow to stub stream' do - @configuration.stub_command 'pwd', :data => '/stubbed/path', :stream => :err - @configuration.custom_pwd.should == 'err: /stubbed/path' + configuration.stub_command 'pwd', :data => '/stubbed/path', :stream => :err + expect { custom_pwd.should == 'err: /stubbed/path' } end it 'should allow to stub commands without block' do - @configuration.stub_command 'pwd' + configuration.stub_command 'pwd' expect { @configuration.no_block }.to_not raise_error(NoMethodError) end it 'should allow to stub command processing' do - @configuration.stub_command 'pwd', :with => proc { |cmd| cmd } - @configuration.remote_pwd.should == 'pwd' + configuration.stub_command 'pwd', :with => proc { |cmd| cmd } + expect { remote_pwd.should == 'pwd' } end + let(:testvar) { false } + it 'should allow to stub command processing (2)' do - testvar = false - @configuration.stub_command 'pwd' do |cmd| testvar = true end - @configuration.no_block - testvar.should be_true + configuration.stub_command 'pwd' do |cmd| testvar = true end + configuration.no_block + expect { testvar.should be_true} end it 'should allow to stub command processing with error' do - @configuration.stub_command 'pwd', :raise => ::Capistrano::CommandError + configuration.stub_command 'pwd', :raise => ::Capistrano::CommandError expect { @configuration.no_block }.to raise_error(::Capistrano::CommandError) end it 'should allow to stub command processing with CommandError' do - @configuration.stub_command 'pwd', :fail => true - expect { @configuration.no_block }.to raise_error(::Capistrano::CommandError) + configuration.stub_command 'pwd', :fail => true + expect { configuration.no_block }.to raise_error(::Capistrano::CommandError) end end