spec/ rubocopied
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe GitUpdater do
|
||||
@@ -6,65 +8,65 @@ describe GitUpdater do
|
||||
@git_updater = GitUpdater.new
|
||||
end
|
||||
|
||||
describe "#is_installed?" do
|
||||
describe '#is_installed?' do
|
||||
after :each do
|
||||
stub_system_command(@git_updater, /^git .* status/, @stub_value)
|
||||
@git_updater.is_installed?.should === @expected
|
||||
end
|
||||
|
||||
it "should return false if the command is not found" do
|
||||
@stub_value = "git: command not found"
|
||||
@expected = false
|
||||
it 'should return false if the command is not found' do
|
||||
@stub_value = 'git: command not found'
|
||||
@expected = false
|
||||
end
|
||||
|
||||
it "should return true if the repo is a git one" do
|
||||
it 'should return true if the repo is a git one' do
|
||||
@stub_value = "# On branch master\n# Changed but not updated:"
|
||||
@expected = true
|
||||
@expected = true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#local_revision_number" do
|
||||
describe '#local_revision_number' do
|
||||
after :each do
|
||||
stub_system_command(@git_updater, /^git .* log/, @stub_value)
|
||||
@git_updater.local_revision_number.should === @expected
|
||||
end
|
||||
|
||||
it "should return 79c01f3" do
|
||||
@stub_value = "
|
||||
it 'should return 79c01f3' do
|
||||
@stub_value = '
|
||||
commit 79c01f3ed535a8e33876ea091d8217cae7df4028
|
||||
Author: Moi <tadimm>
|
||||
Date: Wed Jul 11 23:22:16 2012 +0100"
|
||||
@expected = "79c01f3"
|
||||
Date: Wed Jul 11 23:22:16 2012 +0100'
|
||||
@expected = '79c01f3'
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
it "should do nothing xD" do
|
||||
stub_system_command(@git_updater, /^git .* pull/, "Already up-to-date.")
|
||||
@git_updater.update().should === "Already up-to-date."
|
||||
describe '#update' do
|
||||
it 'should do nothing xD' do
|
||||
stub_system_command(@git_updater, /^git .* pull/, 'Already up-to-date.')
|
||||
@git_updater.update().should === 'Already up-to-date.'
|
||||
end
|
||||
end
|
||||
|
||||
describe "#has_local_changes?" do
|
||||
describe '#has_local_changes?' do
|
||||
after :each do
|
||||
stub_system_command(@git_updater, /^git .* diff --exit-code 2>&1/, @stub_value)
|
||||
@git_updater.has_local_changes?.should === @expected
|
||||
end
|
||||
|
||||
it "should return true if there are local changes" do
|
||||
it 'should return true if there are local changes' do
|
||||
@stub_value = 'diff'
|
||||
@expected = true
|
||||
@expected = true
|
||||
end
|
||||
|
||||
it "should return false if there are no local changes" do
|
||||
it 'should return false if there are no local changes' do
|
||||
@stub_value = ''
|
||||
@expected = false
|
||||
@expected = false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#reset_head" do
|
||||
it "should reset the local repo" do
|
||||
stub_system_command(@git_updater, /^git .* reset --hard HEAD/, "HEAD is now at")
|
||||
describe '#reset_head' do
|
||||
it 'should reset the local repo' do
|
||||
stub_system_command(@git_updater, /^git .* reset --hard HEAD/, 'HEAD is now at')
|
||||
@git_updater.reset_head.should match(/^HEAD is now at/)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe SvnUpdater do
|
||||
@@ -6,23 +8,23 @@ describe SvnUpdater do
|
||||
@svn_updater = SvnUpdater.new
|
||||
end
|
||||
|
||||
describe "#is_installed?" do
|
||||
describe '#is_installed?' do
|
||||
after :each do
|
||||
stub_system_command(@svn_updater, /^svn info/, @stub_value)
|
||||
@svn_updater.is_installed?.should === @expected
|
||||
end
|
||||
|
||||
it "should return false if the svn command is not found" do
|
||||
@stub_value = "svn: command not found"
|
||||
@expected = false
|
||||
it 'should return false if the svn command is not found' do
|
||||
@stub_value = 'svn: command not found'
|
||||
@expected = false
|
||||
end
|
||||
|
||||
it "should return false if the repository is not manage by svn" do
|
||||
it 'should return false if the repository is not manage by svn' do
|
||||
@stub_value = "svn: '.' is not a working copy"
|
||||
@expected = false
|
||||
@expected = false
|
||||
end
|
||||
|
||||
it "should return true" do
|
||||
it 'should return true' do
|
||||
@stub_value = '<?xml version="1.0"?>
|
||||
<info>
|
||||
<entry kind="dir" path="." revision="362">
|
||||
@@ -45,13 +47,13 @@ describe SvnUpdater do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#local_revision_number" do
|
||||
describe '#local_revision_number' do
|
||||
after :each do
|
||||
stub_system_command(@svn_updater, /^svn info/, @stub_value)
|
||||
@svn_updater.local_revision_number.should === @expected
|
||||
end
|
||||
|
||||
it "should return 399" do
|
||||
it 'should return 399' do
|
||||
@stub_value = '<?xml version="1.0"?>
|
||||
<info>
|
||||
<entry kind="dir" path="." revision="362">
|
||||
@@ -70,14 +72,14 @@ describe SvnUpdater do
|
||||
</commit>
|
||||
</entry>
|
||||
</info>'
|
||||
@expected = "362"
|
||||
@expected = '362'
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
it "should do nothing xD" do
|
||||
stub_system_command(@svn_updater, /^svn up/, "At revision 425.")
|
||||
@svn_updater.update().should === "At revision 425."
|
||||
describe '#update' do
|
||||
it 'should do nothing xD' do
|
||||
stub_system_command(@svn_updater, /^svn up/, 'At revision 425.')
|
||||
@svn_updater.update().should === 'At revision 425.'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe UpdaterFactory do
|
||||
|
||||
describe "#available_updaters_classes" do
|
||||
describe '#available_updaters_classes' do
|
||||
after :each do
|
||||
UpdaterFactory.available_updaters_classes.sort.should === @expected.sort
|
||||
end
|
||||
|
||||
it "should return [:GitUpdater, :SvnUpdater]" do
|
||||
it 'should return [:GitUpdater, :SvnUpdater]' do
|
||||
@expected = [:GitUpdater, :SvnUpdater]
|
||||
end
|
||||
|
||||
it "should return [:TestUpdater, :GitUpdater, :SvnUpdater]" do
|
||||
it 'should return [:TestUpdater, :GitUpdater, :SvnUpdater]' do
|
||||
class TestUpdater < Updater
|
||||
end
|
||||
|
||||
@@ -20,7 +22,7 @@ describe UpdaterFactory do
|
||||
end
|
||||
|
||||
# TODO : Find a way to test that
|
||||
describe "#get_updater" do
|
||||
describe '#get_updater' do
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Updater do
|
||||
@@ -11,8 +13,8 @@ describe Updater do
|
||||
Object.send(:remove_const, :TestUpdater)
|
||||
end
|
||||
|
||||
describe "non implementation of #is_installed?, #has_update? and #update" do
|
||||
it "should raise errors" do
|
||||
describe 'non implementation of #is_installed?, #has_update? and #update' do
|
||||
it 'should raise errors' do
|
||||
test_updater = TestUpdater.new
|
||||
methods_to_call = [:is_installed?, :update, :local_revision_number]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user