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/git_config.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Gitnesse
|
2
|
-
class GitConfig
|
3
|
-
class NoValueSetError < StandardError ; end
|
4
|
-
|
5
|
-
# Public: Reads a value from the system's git config.
|
6
|
-
#
|
7
|
-
# key - the value to look up from the git config
|
8
|
-
#
|
9
|
-
# Returns a string containing the git config value or GitConfigNotFoundError
|
10
|
-
def self.read(key)
|
11
|
-
value = get_from_git_config key
|
12
|
-
|
13
|
-
if value.empty? || value == ''
|
14
|
-
raise NoValueSetError, "Cannot read git config value for #{key}"
|
15
|
-
end
|
16
|
-
|
17
|
-
value
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
# Private: Tries to fetch a value using git config --get
|
23
|
-
#
|
24
|
-
# key - the value to look up from the git config
|
25
|
-
#
|
26
|
-
# Returns a string containing the value supplied by git
|
27
|
-
def self.get_from_git_config(key)
|
28
|
-
value = ''
|
29
|
-
|
30
|
-
value = `git config --get #{key}`
|
31
|
-
|
32
|
-
if value.empty? || value == ''
|
33
|
-
value = `git config --get --global #{key}`
|
34
|
-
end
|
35
|
-
|
36
|
-
value.strip
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/gitnesse/tasks.rake
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
namespace :gitnesse do
|
2
|
-
task :environment do
|
3
|
-
end
|
4
|
-
|
5
|
-
desc "Pull features from remote repository and run cucumber."
|
6
|
-
task :run => :environment do
|
7
|
-
Gitnesse::Configuration.load_using_search
|
8
|
-
Gitnesse.run
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "Pull features from remote git wiki repository."
|
12
|
-
task :pull => :environment do
|
13
|
-
Gitnesse::Configuration.load_using_search
|
14
|
-
Gitnesse.pull
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Push features to remote git wiki repository."
|
18
|
-
task :push => :environment do
|
19
|
-
Gitnesse::Configuration.load_using_search
|
20
|
-
Gitnesse.push
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "Push features to remote git wiki repository, run cucumber, and push results to wiki"
|
24
|
-
task :push_results => :environment do
|
25
|
-
Gitnesse::Configuration.load_using_search
|
26
|
-
Gitnesse.push_results
|
27
|
-
end
|
28
|
-
|
29
|
-
desc "Dump the current config info to the console."
|
30
|
-
task :info => :environment do
|
31
|
-
Gitnesse::Configuration.load_using_search
|
32
|
-
puts Gitnesse.configuration.to_yaml
|
33
|
-
end
|
34
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Wiki do
|
4
|
-
let(:dir) { Dir.mktmpdir }
|
5
|
-
let(:wiki) { Gitnesse::Wiki.new(dir) }
|
6
|
-
|
7
|
-
before do
|
8
|
-
Dir.chdir(dir) do
|
9
|
-
`git init`
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".build_page_content" do
|
14
|
-
let(:wiki_page_content) do
|
15
|
-
<<-EOS
|
16
|
-
# Addition is Awesome
|
17
|
-
|
18
|
-
```gherkin
|
19
|
-
Feature: Addition
|
20
|
-
In order to avoid silly mistakes
|
21
|
-
I want to be told the sum of two numbers
|
22
|
-
|
23
|
-
Scenario: Add two single digit numbers
|
24
|
-
Given I have entered 7 into the calculator
|
25
|
-
And I have entered 5 into the calculator
|
26
|
-
When I add
|
27
|
-
Then the result should be 12 on the screen
|
28
|
-
```
|
29
|
-
EOS
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:new_feature_content) do
|
33
|
-
<<-EOS
|
34
|
-
Feature: Addition
|
35
|
-
In order to avoid silly mistakes
|
36
|
-
I want to be told the sum of two numbers
|
37
|
-
|
38
|
-
Scenario: Add two double digit numbers
|
39
|
-
Given I have entered 50 into the calculator
|
40
|
-
And I have entered 70 into the calculator
|
41
|
-
When I add
|
42
|
-
Then the result should be 120 on the screen
|
43
|
-
EOS
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "without existing wiki page content" do
|
47
|
-
let(:method) { lambda { wiki.build_page_content(new_feature_content) } }
|
48
|
-
let(:expected_result) do
|
49
|
-
"```gherkin
|
50
|
-
Feature: Addition
|
51
|
-
In order to avoid silly mistakes
|
52
|
-
I want to be told the sum of two numbers
|
53
|
-
|
54
|
-
Scenario: Add two double digit numbers
|
55
|
-
Given I have entered 50 into the calculator
|
56
|
-
And I have entered 70 into the calculator
|
57
|
-
When I add
|
58
|
-
Then the result should be 120 on the screen
|
59
|
-
|
60
|
-
```"
|
61
|
-
end
|
62
|
-
|
63
|
-
it { method.call.must_equal expected_result }
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "with existing wiki page content" do
|
67
|
-
let(:method) { lambda { wiki.build_page_content(new_feature_content, wiki_page_content) } }
|
68
|
-
let(:expected_result) do
|
69
|
-
<<-EOS
|
70
|
-
# Addition is Awesome
|
71
|
-
|
72
|
-
```gherkin
|
73
|
-
Feature: Addition
|
74
|
-
In order to avoid silly mistakes
|
75
|
-
I want to be told the sum of two numbers
|
76
|
-
|
77
|
-
Scenario: Add two double digit numbers
|
78
|
-
Given I have entered 50 into the calculator
|
79
|
-
And I have entered 70 into the calculator
|
80
|
-
When I add
|
81
|
-
Then the result should be 120 on the screen
|
82
|
-
```
|
83
|
-
EOS
|
84
|
-
end
|
85
|
-
|
86
|
-
it { method.call.must_equal expected_result }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse do
|
4
|
-
describe "#generate_commit_info" do
|
5
|
-
let(:method) { lambda { Gitnesse.generate_commit_info } }
|
6
|
-
|
7
|
-
before do
|
8
|
-
Gitnesse::GitConfig.expects(:read).with("user.name").returns("Bob Martin")
|
9
|
-
Gitnesse::GitConfig.expects(:read).with("user.email").returns("bob@bobmartin.com")
|
10
|
-
end
|
11
|
-
|
12
|
-
it { method.call.must_equal({ :name => "Bob Martin",
|
13
|
-
:email => "bob@bobmartin.com",
|
14
|
-
:message => "Update features with Gitnesse" }) }
|
15
|
-
end
|
16
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Configuration do
|
4
|
-
describe "defaults" do
|
5
|
-
subject { Gitnesse::Configuration.new }
|
6
|
-
it { subject.branch.must_equal "master" }
|
7
|
-
it { subject.annotate_results.must_equal false }
|
8
|
-
it { subject.info.must_be_nil }
|
9
|
-
it { subject.target_directory.must_equal File.join(Dir.pwd, "features") }
|
10
|
-
end
|
11
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Configuration do
|
4
|
-
describe ".to_hash" do
|
5
|
-
let(:method) { lambda { Gitnesse.configuration.to_hash } }
|
6
|
-
|
7
|
-
before do
|
8
|
-
Gitnesse.configure do |config|
|
9
|
-
config.repository_url = "git://github.com/hybridgroup/gitnesse-demo.wiki.git"
|
10
|
-
config.branch = "wiki"
|
11
|
-
config.target_directory = "feature_files"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it { method.call.must_be_instance_of Hash }
|
16
|
-
|
17
|
-
it "contains the configuration data" do
|
18
|
-
hash = method.call
|
19
|
-
|
20
|
-
hash["repository_url"].must_equal "git://github.com/hybridgroup/gitnesse-demo.wiki.git"
|
21
|
-
hash["branch"].must_equal "wiki"
|
22
|
-
hash["target_directory"].must_equal "feature_files"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Configuration do
|
4
|
-
describe "#branch" do
|
5
|
-
describe "defaults to 'master'" do
|
6
|
-
it { Gitnesse.configuration.branch.must_equal "master" }
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "when changed" do
|
10
|
-
before { Gitnesse.configuration.branch = "wiki" }
|
11
|
-
it { Gitnesse.configuration.branch.must_equal "wiki" }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "when changed through #configure" do
|
15
|
-
before do
|
16
|
-
Gitnesse.configure do |config|
|
17
|
-
config.branch = "wiki"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it { Gitnesse.configuration.branch.must_equal "wiki" }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Dependencies do
|
4
|
-
describe "#check" do
|
5
|
-
before do
|
6
|
-
Gitnesse::Dependencies.expects(:check_git)
|
7
|
-
Gitnesse::Dependencies.expects(:check_cucumber)
|
8
|
-
Gitnesse::Dependencies.expects(:check_repository_url)
|
9
|
-
Gitnesse::Dependencies.expects(:check_annotation_info)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "calls the other check functions" do
|
13
|
-
Gitnesse::Dependencies.check
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#check_repository_url" do
|
18
|
-
let(:method) { lambda { Gitnesse::Dependencies.check_repository_url } }
|
19
|
-
|
20
|
-
describe "when repository was defined" do
|
21
|
-
before { Gitnesse.configuration.repository_url = "git://github.com/hybridgroup/gitnesse-demo.wiki" }
|
22
|
-
it { method.call.must_be_nil }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "when repository was not defined" do
|
26
|
-
before { Gitnesse.configuration.repository_url = nil }
|
27
|
-
it { method.must_raise(Gitnesse::Dependencies::NoRepositoryURLError) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#check_git" do
|
32
|
-
let(:method) { lambda { Gitnesse::Dependencies.check_git } }
|
33
|
-
|
34
|
-
describe "when git is not installed" do
|
35
|
-
before { Kernel.expects(:system).with("git --version &> /dev/null").returns(false) }
|
36
|
-
it { method.must_raise(Gitnesse::Dependencies::NoGitError) }
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "when git is installed" do
|
40
|
-
before { Kernel.expects(:system).with("git --version &> /dev/null").returns(true) }
|
41
|
-
it { method.call.must_be_nil }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#check_cucumber" do
|
46
|
-
let(:method) { lambda { Gitnesse::Dependencies.check_cucumber } }
|
47
|
-
|
48
|
-
describe "when cucumber is not installed" do
|
49
|
-
before { Kernel.expects(:system).with("cucumber --version &> /dev/null").returns(false) }
|
50
|
-
it { method.must_raise(Gitnesse::Dependencies::NoCucumberError) }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "when cucumber is installed" do
|
54
|
-
before { Kernel.expects(:system).with("cucumber --version &> /dev/null").returns(true) }
|
55
|
-
it { method.call.must_be_nil }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#check_annotation_info" do
|
60
|
-
let(:method) { lambda { Gitnesse::Dependencies.check_annotation_info } }
|
61
|
-
before { Gitnesse.configuration.annotate_results = true }
|
62
|
-
|
63
|
-
describe "when info is defined" do
|
64
|
-
before { Gitnesse.configuration.info = "Bob Martin's workstation" }
|
65
|
-
it { method.call.must_be_nil }
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "when info is not defined" do
|
69
|
-
before { Gitnesse.configuration.info = nil }
|
70
|
-
it { method.must_raise Gitnesse::Dependencies::NoAnnotationInfoError }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Wiki do
|
4
|
-
describe ".extract_features" do
|
5
|
-
let(:data) do
|
6
|
-
<<-EOS
|
7
|
-
# Addition is Awesome
|
8
|
-
|
9
|
-
```gherkin
|
10
|
-
Feature: Addition
|
11
|
-
In order to avoid silly mistakes
|
12
|
-
I want to be told the sum of two numbers
|
13
|
-
|
14
|
-
Scenario: Add two single digit numbers
|
15
|
-
Given I have entered 7 into the calculator
|
16
|
-
And I have entered 5 into the calculator
|
17
|
-
When I add
|
18
|
-
Then the result should be 12 on the screen
|
19
|
-
```
|
20
|
-
EOS
|
21
|
-
end
|
22
|
-
|
23
|
-
let(:expected_result) do
|
24
|
-
{ "addition" => "Feature: Addition
|
25
|
-
In order to avoid silly mistakes
|
26
|
-
I want to be told the sum of two numbers
|
27
|
-
|
28
|
-
Scenario: Add two single digit numbers
|
29
|
-
Given I have entered 7 into the calculator
|
30
|
-
And I have entered 5 into the calculator
|
31
|
-
When I add
|
32
|
-
Then the result should be 12 on the screen
|
33
|
-
"}
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:method) { lambda { Gitnesse::Wiki.extract_features(data) } }
|
37
|
-
|
38
|
-
it { method.call.must_be_instance_of Hash }
|
39
|
-
|
40
|
-
it "extracts feature data" do
|
41
|
-
method.call.must_equal expected_result
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Features do
|
4
|
-
describe ".gather" do
|
5
|
-
|
6
|
-
describe "when several features" do
|
7
|
-
let(:page_features) { {"test-feature" => "feature content", "another-test-feature" => "another feature content"} }
|
8
|
-
|
9
|
-
it { Gitnesse::Features.gather(page_features).must_equal "feature content" }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "when one single feature" do
|
13
|
-
let(:page_features) { {"test-feature" => "feature content"} }
|
14
|
-
|
15
|
-
it { Gitnesse::Features.gather(page_features).must_equal "feature content" }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "when no features" do
|
19
|
-
let(:page_features) { Hash.new }
|
20
|
-
|
21
|
-
it { Gitnesse::Features.gather(page_features).must_equal "" }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "when nil" do
|
25
|
-
let(:page_features) { nil }
|
26
|
-
|
27
|
-
it { Gitnesse::Features.gather(page_features).must_equal "" }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse do
|
4
|
-
describe "#load_feature_files_into_wiki" do
|
5
|
-
let(:wiki) { mock() }
|
6
|
-
let(:wiki_page) { mock() }
|
7
|
-
let(:tmpdir) { Dir.mktmpdir }
|
8
|
-
let(:feature_file_dir) { Dir.mktmpdir }
|
9
|
-
|
10
|
-
before do
|
11
|
-
# create test feature
|
12
|
-
File.open(File.join(feature_file_dir, "test.feature"), "w") do |file|
|
13
|
-
feature = <<-EOF
|
14
|
-
Feature: Addition
|
15
|
-
In order to avoid silly mistakes
|
16
|
-
As a math idiot
|
17
|
-
I want to be told the sum of two numbers
|
18
|
-
|
19
|
-
Scenario: Add two numbers
|
20
|
-
Given I have entered 50 into the calculator
|
21
|
-
And I have entered 70 into the calculator
|
22
|
-
When I press add
|
23
|
-
Then the result should be 120 on the screen
|
24
|
-
EOF
|
25
|
-
|
26
|
-
file.write(feature)
|
27
|
-
end
|
28
|
-
|
29
|
-
Dir.expects(:glob).with("#{Gitnesse.configuration.target_directory}/*.feature").returns(:feature_file_dir)
|
30
|
-
wiki.expects(:page).with("testing").returns(wiki_page)
|
31
|
-
Gitnesse.expects(:update_wiki_page).with(wiki_page, "testing", "blarg")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::GitConfig do
|
4
|
-
describe "#read" do
|
5
|
-
let(:method) { lambda { Gitnesse::GitConfig.read("user.email") } }
|
6
|
-
|
7
|
-
describe "when a gitconfig value is not set" do
|
8
|
-
before do
|
9
|
-
Gitnesse::GitConfig.stubs(:`).with("git config --get user.email").returns("")
|
10
|
-
Gitnesse::GitConfig.stubs(:`).with("git config --get --global user.email").returns("")
|
11
|
-
end
|
12
|
-
|
13
|
-
it { method.must_raise(Gitnesse::GitConfig::NoValueSetError) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "when a gitconfig value is set" do
|
17
|
-
before do
|
18
|
-
Gitnesse::GitConfig.stubs(:`).with("git config --get user.email").returns("bob@bobsmith.com\n")
|
19
|
-
end
|
20
|
-
|
21
|
-
it { method.call.must_equal "bob@bobsmith.com" }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "when a gitconfig value is set globally" do
|
25
|
-
before do
|
26
|
-
Gitnesse::GitConfig.stubs(:`).with('git config --get user.email').returns('')
|
27
|
-
Gitnesse::GitConfig.stubs(:`).with('git config --get --global user.email').returns("bob@bobsmith.com\n")
|
28
|
-
end
|
29
|
-
|
30
|
-
it { method.call.must_equal "bob@bobsmith.com" }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require_relative "../../test_helper"
|
2
|
-
|
3
|
-
describe Gitnesse::Wiki do
|
4
|
-
describe "#strip_results" do
|
5
|
-
let(:wiki_page) do
|
6
|
-
<<-EOS
|
7
|
-
```gherkin
|
8
|
-
Feature: Division
|
9
|
-
In order to avoid silly mistakes
|
10
|
-
As a math idiot
|
11
|
-
I want to be told the quotient of 2 numbers
|
12
|
-
|
13
|
-
Scenario: Divide two numbers
|
14
|
-
Given I have entered 6 into the calculator
|
15
|
-
And I have entered 2 into the calculator
|
16
|
-
When I divide
|
17
|
-
Then the result should be 3
|
18
|
-
```
|
19
|
-
![](http://path-to-image) `Last result was UNDEFINED: Divide two numbers`
|
20
|
-
|
21
|
-
![](http://path-to-image) `Last result was PENDING: Divide two numbers`
|
22
|
-
|
23
|
-
![](http://path-to-image) `Last result was FAILED: Divide two numbers`
|
24
|
-
|
25
|
-
![](http://path-to-image) `Last result was PASSED: Divide two numbers`
|
26
|
-
EOS
|
27
|
-
end
|
28
|
-
|
29
|
-
let(:expected_result) do
|
30
|
-
"```gherkin
|
31
|
-
Feature: Division
|
32
|
-
In order to avoid silly mistakes
|
33
|
-
As a math idiot
|
34
|
-
I want to be told the quotient of 2 numbers
|
35
|
-
|
36
|
-
Scenario: Divide two numbers
|
37
|
-
Given I have entered 6 into the calculator
|
38
|
-
And I have entered 2 into the calculator
|
39
|
-
When I divide
|
40
|
-
Then the result should be 3
|
41
|
-
```"
|
42
|
-
end
|
43
|
-
|
44
|
-
before do
|
45
|
-
Gollum::Wiki.expects(:new).returns(mock)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "strips old results from the page" do
|
49
|
-
Gitnesse::Wiki.new(Dir.mktmpdir).strip_results(wiki_page).must_equal expected_result
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Wiki do
|
4
|
-
describe "#append_results" do
|
5
|
-
let(:dir) { Dir.mktmpdir }
|
6
|
-
let(:wiki) { mock }
|
7
|
-
let(:feature_file) do
|
8
|
-
<<-EOS
|
9
|
-
```gherkin
|
10
|
-
Feature: Addition
|
11
|
-
In order to avoid silly mistakes
|
12
|
-
I want to be told the sum of two numbers
|
13
|
-
|
14
|
-
Scenario: Add two single digit numbers
|
15
|
-
Given I have entered 7 into the calculator
|
16
|
-
And I have entered 5 into the calculator
|
17
|
-
When I add
|
18
|
-
Then the result should be 12 on the screen
|
19
|
-
```
|
20
|
-
EOS
|
21
|
-
end
|
22
|
-
let(:pages) do
|
23
|
-
[
|
24
|
-
stub(
|
25
|
-
:name => "addition",
|
26
|
-
:text_data => feature_file,
|
27
|
-
:raw_data => feature_file
|
28
|
-
)
|
29
|
-
]
|
30
|
-
end
|
31
|
-
let(:cucumber_scenario) do
|
32
|
-
stub(
|
33
|
-
:name => "Add two single digit numbers",
|
34
|
-
:status => :passed,
|
35
|
-
:feature => stub(:file => "addition.feature")
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
let(:method) { lambda { Gitnesse::Wiki.new(dir).append_results(cucumber_scenario) } }
|
40
|
-
|
41
|
-
before do
|
42
|
-
Gollum::Wiki.expects(:new).returns(wiki)
|
43
|
-
wiki.expects(:pages).returns(pages)
|
44
|
-
wiki.expects(:update_page).returns(true)
|
45
|
-
File.expects(:basename).returns("addition")
|
46
|
-
end
|
47
|
-
|
48
|
-
it { puts method.call.must_include "Last result was PASSED: Add two single digit numbers" }
|
49
|
-
end
|
50
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require_relative '../../test_helper'
|
2
|
-
|
3
|
-
describe Gitnesse::Features do
|
4
|
-
describe ".write_file" do
|
5
|
-
let(:file) { StringIO.new }
|
6
|
-
let(:file_path) { "#{Gitnesse.configuration.target_directory}/test.feature" }
|
7
|
-
|
8
|
-
before do
|
9
|
-
File.expects(:open).with(file_path, "w").yields(file)
|
10
|
-
Gitnesse::Features.expects(:gather).with({ "test-feature" => "feature content" }).returns("feature content")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "writes to the file" do
|
14
|
-
Gitnesse::Features.write_file(file_path, { "test-feature" => "feature content" })
|
15
|
-
file.string.must_equal "feature content"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|