gitnesse 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f0e8d676922e813e166be577a0a5866452c9029
4
- data.tar.gz: 40ca9a4ccfa71c4308a90d1f4d1f9c1dd0a4339e
3
+ metadata.gz: 5be94d888608f5e3f317832d868b72a51c028c85
4
+ data.tar.gz: c7539589e565d2331879b2b16b3810159fffe797
5
5
  SHA512:
6
- metadata.gz: af6deb49255c922a75add6ce18912ba23e491b0cc7e24ee2bd4d852d1c4971b092ea08bf0e99c51d5f0c5f105e06055354137d4c0d6833bf313cc1d35d289758
7
- data.tar.gz: ba274b9548f2f867dd64890e67e298d8b45d05451e227e49bddb0b1ca7a17861eb04aa236b210de3e7c17d23aec0f49803a65a4ada266fe52b9f417640c11ee9
6
+ metadata.gz: 281e86c029b1a61720002b5ae889a2f8f6764a276ee2819084907fa12c590e18f6b786953427ef1f087c9830fd53e76a688140b64ce85fe65a19cd65766413fd
7
+ data.tar.gz: e6de2276bb6dcb372aea80fc149ad89b31717c855f4dbee81d771e4746738a50ec4125a8884dbbf537bc8d8030b9e3b578227a2e4e0a8c1e682155c456adfdd4
@@ -15,7 +15,8 @@ module Gitnesse
15
15
  end
16
16
 
17
17
  def parse(args = ARGV)
18
- parser.parse! args
18
+ # gitnesse run will pass all arguments onto cucumber
19
+ parser.parse! args unless ARGV.first == "run"
19
20
 
20
21
  arg = args.shift.to_s
21
22
 
@@ -11,12 +11,16 @@ Pulls changed features from remote git-based wiki, runs Cucumber, and pushes
11
11
  annotated results to the remote git-based wiki if the "annotate_results" setting
12
12
  is enabled.
13
13
 
14
+ Unlike other commands, all arguments passed to gitnesse run will be passed
15
+ through to Cucumber if you only want to run specific cukes.
16
+
14
17
  Examples:
15
18
  gitnesse run # will pull changes, run cucumber, and annotate results
19
+ gitnesse run ./features/addition.feature
16
20
  EOS
17
21
  end
18
22
 
19
- def perform
23
+ def perform(*args)
20
24
  load_and_check_config
21
25
  clone_wiki
22
26
  extract_features_from_wiki
@@ -27,7 +31,7 @@ Examples:
27
31
  remove_existing_results_from_wiki
28
32
 
29
33
  create_hooks
30
- run_features
34
+ run_features(args)
31
35
  remove_hooks
32
36
 
33
37
  push_annotated_results_to_wiki
@@ -64,15 +68,19 @@ Examples:
64
68
 
65
69
  # Public: Runs Cucumber features
66
70
  #
71
+ # args - optional array of arguments to be passed to Cucumber
72
+ #
67
73
  # Returns nothing
68
- def run_features
69
- puts " Running cucumber."
70
- puts ' -------------------', ''
74
+ def run_features(args = [])
75
+ puts " Running cucumber.", ' -------------------', ''
76
+ args = (args.empty? ? @config.features_dir : args.join(' '))
77
+
71
78
  if defined?(Bundler)
72
- Bundler.with_clean_env { system "cucumber #{@config.features_dir}" }
79
+ Bundler.with_clean_env { system "bundle exec cucumber #{args}" }
73
80
  else
74
- system "cucumber #{@config.features_dir}"
81
+ system "bundle exec cucumber #{args}"
75
82
  end
83
+
76
84
  puts ' -------------------', ''
77
85
  end
78
86
 
@@ -31,10 +31,17 @@ module Gitnesse
31
31
  Gitnesse::ConfigLoader.find_and_load
32
32
  dir = Gitnesse::DirManager.project_dir
33
33
 
34
- file = scenario.file.gsub(/^#{@config.features_dir}\//, '')
34
+ if scenario.respond_to?(:scenario_outline)
35
+ file = scenario.scenario_outline.file.gsub(/^#{@config.features_dir}\//, '')
36
+ name = "#{scenario.scenario_outline.name}"
37
+ subtitle = scenario.name.gsub(/(^\|\s+|\s+\|$)/, '').gsub(/\s+\|/, ',')
38
+ else
39
+ file = scenario.file.gsub(/^#{@config.features_dir}\//, '')
40
+ name = scenario.name
41
+ subtitle = nil
42
+ end
35
43
 
36
44
  page = file.gsub("/", " > ")
37
- name = scenario.name
38
45
  status = scenario.status
39
46
 
40
47
  @wiki = Gitnesse::Wiki.new(@config.repository_url, dir, clone: false)
@@ -42,7 +49,7 @@ module Gitnesse
42
49
 
43
50
  return unless page
44
51
 
45
- page.append_result name, status
52
+ page.append_result name, status, subtitle
46
53
  @wiki.repo.add(page.wiki_path)
47
54
  end
48
55
  end
@@ -1,3 +1,3 @@
1
1
  module Gitnesse
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -41,7 +41,11 @@ module Gitnesse
41
41
  #
42
42
  # Returns nothing
43
43
  def remove_results
44
- write(read.gsub(/(\s+\!\[\].*)/, ''))
44
+ content = read
45
+ # Remove old Cucumber results, if they exist
46
+ content.gsub!(/(\s+\!\[\].*)/, '') unless content =~ /\s+- !\[\].*---/m
47
+ content.gsub!(/\s+- !\[\].*---/m, '')
48
+ write content
45
49
  end
46
50
 
47
51
  # Public: Appends the result of a Cucumber scenario to the feature's wiki
@@ -50,16 +54,17 @@ module Gitnesse
50
54
  # scenario - feature scenario that was run
51
55
  # status - return status of the scenario, e.g. :passed, :undefined,
52
56
  # :failing
57
+ # subtitle - subtitle of scenario (used for scenario outlines)
53
58
  #
54
59
  # Returns nothing
55
- def append_result(scenario, status)
56
- status = status.to_s
57
- image = "![](https://s3.amazonaws.com/gitnesse/github/#{status}.png)"
58
- string = "\n\n#{image} \`"
59
- string << "Last Result For Scenario '#{scenario}': "
60
- string << status.upcase
61
- string << " (#{Time.now.strftime("%b %d, %Y, %-l:%M %p")} - "
62
- string << "#{Gitnesse::Config.instance.identifier})\`"
60
+ def append_result(scenario, status, subtitle = nil)
61
+ image = "![](//s3.amazonaws.com/gitnesse/github/#{status.to_s}.png)"
62
+ time = Time.now.strftime("%b %d, %Y, %-l:%M %p")
63
+ identifier = Gitnesse::Config.instance.identifier
64
+
65
+ string = "\n- #{image} **#{scenario}**".chomp
66
+ string << "\n- **(#{subtitle})**" if subtitle
67
+ string << "\n- #{identifier} - #{time}\n\n---"
63
68
 
64
69
  write(read + string)
65
70
  end
@@ -7,8 +7,9 @@ module Gitnesse
7
7
  describe "#find_and_load" do
8
8
  context "when no config file exists" do
9
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.")
10
+ expect(Dir).to receive(:glob).and_return []
11
+ message = "Can't find a gitnesse.rb file with Gitnesse configuration."
12
+ expect(ConfigLoader).to receive(:raise_error).with message
12
13
  end
13
14
 
14
15
  it "raises an error" do
@@ -18,10 +19,10 @@ module Gitnesse
18
19
 
19
20
  context "when one config file exists" do
20
21
  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)
22
+ files = [Support.example_config_file]
23
+ expect(Dir).to receive(:glob).and_return(files)
24
+ expect(ConfigLoader).to receive(:load).and_return(true)
25
+ expect(ConfigLoader).to receive(:reject_irrelevant_files).and_return(files)
25
26
  end
26
27
 
27
28
  it "loads the config file" do
@@ -31,10 +32,10 @@ module Gitnesse
31
32
 
32
33
  context "when multiple config files exist" do
33
34
  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)
35
+ files = [Support.example_config_file, Support.example_config_file]
36
+ expect(Dir).to receive(:glob).and_return(files)
37
+ expect(ConfigLoader).to receive(:reject_irrelevant_files).and_return(files)
38
+ expect(ConfigLoader).to receive(:raise_error).with("Multiple configuration files found:", files)
38
39
  end
39
40
 
40
41
  it "raises an error" do
@@ -10,7 +10,7 @@ module Gitnesse
10
10
  checks = %w(check_git check_cucumber check_repository_url
11
11
  check_identifier check_features_dir_exists)
12
12
  checks.each do |check|
13
- checker.should_receive(check.to_sym).and_return(true)
13
+ expect(checker).to receive(check.to_sym).and_return(true)
14
14
  end
15
15
 
16
16
  checker.check
@@ -21,11 +21,11 @@ module Gitnesse
21
21
  check_features_dir_exists)
22
22
 
23
23
  checks.each do |check|
24
- checker.should_receive(check.to_sym).and_return(true)
24
+ expect(checker).to receive(check.to_sym).and_return(true)
25
25
  end
26
26
 
27
- checker.should_receive(:system).with('git --version &> /dev/null').and_return(nil)
28
- checker.should_receive(:display_errors)
27
+ expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(nil)
28
+ expect(checker).to receive(:display_errors)
29
29
 
30
30
  checker.check
31
31
  end
@@ -35,9 +35,9 @@ module Gitnesse
35
35
  before do
36
36
  checker.instance_variable_set(:@errors, ["this is an example error"])
37
37
 
38
- checker.should_receive(:puts).with("Configuration errors were found!")
39
- checker.should_receive(:puts).with(" - this is an example error")
40
- checker.should_receive(:abort)
38
+ expect(checker).to receive(:puts).with("Configuration errors were found!")
39
+ expect(checker).to receive(:puts).with(" - this is an example error")
40
+ expect(checker).to receive(:abort)
41
41
  end
42
42
 
43
43
  it "prints a note saying errors were found" do
@@ -56,7 +56,7 @@ module Gitnesse
56
56
  describe '#check_git' do
57
57
  context 'when git is installed' do
58
58
  before do
59
- checker.should_receive(:system).with('git --version &> /dev/null').and_return(true)
59
+ expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(true)
60
60
  end
61
61
 
62
62
  it 'returns true' do
@@ -66,7 +66,7 @@ module Gitnesse
66
66
 
67
67
  context 'when git is not installed' do
68
68
  before do
69
- checker.should_receive(:system).with('git --version &> /dev/null').and_return(nil)
69
+ expect(checker).to receive(:system).with('git --version &> /dev/null').and_return(nil)
70
70
  end
71
71
 
72
72
  it 'adds an error' do
@@ -80,7 +80,7 @@ module Gitnesse
80
80
  describe '#check_cucumber' do
81
81
  context 'when cucumber is installed' do
82
82
  before do
83
- checker.should_receive(:system).with('cucumber --version &> /dev/null').and_return(true)
83
+ expect(checker).to receive(:system).with('cucumber --version &> /dev/null').and_return(true)
84
84
  end
85
85
 
86
86
  it 'returns true' do
@@ -90,7 +90,7 @@ module Gitnesse
90
90
 
91
91
  context 'when cucumber is not installed' do
92
92
  before do
93
- checker.should_receive(:system).with('cucumber --version &> /dev/null').and_return(nil)
93
+ expect(checker).to receive(:system).with('cucumber --version &> /dev/null').and_return(nil)
94
94
  end
95
95
 
96
96
  it 'adds an error' do
@@ -169,7 +169,7 @@ module Gitnesse
169
169
  describe "#check_features_dir_exists" do
170
170
  context "when features_dir exists" do
171
171
  before do
172
- File.should_receive(:directory?).and_return(true)
172
+ expect(File).to receive(:directory?).and_return(true)
173
173
  end
174
174
 
175
175
  it "returns true" do
@@ -179,7 +179,7 @@ module Gitnesse
179
179
 
180
180
  context "when features_dir does not exist or is a file" do
181
181
  before do
182
- File.should_receive(:directory?).and_return(false)
182
+ expect(File).to receive(:directory?).and_return(false)
183
183
  end
184
184
 
185
185
  it "adds an error" do
@@ -6,7 +6,7 @@ module Gitnesse
6
6
 
7
7
  describe ".make_project_dir" do
8
8
  before do
9
- FileUtils.should_receive(:mkdir_p).with(path).and_return(true)
9
+ expect(FileUtils).to receive(:mkdir_p).with(path).and_return(true)
10
10
  end
11
11
 
12
12
  it "creates a dir based on the current project name" do
@@ -16,7 +16,7 @@ module Gitnesse
16
16
 
17
17
  describe ".remove_project_dir" do
18
18
  it "removes the wiki dir for the current project" do
19
- FileUtils.should_receive(:rm_rf).with(path).and_return(true)
19
+ expect(FileUtils).to receive(:rm_rf).with(path).and_return(true)
20
20
  DirManager.remove_project_dir
21
21
  end
22
22
  end
@@ -24,7 +24,7 @@ module Gitnesse
24
24
  describe ".project_dir_present?" do
25
25
  context "if project dir is a directory" do
26
26
  before do
27
- File.should_receive(:directory?).with(path).and_return(true)
27
+ expect(File).to receive(:directory?).with(path).and_return(true)
28
28
  end
29
29
 
30
30
  it "returns true" do
@@ -34,7 +34,7 @@ module Gitnesse
34
34
 
35
35
  context "if project dir does not exists" do
36
36
  before do
37
- File.should_receive(:directory?).with(path).and_return(false)
37
+ expect(File).to receive(:directory?).with(path).and_return(false)
38
38
  end
39
39
 
40
40
  it "returns false" do
@@ -19,7 +19,7 @@ module Gitnesse
19
19
 
20
20
  describe "#read" do
21
21
  it "reads and caches the page's contents" do
22
- File.should_receive(:read).with(page.wiki_path).once.and_return("test")
22
+ expect(File).to receive(:read).with(page.wiki_path).once.and_return("test")
23
23
 
24
24
  expect(page.read).to be_a String
25
25
  expect(page.read).to eq "test"
@@ -1,17 +1,30 @@
1
1
  SUPPORT_FILES_DIR = File.join(File.dirname(__FILE__), "/support")
2
2
 
3
- Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each { |f| require(f) }
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+ require 'tmpdir'
6
+
7
+ module CliSpecs
8
+ def gitnesse(args)
9
+ out = StringIO.new
10
+ Gitnesse::Cli.new(out).parse(args.split(/\s+/))
11
+
12
+ out.rewind
13
+ out.read
14
+ rescue SystemExit
15
+ out.rewind
16
+ out.read
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |c|
21
+ c.include CliSpecs, type: :cli
22
+ end
4
23
 
5
24
  class Support
6
25
  class << self
7
- def example_config_file_path
8
- "#{SUPPORT_FILES_DIR}/example_config/gitnesse.rb"
9
- end
10
-
11
26
  def example_config_file
12
- @example_config ||= begin
13
- File.read(example_config_file_path)
14
- end
27
+ "#{SUPPORT_FILES_DIR}/example_config/gitnesse.rb"
15
28
  end
16
29
 
17
30
  def addition_feature
@@ -57,8 +70,10 @@ class Support
57
70
  ```gherkin
58
71
  #{division_feature}
59
72
  ```
73
+ - ![](//s3.amazonaws.com/gitnesse/github/passed.png) **Divide two numbers**
74
+ - - Sep 06, 2013, 10:10 AM
60
75
 
61
- ![](https://s3.amazonaws.com/gitnesse/github/passed.png) `Last Result For Scenario 'Divide two numbers': PASSED (Sep 06, 2013, 10:10 AM - )`
76
+ ---
62
77
  EOS
63
78
  end
64
79
 
@@ -77,3 +92,4 @@ class Support
77
92
  end
78
93
  end
79
94
  end
95
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitnesse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - www.hybridgroup.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,7 +154,6 @@ files:
154
154
  - spec/lib/wiki/page_spec.rb
155
155
  - spec/lib/wiki_spec.rb
156
156
  - spec/spec_helper.rb
157
- - spec/support/cli.rb
158
157
  - spec/support/example_config/gitnesse.rb
159
158
  - spec/support/example_features/addition.feature
160
159
  - spec/support/example_features/division.feature
@@ -180,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
179
  version: '0'
181
180
  requirements: []
182
181
  rubyforge_project:
183
- rubygems_version: 2.1.2
182
+ rubygems_version: 2.0.3
184
183
  signing_key:
185
184
  specification_version: 4
186
185
  summary: Sync your feature stories using a Git-based wiki!
@@ -209,7 +208,6 @@ test_files:
209
208
  - spec/lib/wiki/page_spec.rb
210
209
  - spec/lib/wiki_spec.rb
211
210
  - spec/spec_helper.rb
212
- - spec/support/cli.rb
213
211
  - spec/support/example_config/gitnesse.rb
214
212
  - spec/support/example_features/addition.feature
215
213
  - spec/support/example_features/division.feature
@@ -1,20 +0,0 @@
1
- require 'fileutils'
2
- require 'tempfile'
3
- require 'tmpdir'
4
-
5
- module CliSpecs
6
- def gitnesse(args)
7
- out = StringIO.new
8
- Gitnesse::Cli.new(out).parse(args.split(/\s+/))
9
-
10
- out.rewind
11
- out.read
12
- rescue SystemExit
13
- out.rewind
14
- out.read
15
- end
16
- end
17
-
18
- RSpec.configure do |c|
19
- c.include CliSpecs, type: :cli
20
- end