falkorlib 0.1.0 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +56 -4
- data/README.md +147 -34
- data/Rakefile +42 -23
- data/falkorlib.gemspec +11 -7
- data/lib/falkorlib.rb +31 -2
- data/lib/falkorlib/common.rb +93 -41
- data/lib/falkorlib/config.rb +91 -0
- data/lib/falkorlib/git.rb +15 -0
- data/lib/falkorlib/git/base.rb +405 -0
- data/lib/falkorlib/git/flow.rb +120 -0
- data/lib/falkorlib/git_tasks.rb +56 -0
- data/lib/falkorlib/loader.rb +9 -1
- data/lib/falkorlib/tasks.rb +30 -0
- data/lib/falkorlib/tasks/git.rake +121 -0
- data/lib/falkorlib/tasks/git.rb +56 -0
- data/lib/falkorlib/tasks/gitflow.rake +139 -0
- data/{tasks/spec_test.rake → lib/falkorlib/tasks/rspec.rake} +4 -3
- data/lib/falkorlib/tasks/yard.rake +78 -0
- data/lib/falkorlib/version.rb +62 -54
- data/lib/falkorlib/versioning.rb +162 -0
- data/spec/falkorlib/common_spec.rb +12 -12
- data/spec/falkorlib/git_spec.rb +191 -0
- data/spec/falkorlib/gitflow_spec.rb +47 -45
- data/spec/falkorlib/versioning_spec.rb +108 -0
- data/spec/spec_helper.rb +58 -9
- metadata +80 -24
- data/lib/falkorlib/gitflow.rb +0 -71
- data/tasks/debug_mail.rake +0 -75
- data/tasks/debug_mail.txt +0 -13
- data/tasks/gem.rake +0 -73
- data/tasks/unit_test.rake +0 -77
- data/tasks/yard.rake +0 -51
- data/test/test_gitflow.rb +0 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Installs a rake task for for running examples written using rspec.
|
|
2
2
|
#
|
|
3
|
-
# This file installs the 'rake
|
|
3
|
+
# This file installs the 'rake rspec' (aliased as 'rake spec') as well as
|
|
4
4
|
# extends 'rake test' to run spec tests, if any. It is automatically generated
|
|
5
5
|
# by Noe from your .noespec file, and should therefore be configured there,
|
|
6
6
|
# under the variables/rake_tasks/spec_test entry, as illustrated below:
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
#
|
|
28
28
|
begin
|
|
29
29
|
require "rspec/core/rake_task"
|
|
30
|
-
desc "Run RSpec code examples"
|
|
31
|
-
RSpec::Core::RakeTask.new(:
|
|
30
|
+
desc "Run RSpec code examples '*_spec.rb' from the spec/ directory"
|
|
31
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
|
32
32
|
# Glob pattern to match files.
|
|
33
33
|
#t.pattern = "spec/**/test_*.rb"
|
|
34
34
|
t.pattern = "spec/**/*_spec.rb"
|
|
35
|
+
#t.pattern = "spec/**/versioning_spec.rb"
|
|
35
36
|
|
|
36
37
|
# Whether or not to fail Rake when an error occurs (typically when
|
|
37
38
|
# examples fail).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Ven 2014-06-06 15:54 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
# Installs a rake task to generate API documentation using yard.
|
|
6
|
+
#
|
|
7
|
+
# This file installs the 'rake yard' task. It is automatically generated by Noe from
|
|
8
|
+
# your .noespec file, and should therefore be configured there, under the
|
|
9
|
+
# variables/rake_tasks/yard entry, as illustrated below:
|
|
10
|
+
#
|
|
11
|
+
# variables:
|
|
12
|
+
# rake_tasks:
|
|
13
|
+
# yard:
|
|
14
|
+
# files: lib/**/*.rb
|
|
15
|
+
# options: []
|
|
16
|
+
# ...
|
|
17
|
+
#
|
|
18
|
+
# If you have specific needs requiring manual intervention on this file,
|
|
19
|
+
# don't forget to set safe-override to false in your noe specification:
|
|
20
|
+
#
|
|
21
|
+
# template-info:
|
|
22
|
+
# manifest:
|
|
23
|
+
# tasks/yard.rake:
|
|
24
|
+
# safe-override: false
|
|
25
|
+
#
|
|
26
|
+
# This file has been written to conform to yard v0.6.4. More information about
|
|
27
|
+
# yard and the rake task installed below can be found on http://yardoc.org/
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
require "falkorlib"
|
|
31
|
+
|
|
32
|
+
#.....................
|
|
33
|
+
namespace :yard do
|
|
34
|
+
begin
|
|
35
|
+
require "yard"
|
|
36
|
+
|
|
37
|
+
########### yard:doc ###########
|
|
38
|
+
desc "Generate yard documentation"
|
|
39
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
40
|
+
# Array of options passed to yardoc commandline. See 'yardoc --help' about this
|
|
41
|
+
t.options = ["--output-dir", "doc/api", "-", "README.md", "CHANGELOG.md", "LICENCE.md"]
|
|
42
|
+
|
|
43
|
+
# Array of ruby source files (and any extra documentation files
|
|
44
|
+
# separated by '-')
|
|
45
|
+
t.files = ["lib/**/*.rb"]
|
|
46
|
+
|
|
47
|
+
# A proc to call before running the task
|
|
48
|
+
# t.before = proc{ }
|
|
49
|
+
|
|
50
|
+
# A proc to call after running the task
|
|
51
|
+
t.after = proc{
|
|
52
|
+
puts "\nFull documentation is now generated -- you probably want now to\n\t open doc/api/index.html"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# An optional lambda to run against all objects being generated.
|
|
56
|
+
# Any object that the lambda returns false for will be excluded
|
|
57
|
+
# from documentation.
|
|
58
|
+
# t.verifier = lambda{|obj| true}
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
rescue LoadError
|
|
63
|
+
task :yard do
|
|
64
|
+
abort 'yard is not available. In order to run yard, you must: gem install yard'
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
########### yard:stats ###########
|
|
69
|
+
desc "Collect statistics as regards yard documentation"
|
|
70
|
+
task :stats do |t|
|
|
71
|
+
Dir.chdir(FalkorLib.config.root) do
|
|
72
|
+
FalkorLib::Common.run %{yard stats --list-undoc}
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
data/lib/falkorlib/version.rb
CHANGED
|
@@ -1,65 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Mer 2014-06-18 17:45 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
|
6
|
+
#
|
|
7
|
+
# FalkorLib Version management
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
module FalkorLib #:nodoc:
|
|
11
|
+
|
|
12
|
+
# Management of the current version of the library
|
|
13
|
+
# @see falkorlib/tasks/versioning.rake
|
|
2
14
|
module Version
|
|
3
15
|
|
|
4
|
-
##
|
|
5
16
|
# Change the MAJOR, MINOR and PATCH constants below
|
|
6
17
|
# to adjust the version of the FalkorLib gem
|
|
7
18
|
#
|
|
8
|
-
# MAJOR:
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
# MAJOR: Defines the major version
|
|
20
|
+
# MINOR: Defines the minor version
|
|
21
|
+
# PATCH: Defines the patch version
|
|
22
|
+
MAJOR, MINOR, PATCH = 0, 2, 8
|
|
23
|
+
|
|
24
|
+
module_function
|
|
25
|
+
|
|
26
|
+
## Returns the major version ( big release based off of multiple minor releases )
|
|
27
|
+
def major
|
|
28
|
+
MAJOR
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
## Returns the minor version ( small release based off of multiple patches )
|
|
32
|
+
def minor
|
|
33
|
+
MINOR
|
|
34
|
+
end
|
|
21
35
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
36
|
+
## Returns the patch version ( updates, features and (crucial) bug fixes )
|
|
37
|
+
def patch
|
|
38
|
+
PATCH
|
|
39
|
+
end
|
|
27
40
|
|
|
28
|
-
##
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
##
|
|
35
|
-
# Returns the full version
|
|
36
|
-
def self.to_s
|
|
37
|
-
[ MAJOR, MINOR, PATCH ].join('.')
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
## Return a new version number based on
|
|
41
|
-
# - the old version (format: x.y.z)
|
|
42
|
-
# - the level of bumping (either :major, :minor, :patch)
|
|
43
|
-
def bump_version(oldversion, level)
|
|
44
|
-
if oldversion =~ /^(\d+)\.(\d+)\.(\d+)$/
|
|
45
|
-
major = $1.to_i
|
|
46
|
-
minor = $2.to_i
|
|
47
|
-
patch = $3.to_i
|
|
48
|
-
end
|
|
49
|
-
case level
|
|
50
|
-
when ':major'
|
|
51
|
-
major += 1
|
|
52
|
-
minor = 0
|
|
53
|
-
patch = 0
|
|
54
|
-
when ':minor'
|
|
55
|
-
minor += 1
|
|
56
|
-
patch = 0
|
|
57
|
-
when ':patch'
|
|
58
|
-
patch += 1
|
|
59
|
-
end
|
|
60
|
-
version = [major, minor, patch].compact.join('.')
|
|
61
|
-
end
|
|
41
|
+
## @return the full version string
|
|
42
|
+
def to_s
|
|
43
|
+
[ MAJOR, MINOR, PATCH ].join('.')
|
|
44
|
+
end
|
|
62
45
|
|
|
46
|
+
# ## Return a new version number based on
|
|
47
|
+
# # @param oldversion the old version (format: x.y.z)
|
|
48
|
+
# # @param level the level of bumping (either :major, :minor, :patch)
|
|
49
|
+
# def bump_version(oldversion, level)
|
|
50
|
+
# major = minor = patch = 0
|
|
51
|
+
# if oldversion =~ /^(\d+)\.(\d+)\.(\d+)$/
|
|
52
|
+
# major = $1.to_i
|
|
53
|
+
# minor = $2.to_i
|
|
54
|
+
# patch = $3.to_i
|
|
55
|
+
# end
|
|
56
|
+
# case level
|
|
57
|
+
# when ':major'
|
|
58
|
+
# major += 1
|
|
59
|
+
# minor = 0
|
|
60
|
+
# patch = 0
|
|
61
|
+
# when ':minor'
|
|
62
|
+
# minor += 1
|
|
63
|
+
# patch = 0
|
|
64
|
+
# when ':patch'
|
|
65
|
+
# patch += 1
|
|
66
|
+
# end
|
|
67
|
+
# version = [major, minor, patch].compact.join('.')
|
|
68
|
+
# end
|
|
63
69
|
end
|
|
70
|
+
|
|
71
|
+
# Shorter version of the Gem's VERSION
|
|
64
72
|
VERSION = Version.to_s
|
|
65
73
|
end
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
################################################################################
|
|
3
|
+
# Time-stamp: <Jeu 2014-06-19 18:41 svarrette>
|
|
4
|
+
################################################################################
|
|
5
|
+
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
|
6
|
+
#
|
|
7
|
+
# FalkorLib Version management
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
module FalkorLib #:nodoc:
|
|
11
|
+
|
|
12
|
+
module Config
|
|
13
|
+
|
|
14
|
+
# Default configuration for Versioning Management
|
|
15
|
+
module Versioning
|
|
16
|
+
# Versioning Management defaults
|
|
17
|
+
DEFAULTS = {
|
|
18
|
+
:default => '0.0.1',
|
|
19
|
+
:levels => [ 'major', 'minor', 'patch' ],
|
|
20
|
+
:type => 'file',
|
|
21
|
+
:source => {
|
|
22
|
+
'file' => {
|
|
23
|
+
:filename => 'VERSION'
|
|
24
|
+
},
|
|
25
|
+
'gem' => {
|
|
26
|
+
:filename => 'lib/falkorlib/version.rb',
|
|
27
|
+
:getmethod => 'FalkorLib::Version.to_s',
|
|
28
|
+
#:setmethod => 'FalkorLib::Version.set',
|
|
29
|
+
:pattern => '^(\s*)MAJOR\s*,\s*MINOR,\s*PATCH\s*=\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)'
|
|
30
|
+
},
|
|
31
|
+
'tag' => {
|
|
32
|
+
:suffix => 'v'
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Semantic Versioning Management
|
|
40
|
+
# @see falkorlib/tasks/versioning.rake
|
|
41
|
+
module Versioning
|
|
42
|
+
module_function
|
|
43
|
+
|
|
44
|
+
## extract the major part of the version
|
|
45
|
+
def major(version)
|
|
46
|
+
res = 0
|
|
47
|
+
res = $1 if version =~ /^\s*(\d+)\.\d+\.\d+/
|
|
48
|
+
res
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
## extract the minor part of the version
|
|
52
|
+
def minor(version)
|
|
53
|
+
res = 0
|
|
54
|
+
res = $1 if version =~ /^\s*\d+\.(\d+)\.\d+/
|
|
55
|
+
res
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
## extract the patch part of the version
|
|
59
|
+
def patch(version)
|
|
60
|
+
res = 0
|
|
61
|
+
res = $1 if version =~ /^\s*\d+\.\d+\.(\d+)/
|
|
62
|
+
res
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## get the current version
|
|
67
|
+
def get_version(rootdir = Dir.pwd)
|
|
68
|
+
version = FalkorLib.config[:versioning][:default]
|
|
69
|
+
type = FalkorLib.config[:versioning][:type]
|
|
70
|
+
source = FalkorLib.config[:versioning][:source][ type ]
|
|
71
|
+
case type
|
|
72
|
+
when 'file'
|
|
73
|
+
versionfile = File.join( rootdir, source[:filename] )
|
|
74
|
+
version = File.read( versionfile ).chomp if File.exist? ( versionfile )
|
|
75
|
+
when 'gem'
|
|
76
|
+
getmethod = source[:getmethod ]
|
|
77
|
+
version = eval( getmethod ) unless (getmethod.nil? || getmethod.empty?)
|
|
78
|
+
end
|
|
79
|
+
version
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
## Set the version
|
|
83
|
+
def set_version(version, rootdir = Dir.pwd)
|
|
84
|
+
exit_status = 0
|
|
85
|
+
type = FalkorLib.config[:versioning][:type]
|
|
86
|
+
source = FalkorLib.config[:versioning][:source][ type ]
|
|
87
|
+
versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?
|
|
88
|
+
filelist = FalkorLib::Git.list_files( rootdir )
|
|
89
|
+
major, minor, patch = major(version), minor(version), patch(version)
|
|
90
|
+
#tocommit = ""
|
|
91
|
+
case type
|
|
92
|
+
when 'file'
|
|
93
|
+
info "writing version changes in #{source[:filename]}"
|
|
94
|
+
File.open(versionfile, 'w') {|f| f.puts version } if File.exist? ( versionfile )
|
|
95
|
+
when 'gem'
|
|
96
|
+
info "=> writing version changes in #{source[:filename]}"
|
|
97
|
+
File.open(versionfile, 'r+') do |f|
|
|
98
|
+
text = f.read
|
|
99
|
+
text.gsub!(/^(\s*)MAJOR\s*,\s*MINOR,\s*PATCH\s*=\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(.*)$/,
|
|
100
|
+
'\1' + "MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}" + '\5')
|
|
101
|
+
f.rewind
|
|
102
|
+
f.write(text)
|
|
103
|
+
end
|
|
104
|
+
#exit 1
|
|
105
|
+
end
|
|
106
|
+
Dir.chdir( rootdir ) do
|
|
107
|
+
next if source[:filename].nil?
|
|
108
|
+
unless filelist.include?( source[:filename] )
|
|
109
|
+
warning "The version file #{source[:filename]} is not part of the Git repository"
|
|
110
|
+
answer = ask("Adding the file to the repository? (Y|n)", 'Yes')
|
|
111
|
+
next if answer =~ /n.*/i
|
|
112
|
+
exit_status = FalkorLib::Git.add(versionfile, "Adding the version file '#{source[:filename]}', inialized to the '#{version}' version" )
|
|
113
|
+
next
|
|
114
|
+
end
|
|
115
|
+
run %{
|
|
116
|
+
git diff #{source[:filename]}
|
|
117
|
+
}
|
|
118
|
+
answer = ask(cyan("=> Commit the changes of the version file to the repository? (Y|n)"), 'Yes')
|
|
119
|
+
next if answer =~ /n.*/i
|
|
120
|
+
run %{
|
|
121
|
+
git commit -s -m "bump to version '#{version}'" #{source[:filename]}
|
|
122
|
+
}
|
|
123
|
+
exit_status = $?.to_i
|
|
124
|
+
if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )
|
|
125
|
+
run %{
|
|
126
|
+
bundle
|
|
127
|
+
git commit -s -m "Update Gemfile.lock accordingly" Gemfile.lock
|
|
128
|
+
} if command?( 'bundle' )
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
exit_status
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## Return a new version number based on
|
|
138
|
+
# @param oldversion the old version (format: x.y.z)
|
|
139
|
+
# @param level the level of bumping (either :major, :minor, :patch)
|
|
140
|
+
def bump(oldversion, level)
|
|
141
|
+
major = minor = patch = 0
|
|
142
|
+
if oldversion =~ /^(\d+)\.(\d+)\.(\d+)$/
|
|
143
|
+
major = $1.to_i
|
|
144
|
+
minor = $2.to_i
|
|
145
|
+
patch = $3.to_i
|
|
146
|
+
end
|
|
147
|
+
case level.to_sym
|
|
148
|
+
when :major
|
|
149
|
+
major += 1
|
|
150
|
+
minor = 0
|
|
151
|
+
patch = 0
|
|
152
|
+
when :minor
|
|
153
|
+
minor += 1
|
|
154
|
+
patch = 0
|
|
155
|
+
when :patch
|
|
156
|
+
patch += 1
|
|
157
|
+
end
|
|
158
|
+
version = [major, minor, patch].compact.join('.')
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
require 'tempfile'
|
|
3
3
|
|
|
4
|
-
describe FalkorLib do
|
|
4
|
+
describe FalkorLib::Common do
|
|
5
5
|
|
|
6
6
|
include FalkorLib::Common
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ describe FalkorLib do
|
|
|
11
11
|
@print_test_conf = {
|
|
12
12
|
:info => {
|
|
13
13
|
:color => :green,
|
|
14
|
-
|
|
14
|
+
:prefix => "[INFO]",
|
|
15
15
|
},
|
|
16
16
|
:warning => {
|
|
17
17
|
:color => :cyan,
|
|
@@ -25,7 +25,7 @@ describe FalkorLib do
|
|
|
25
25
|
|
|
26
26
|
# Check the color functions
|
|
27
27
|
@print_test_conf.values.collect{ |e| e[:color] }.each do |color|
|
|
28
|
-
|
|
28
|
+
it "##{color} - check #{color} text" do
|
|
29
29
|
STDOUT.should_receive(:puts).with(send("#{color}", "#{color} text"))
|
|
30
30
|
puts send("#{color}", "#{color} text")
|
|
31
31
|
end
|
|
@@ -33,7 +33,7 @@ describe FalkorLib do
|
|
|
33
33
|
|
|
34
34
|
# Check the prining messages
|
|
35
35
|
@print_test_conf.each do |method,conf|
|
|
36
|
-
|
|
36
|
+
it "##{method} - put a #{method} message" do
|
|
37
37
|
((method == :error) ? STDERR : STDOUT).should_receive(:puts).with(send("#{conf[:color]}", "#{conf[:prefix]} #{method} text"))
|
|
38
38
|
if (method == :error)
|
|
39
39
|
lambda {
|
|
@@ -48,7 +48,7 @@ describe FalkorLib do
|
|
|
48
48
|
# Check the ask function
|
|
49
49
|
['', 'default'].each do |default_answer|
|
|
50
50
|
@query = "Am I a query"
|
|
51
|
-
it "
|
|
51
|
+
it "#ask - ask '#{@query}' with default answer '#{default_answer}' and no answer" do
|
|
52
52
|
STDIN.should_receive(:gets).and_return('')
|
|
53
53
|
results = capture(:stdout) {
|
|
54
54
|
answer = ask(@query, default_answer)
|
|
@@ -67,14 +67,14 @@ describe FalkorLib do
|
|
|
67
67
|
|
|
68
68
|
# Check the really_continue? function
|
|
69
69
|
[ '', 'Yes', 'y', 'Y', 'yes' ].each do |answer|
|
|
70
|
-
it "should really continue after answer '#{answer}'" do
|
|
70
|
+
it "#really_continue? - should really continue after answer '#{answer}'" do
|
|
71
71
|
STDIN.should_receive(:gets).and_return(answer)
|
|
72
72
|
results = capture(:stdout) { really_continue? }
|
|
73
73
|
results.should =~ /=> Do you really want to continue/;
|
|
74
74
|
results.should =~ /Default: Yes/;
|
|
75
75
|
end
|
|
76
76
|
next if answer.empty?
|
|
77
|
-
it "should really continue (despite default answer 'No') after answer '#{answer}'" do
|
|
77
|
+
it "#really_continue? - should really continue (despite default answer 'No') after answer '#{answer}'" do
|
|
78
78
|
STDIN.should_receive(:gets).and_return(answer)
|
|
79
79
|
results = capture(:stdout) { really_continue?('No') }
|
|
80
80
|
results.should =~ /=> Do you really want to continue/;
|
|
@@ -83,7 +83,7 @@ describe FalkorLib do
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
[ '', 'No', 'n', 'N', 'no' ].each do |answer|
|
|
86
|
-
it "should not continue (despite default answer 'No') and exit after answer '#{answer}'" do
|
|
86
|
+
it "#really_continue? - should not continue (despite default answer 'No') and exit after answer '#{answer}'" do
|
|
87
87
|
STDIN.should_receive(:gets).and_return(answer)
|
|
88
88
|
results = capture(:stdout) {
|
|
89
89
|
lambda{
|
|
@@ -94,7 +94,7 @@ describe FalkorLib do
|
|
|
94
94
|
results.should =~ /Default: No/;
|
|
95
95
|
end
|
|
96
96
|
next if answer.empty?
|
|
97
|
-
it "should not continue and exit after answer '#{answer}'" do
|
|
97
|
+
it "#really_continue? - should not continue and exit after answer '#{answer}'" do
|
|
98
98
|
STDIN.should_receive(:gets).and_return(answer)
|
|
99
99
|
results = capture(:stdout) {
|
|
100
100
|
lambda{
|
|
@@ -108,7 +108,7 @@ describe FalkorLib do
|
|
|
108
108
|
|
|
109
109
|
# Check the command? function
|
|
110
110
|
[ 'sqgfyueztruyjf', 'ruby' ].each do |command|
|
|
111
|
-
it "
|
|
111
|
+
it "#command? - check the command '#{command}'" do
|
|
112
112
|
command?(command).should ((command == 'ruby') ? be_true : be_false)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
@@ -117,14 +117,14 @@ describe FalkorLib do
|
|
|
117
117
|
#############################################
|
|
118
118
|
context "Test (common) YAML functions" do
|
|
119
119
|
|
|
120
|
-
it "
|
|
120
|
+
it "#load_config - load the correct hash from YAML" do
|
|
121
121
|
file_config = {:domain => "foo.com", :nested => { 'a1' => 2 }}
|
|
122
122
|
YAML.stub(:load_file).and_return(file_config)
|
|
123
123
|
loaded = load_config('toto')
|
|
124
124
|
loaded.should == file_config
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
it "should store the correct hash to YAML" do
|
|
127
|
+
it "#store_config - should store the correct hash to YAML" do
|
|
128
128
|
file_config = {:domain => "foo.com", :nested => { 'a1' => 2 }}
|
|
129
129
|
f = Tempfile.new('toto')
|
|
130
130
|
store_config(f.path, file_config)
|