gitnesse 0.12.6 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +6 -0
- data/Rakefile +6 -11
- data/bin/.keep +0 -0
- data/bin/gitnesse +2 -32
- data/config/gitnesse.rb.example +2 -4
- data/gitnesse.gemspec +22 -21
- data/lib/gitnesse/cli/helpers/config_helpers.rb +13 -0
- data/lib/gitnesse/cli/helpers/feature_helpers.rb +26 -0
- data/lib/gitnesse/cli/helpers/wiki_helpers.rb +53 -0
- data/lib/gitnesse/cli/task/help.rb +42 -0
- data/lib/gitnesse/cli/task/info.rb +29 -0
- data/lib/gitnesse/cli/task/pull.rb +26 -0
- data/lib/gitnesse/cli/task/push.rb +101 -0
- data/lib/gitnesse/cli/task/run.rb +85 -0
- data/lib/gitnesse/cli/task.rb +67 -0
- data/lib/gitnesse/cli.rb +55 -0
- data/lib/gitnesse/config.rb +68 -0
- data/lib/gitnesse/config_loader.rb +36 -0
- data/lib/gitnesse/dependency_checker.rb +86 -0
- data/lib/gitnesse/dir_manager.rb +37 -0
- data/lib/gitnesse/feature.rb +63 -0
- data/lib/gitnesse/feature_extractor.rb +29 -0
- data/lib/gitnesse/feature_transform.rb +30 -0
- data/lib/gitnesse/hooks/gitnesse.rb +5 -0
- data/lib/gitnesse/hooks.rb +30 -33
- data/lib/gitnesse/railtie.rb +3 -1
- data/lib/gitnesse/rake/tasks.rake +11 -0
- data/lib/gitnesse/tasks.rb +7 -4
- data/lib/gitnesse/version.rb +1 -1
- data/lib/gitnesse/wiki/page.rb +103 -0
- data/lib/gitnesse/wiki.rb +80 -143
- data/lib/gitnesse.rb +10 -102
- data/spec/lib/cli/task/help_spec.rb +34 -0
- data/spec/lib/cli/task/info_spec.rb +22 -0
- data/spec/lib/cli/task/pull_spec.rb +24 -0
- data/spec/lib/cli/task/push_spec.rb +24 -0
- data/spec/lib/cli_spec.rb +13 -0
- data/spec/lib/config_loader_spec.rb +46 -0
- data/spec/lib/config_spec.rb +61 -0
- data/spec/lib/dependency_checker_spec.rb +193 -0
- data/spec/lib/dir_manager_spec.rb +46 -0
- data/spec/lib/feature_extractor_spec.rb +30 -0
- data/spec/lib/feature_spec.rb +53 -0
- data/spec/lib/feature_transform_spec.rb +25 -0
- data/spec/lib/hooks_spec.rb +40 -0
- data/spec/lib/version_spec.rb +9 -0
- data/spec/lib/wiki/page_spec.rb +68 -0
- data/spec/lib/wiki_spec.rb +34 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/cli.rb +20 -0
- data/spec/support/example_config/gitnesse.rb +4 -0
- data/{test/test_helper.rb → spec/support/example_features/addition.feature} +0 -16
- data/spec/support/example_features/division.feature +10 -0
- data/spec/support/example_wiki_pages/developer_can_sync_features_to_code.md +29 -0
- data/spec/support_helper.rb +79 -0
- metadata +103 -109
- data/README.md +0 -85
- data/features/step_definitions/gitnesse_steps.rb +0 -54
- data/features/support/env.rb +0 -65
- data/features/sync_wiki_features_to_code.feature +0 -29
- data/lib/gitnesse/configuration.rb +0 -54
- data/lib/gitnesse/dependencies.rb +0 -39
- data/lib/gitnesse/features.rb +0 -38
- data/lib/gitnesse/git_config.rb +0 -39
- data/lib/gitnesse/support/hook.rb +0 -11
- data/lib/gitnesse/tasks.rake +0 -34
- data/test/lib/gitnesse/build_page_content_test.rb +0 -89
- data/test/lib/gitnesse/commit_info_test.rb +0 -16
- data/test/lib/gitnesse/configuration_defaults_test.rb +0 -11
- data/test/lib/gitnesse/configuration_to_hash_test.rb +0 -25
- data/test/lib/gitnesse/custom_branch_test.rb +0 -24
- data/test/lib/gitnesse/dependencies_check_test.rb +0 -73
- data/test/lib/gitnesse/extract_features_test.rb +0 -44
- data/test/lib/gitnesse/gather_test.rb +0 -30
- data/test/lib/gitnesse/load_feature_files_into_wiki_test.rb +0 -34
- data/test/lib/gitnesse/read_git_config_test.rb +0 -33
- data/test/lib/gitnesse/strip_results_test.rb +0 -52
- data/test/lib/gitnesse/version_test.rb +0 -7
- data/test/lib/gitnesse/wiki_append_results_test.rb +0 -50
- data/test/lib/gitnesse/write_file_test.rb +0 -18
- data/test/wiki_test_helper.rb +0 -11
data/lib/gitnesse/wiki.rb
CHANGED
@@ -1,182 +1,119 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + "/wiki/*.rb"].each { |f| require(f) }
|
2
|
+
|
3
|
+
require 'git'
|
4
|
+
|
1
5
|
module Gitnesse
|
2
6
|
class Wiki
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(dir = Dir.mktmpdir)
|
6
|
-
@wiki = Gollum::Wiki.new(dir)
|
7
|
-
@commit_info = Gitnesse.generate_commit_info
|
8
|
-
end
|
7
|
+
attr_reader :repo, :pages, :dir
|
9
8
|
|
10
|
-
# Public:
|
9
|
+
# Public: Clones/updates a wiki in the provided dir
|
11
10
|
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# url - cloneable URL for wiki repository
|
12
|
+
# dir - directory to clone git wiki into
|
13
|
+
# opts - hash of options:
|
14
|
+
# clone - whether or not to clone/update local copy of remote wiki
|
14
15
|
#
|
15
|
-
|
16
|
-
|
16
|
+
# Returns a Gitnesse::Wiki object
|
17
|
+
def initialize(url, dir, opts={clone: true})
|
18
|
+
@url = url
|
19
|
+
@dir = dir
|
20
|
+
@opts = opts
|
21
|
+
@config = Gitnesse::Config.instance
|
22
|
+
|
23
|
+
clone_or_update_repo unless !opts[:clone]
|
17
24
|
|
18
|
-
|
19
|
-
feature_name = File.basename(feature_file, ".feature")
|
20
|
-
feature_content = File.read(feature_file)
|
21
|
-
wiki_page = @wiki.page(feature_name)
|
22
|
-
wiki_page ||= @wiki.page("#{feature_name}.feature")
|
25
|
+
@repo ||= Git.init(dir)
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
create_wiki_page(feature_name, feature_content)
|
27
|
+
@pages = @repo.status.each_with_object([]) do |s, a|
|
28
|
+
if s.path =~ /\.feature\.md$/
|
29
|
+
a << Gitnesse::Wiki::Page.new("#{dir}/#{s.path}")
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
31
32
|
|
32
|
-
|
33
|
-
#
|
34
|
-
# Returns an array of Wiki pages
|
35
|
-
def pages
|
36
|
-
@wiki.pages
|
33
|
+
@pages
|
37
34
|
end
|
38
35
|
|
39
|
-
# Public:
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
if feature_definition
|
59
|
-
feature_name = feature_definition.split(":").last.strip.gsub(" ","-").downcase
|
60
|
-
features[feature_name] = feature_text
|
36
|
+
# Public: Removes pages previously placed by Gitnesse. This includes the
|
37
|
+
# feature listing pages.
|
38
|
+
#
|
39
|
+
# Returns nothing.
|
40
|
+
def remove_features
|
41
|
+
@repo.status.each do |file|
|
42
|
+
if file.path =~ /^features(\.md|\ >)/
|
43
|
+
begin
|
44
|
+
@repo.remove(file.path)
|
45
|
+
rescue Git::GitExecuteError => e
|
46
|
+
# Git spat something on git rm [file]. Likely the file doesn't
|
47
|
+
# exist, or was previously removed and hasn't been committed yet.
|
48
|
+
# It's likely fine. If not, we'll abort and show the end user the
|
49
|
+
# error Git sent to us.
|
50
|
+
unless e.message =~ /did not match any files/
|
51
|
+
puts " A Git error occured. The message it passed to us was:"
|
52
|
+
abort e.message
|
53
|
+
end
|
61
54
|
end
|
62
55
|
end
|
63
56
|
end
|
64
|
-
|
65
|
-
features
|
66
|
-
end
|
67
|
-
|
68
|
-
# Public: Builds wiki page content
|
69
|
-
#
|
70
|
-
# feature_content - Content to generate the page content from
|
71
|
-
# old_page_content - old page content to replace with new page content
|
72
|
-
#
|
73
|
-
# Returns a string containing the generated page content
|
74
|
-
def build_page_content(feature_content, old_page_content = nil)
|
75
|
-
content = "```gherkin\n#{feature_content}\n```"
|
76
|
-
return content if old_page_content.nil? || old_page_content.empty?
|
77
|
-
|
78
|
-
features = Wiki.extract_features(old_page_content)
|
79
|
-
|
80
|
-
_, old_feature_content = features.shift
|
81
|
-
old_page_content.sub(old_feature_content, feature_content)
|
82
57
|
end
|
83
58
|
|
84
|
-
# Public:
|
59
|
+
# Public: Commits staged wiki changes
|
85
60
|
#
|
86
61
|
# Returns nothing
|
87
|
-
def
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
if page
|
96
|
-
content = page.raw_data
|
97
|
-
content = strip_results(content)
|
98
|
-
@wiki.update_page(page, page.name, :markdown, content, @commit_info)
|
62
|
+
def commit
|
63
|
+
begin
|
64
|
+
@repo.commit("Update features with Gitnesse")
|
65
|
+
rescue Git::GitExecuteError => e
|
66
|
+
unless e.message =~ /nothing to commit/
|
67
|
+
puts " A Git error occured. The message it passed to us was:"
|
68
|
+
abort e.message
|
99
69
|
end
|
100
70
|
end
|
101
71
|
end
|
102
72
|
|
103
|
-
# Public:
|
104
|
-
#
|
105
|
-
# content - the string to remote old results from
|
73
|
+
# Public: Pushes new commits to remote wiki
|
106
74
|
#
|
107
|
-
# Returns
|
108
|
-
def
|
109
|
-
|
110
|
-
[ "FAILED", "PASSED", "PENDING", "UNDEFINED" ].each do |type|
|
111
|
-
content.gsub!(/\n*\!\[\]\(.*\) \`Last result was #{type}: .*\n*/, '')
|
112
|
-
end
|
113
|
-
end
|
114
|
-
content
|
75
|
+
# Returns nothing
|
76
|
+
def push
|
77
|
+
@repo.push
|
115
78
|
end
|
116
79
|
|
117
|
-
# Public:
|
80
|
+
# Public: Adds or updates wiki page
|
118
81
|
#
|
119
|
-
#
|
82
|
+
# filename - filename for wiki page
|
83
|
+
# content - content for page
|
120
84
|
#
|
121
|
-
# Returns a
|
122
|
-
def
|
123
|
-
|
124
|
-
@commit_info[:message] = Gitnesse.configuration.info
|
125
|
-
|
126
|
-
self.pages.each do |page|
|
127
|
-
if page.name == filename || page.name == "#{filename}.feature"
|
128
|
-
if page.text_data.include? scenario.name
|
129
|
-
content = page.raw_data
|
85
|
+
# Returns a Wiki::Page
|
86
|
+
def add_page(filename, content)
|
87
|
+
full_filename = "#{@dir}/#{filename}"
|
130
88
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
else image = "![](https://s3.amazonaws.com/gitnesse/github/undefined.png)"
|
137
|
-
end
|
138
|
-
|
139
|
-
string = "\n#{image} \`Last result was #{scenario.status.to_s.upcase}: #{scenario.name} (#{Time.now.to_s} - #{Gitnesse.configuration.info})\`\n"
|
140
|
-
content.gsub(string, '')
|
141
|
-
content << string
|
142
|
-
@wiki.update_page(page, page.name, :markdown, content, @commit_info)
|
143
|
-
return string
|
144
|
-
end
|
145
|
-
end
|
89
|
+
if @pages.detect { |f| f.wiki_path == full_filename }
|
90
|
+
page = @pages.find { |f| f.wiki_path == full_filename }
|
91
|
+
else
|
92
|
+
page = Gitnesse::Wiki::Page.new(full_filename)
|
93
|
+
@pages << page
|
146
94
|
end
|
147
|
-
end
|
148
|
-
|
149
|
-
private
|
150
95
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
# content - the content the page should have
|
155
|
-
#
|
156
|
-
# Returns the newly created wiki page
|
157
|
-
def create_wiki_page(name, content)
|
158
|
-
new_page_content = build_page_content(content)
|
159
|
-
@wiki.write_page(name, :markdown, new_page_content, @commit_info)
|
160
|
-
puts " \e[32mCreated page \e[0m#{name}."
|
96
|
+
page.write(content)
|
97
|
+
@repo.add(filename)
|
98
|
+
page
|
161
99
|
end
|
162
100
|
|
163
|
-
|
164
|
-
#
|
165
|
-
# wiki_page - the page to update
|
166
|
-
# page_name - the name of the page
|
167
|
-
# feature_content - the feature content to compare/update
|
101
|
+
private
|
102
|
+
# Private: Clones or Updates the local copy of the remote wiki
|
168
103
|
#
|
169
|
-
# Returns
|
170
|
-
def
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
puts " \e[32mPage \e[0m#{page_name} \e[32mdidn't change\e[0m."
|
104
|
+
# Returns nothing
|
105
|
+
def clone_or_update_repo
|
106
|
+
if File.directory?(@dir + "/.git")
|
107
|
+
puts " Updating local copy of remote wiki."
|
108
|
+
@repo = Git.open(@dir)
|
109
|
+
@repo.pull('origin', @config.branch)
|
176
110
|
else
|
177
|
-
|
178
|
-
|
111
|
+
puts " Creating local copy of remote wiki."
|
112
|
+
Dir.mkdir @dir unless File.directory?(@dir)
|
113
|
+
@repo = Git.clone @url, @dir
|
179
114
|
end
|
115
|
+
|
116
|
+
@repo.checkout(@config.branch)
|
180
117
|
end
|
181
118
|
end
|
182
119
|
end
|
data/lib/gitnesse.rb
CHANGED
@@ -1,107 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'gitnesse/
|
7
|
-
require 'gitnesse/
|
8
|
-
require 'gitnesse/
|
9
|
-
require 'gitnesse/features'
|
10
|
-
require 'gitnesse/hooks'
|
1
|
+
require 'gitnesse/version'
|
2
|
+
require 'gitnesse/config'
|
3
|
+
require 'gitnesse/config_loader'
|
4
|
+
require 'gitnesse/dependency_checker'
|
5
|
+
require 'gitnesse/feature'
|
6
|
+
require 'gitnesse/feature_extractor'
|
7
|
+
require 'gitnesse/feature_transform'
|
8
|
+
require 'gitnesse/dir_manager'
|
11
9
|
require 'gitnesse/wiki'
|
10
|
+
require 'gitnesse/hooks'
|
11
|
+
|
12
12
|
require 'gitnesse/railtie' if defined?(Rails)
|
13
13
|
|
14
|
-
# core module
|
15
14
|
module Gitnesse
|
16
|
-
class << self
|
17
|
-
attr_accessor :configuration
|
18
|
-
attr_accessor :commit_info
|
19
|
-
end
|
20
|
-
|
21
|
-
self.configuration ||= Configuration.new
|
22
|
-
|
23
|
-
extend self
|
24
|
-
|
25
|
-
def self.configure
|
26
|
-
yield(configuration)
|
27
|
-
end
|
28
|
-
|
29
|
-
# -- all methods after this are module functions --
|
30
|
-
module_function
|
31
|
-
|
32
|
-
def run
|
33
|
-
if pull
|
34
|
-
Hooks.create
|
35
|
-
puts "\n Now going to run Cucumber."
|
36
|
-
exec("cucumber #{Gitnesse.configuration.target_directory}/*.feature")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def push_results
|
41
|
-
if push
|
42
|
-
Hooks.create
|
43
|
-
puts "\n Now going to run Cucumber."
|
44
|
-
exec("cucumber #{Gitnesse.configuration.target_directory}/*.feature")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# pull features from git wiki, and sync up with features dir
|
49
|
-
def pull
|
50
|
-
Dependencies.check
|
51
|
-
|
52
|
-
relative_path = Pathname.new(Gitnesse.configuration.target_directory).relative_path_from(Pathname.new(Dir.pwd))
|
53
|
-
|
54
|
-
puts " Pulling features into ./#{relative_path} from #{Gitnesse.configuration.repository_url}."
|
55
|
-
Dir.mktmpdir do |tmp_dir|
|
56
|
-
if clone_feature_repo(tmp_dir)
|
57
|
-
FileUtils.mkdir(Gitnesse.configuration.target_directory) unless File.exists?(Gitnesse.configuration.target_directory)
|
58
|
-
|
59
|
-
wiki_pages = Wiki.new(tmp_dir).pages
|
60
|
-
wiki_pages.each do |page|
|
61
|
-
name = page.name.gsub('.feature', '')
|
62
|
-
filename = "#{Gitnesse.configuration.target_directory}/#{name}.feature"
|
63
|
-
features = Wiki.extract_features(page)
|
64
|
-
Features.write_file(filename, features) unless features.empty?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
puts " \e[32mDone pulling features.\e[0m"
|
69
|
-
true
|
70
|
-
end
|
71
|
-
|
72
|
-
# push features back up to git wiki from features directory
|
73
|
-
def push
|
74
|
-
Dependencies.check
|
75
|
-
generate_commit_info
|
76
|
-
|
77
|
-
relative_path = Pathname.new(Gitnesse.configuration.target_directory).relative_path_from(Pathname.new(Dir.pwd))
|
78
|
-
|
79
|
-
puts " Pushing features from ./#{relative_path} to #{Gitnesse.configuration.repository_url}."
|
80
|
-
Dir.mktmpdir do |tmp_dir|
|
81
|
-
if clone_feature_repo(tmp_dir)
|
82
|
-
feature_files = Dir.glob("#{Gitnesse.configuration.target_directory}/*.feature")
|
83
|
-
Wiki.new(tmp_dir).load_feature_files(feature_files)
|
84
|
-
|
85
|
-
# push the changes to the remote git
|
86
|
-
Dir.chdir(tmp_dir) do
|
87
|
-
`git push origin master &> /dev/null`
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
puts " \e[32mDone pushing features.\e[0m"
|
92
|
-
true
|
93
|
-
end
|
94
|
-
|
95
|
-
def clone_feature_repo(dir)
|
96
|
-
output = `git clone #{Gitnesse.configuration.repository_url} #{dir} &> /dev/null`
|
97
|
-
$?.success?
|
98
|
-
end
|
99
|
-
|
100
|
-
def generate_commit_info
|
101
|
-
self.commit_info ||= begin
|
102
|
-
user_name = GitConfig.read("user.name")
|
103
|
-
email = GitConfig.read("user.email")
|
104
|
-
{ :name => user_name, :email => email, :message => "Update features with Gitnesse" }
|
105
|
-
end
|
106
|
-
end
|
107
15
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gitnesse/cli'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Cli, type: :cli do
|
6
|
+
let(:overview) do
|
7
|
+
<<-EOS
|
8
|
+
USAGE: gitnesse <task> [<args>]
|
9
|
+
|
10
|
+
The gitnesse tasks are:
|
11
|
+
info Prints current Gitnesse configuration
|
12
|
+
pull Pulls features from remote git-based wiki
|
13
|
+
push Pushes local features to remote git-based wiki
|
14
|
+
run Pulls changes from remote git-based wiki, and runs Cucumber.
|
15
|
+
|
16
|
+
See 'gitnesse help <task>' for more information on a specific task.
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'displays help overview when called with no args' do
|
21
|
+
expect(gitnesse("")).to eq overview
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'displays help overview when help task is called with no arguments' do
|
25
|
+
expect(gitnesse("help")).to eq overview
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when no help text for a given topic is available" do
|
29
|
+
it "prints out a message" do
|
30
|
+
expect(gitnesse("help missing")).to eq "No help for task 'missing'\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gitnesse/cli'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Cli, type: :cli do
|
6
|
+
let(:result) do
|
7
|
+
<<-EOS
|
8
|
+
Current Gitnesse Configuration:
|
9
|
+
repository_url - [not set]
|
10
|
+
features_dir - features
|
11
|
+
branch - master
|
12
|
+
annotate_results - [not set]
|
13
|
+
identifier - [not set]
|
14
|
+
EOS
|
15
|
+
end
|
16
|
+
|
17
|
+
it "prints the current configuration" do
|
18
|
+
expect(Gitnesse::ConfigLoader).to receive(:find_and_load)
|
19
|
+
expect(gitnesse("info")).to eq result
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gitnesse/cli'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Cli, type: :cli do
|
6
|
+
let(:help) do
|
7
|
+
<<-EOS
|
8
|
+
USAGE: gitnesse pull
|
9
|
+
|
10
|
+
Pulls features from remote git-based wiki
|
11
|
+
|
12
|
+
Pulls the remote wiki, finds the feature files it contains, and updates the
|
13
|
+
relevant local features, creating new ones if necessary.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
gitnesse pull # will pull features from remote wiki
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has help info" do
|
21
|
+
expect(gitnesse("help pull")).to eq help
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gitnesse/cli'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Cli, type: :cli do
|
6
|
+
let(:help) do
|
7
|
+
<<-EOS
|
8
|
+
USAGE: gitnesse push
|
9
|
+
|
10
|
+
Pushes local features to remote git-based wiki
|
11
|
+
|
12
|
+
Pushes the local features files to the remote git-based wiki, creating/updating
|
13
|
+
wiki pages as necessary.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
gitnesse push # will push local features to remote wiki
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has help info" do
|
21
|
+
expect(gitnesse("help push")).to eq help
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gitnesse/cli'
|
3
|
+
|
4
|
+
module Gitnesse
|
5
|
+
describe Cli, type: :cli do
|
6
|
+
describe "-v, --version" do
|
7
|
+
it "outputs the gem name and version" do
|
8
|
+
expect(gitnesse("--version")).to eq "gitnesse #{Gitnesse::VERSION}\n"
|
9
|
+
expect(gitnesse("-v")).to eq "gitnesse #{Gitnesse::VERSION}\n"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe ConfigLoader do
|
5
|
+
let(:config) { Config.instance }
|
6
|
+
|
7
|
+
describe "#find_and_load" do
|
8
|
+
context "when no config file exists" do
|
9
|
+
before do
|
10
|
+
Dir.should_receive(:glob).and_return([])
|
11
|
+
ConfigLoader.should_receive(:raise_error).with("Can't find a gitnesse.rb file with Gitnesse configuration.")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raises an error" do
|
15
|
+
ConfigLoader.find_and_load
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when one config file exists" do
|
20
|
+
before do
|
21
|
+
files = [Support.example_config_file_path]
|
22
|
+
Dir.should_receive(:glob).and_return(files)
|
23
|
+
ConfigLoader.should_receive(:load).and_return(true)
|
24
|
+
ConfigLoader.should_receive(:reject_irrelevant_files).and_return(files)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "loads the config file" do
|
28
|
+
ConfigLoader.find_and_load
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when multiple config files exist" do
|
33
|
+
before do
|
34
|
+
files = [Support.example_config_file_path, Support.example_config_file_path]
|
35
|
+
Dir.should_receive(:glob).and_return(files)
|
36
|
+
ConfigLoader.should_receive(:reject_irrelevant_files).and_return(files)
|
37
|
+
ConfigLoader.should_receive(:raise_error).with("Multiple configuration files found:", files)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "raises an error" do
|
41
|
+
ConfigLoader.find_and_load
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gitnesse
|
4
|
+
describe Config do
|
5
|
+
let(:config) { Config.instance }
|
6
|
+
let(:default_config_hash) do
|
7
|
+
{
|
8
|
+
annotate_results: false,
|
9
|
+
branch: 'master',
|
10
|
+
identifier: nil,
|
11
|
+
features_dir: 'features',
|
12
|
+
repository_url: nil
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is a singleton" do
|
17
|
+
expect(Config.instance).to eq config
|
18
|
+
expect{Config.new}.to raise_error NoMethodError
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has default settings" do
|
22
|
+
expect(config.branch).to eq 'master'
|
23
|
+
expect(config.annotate_results).to be_false
|
24
|
+
expect(config.features_dir).to eq 'features'
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".to_h" do
|
28
|
+
it "returns a hash of config data" do
|
29
|
+
expect(config.to_h).to eq default_config_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".setup" do
|
34
|
+
context "when a block is not passed" do
|
35
|
+
it "returns the configuration hash" do
|
36
|
+
expect(Config.config).to eq default_config_hash
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when a block is passed" do
|
41
|
+
before do
|
42
|
+
Config.config do |config|
|
43
|
+
config.annotate_results = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:expected_results) do
|
48
|
+
default_config_hash.tap { |h| h[:annotate_results] = true }
|
49
|
+
end
|
50
|
+
|
51
|
+
it "allows for config values to be set" do
|
52
|
+
expect(config.annotate_results).to be_true
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns the configuration hash" do
|
56
|
+
expect(Config.config).to eq expected_results
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|