cucumber-slices 0.0.0 → 0.0.1

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: 2d88a947fb01c1b1e19dbb8dfecca01eb1a0dedf
4
- data.tar.gz: 5643d09f34ac57981e805f53436aaa565e082125
3
+ metadata.gz: 5a46d963a9235a05ef5432480023c2bd956d6157
4
+ data.tar.gz: 6802748b8d5d5f6f27aad8a624983a2fc3e40904
5
5
  SHA512:
6
- metadata.gz: 9bd364eb8c6bcf34d672669e5d47ea21e6a7aa463d161346acdc35bee586bbd4950e62ed6ff3f92d8e36a8140b071cdfbbabb8e48596edbc089b65d2b31fe2ba
7
- data.tar.gz: 9ae9421d61e8704e405c6815c7c8087ec1e1b49dad19e95fd3bd5173456f6d783c3dd641e77b936c0f4be8faab1fc31fd12b64406ebd8837f442e0c38c357bbe
6
+ metadata.gz: bf5eaeb841b8b2b4285fe5aa7479af3456309250d0df485093dd0c55199512951f5f60a49d7503c497b0501fa836d2bbb0ba4c726f95c7b62a268c00aadb3ea3
7
+ data.tar.gz: 4be6238125301653ec94f5538d7e0cb63644971bde15586396c927e61219609cd0be7fd913a0b566b7a627a9828a90eb3c863f0cddb083b9fa981e12a98aa320
data/Gemfile CHANGED
@@ -12,6 +12,7 @@ group :development do
12
12
  gem "bundler", "~> 1.0"
13
13
  gem "jeweler", "~> 2.0.1"
14
14
  gem "simplecov", ">= 0"
15
+ gem "docopt", "~> 0.5", ">= 0.5.0"
15
16
  end
16
17
  group :test do
17
18
  gem "debugger", ">= 1.6.6"
data/README.rdoc CHANGED
@@ -1,17 +1,27 @@
1
1
  = cucumber-slices
2
2
 
3
- Description goes here.
4
-
5
- == Contributing to cucumber-slices
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
3
+ Puts your steps right under your cucumber features.
14
4
 
5
+ == Usage
6
+
7
+ Say you have a feature called tic-tac-toe and you have written steps for it Just type
8
+
9
+ cucumber-slices tic-tac-toe
10
+
11
+ and get something like this...
12
+
13
+ 6 Scenario: Begin Game
14
+ 7 Given I start a new Tic-Tac-Toe game
15
+ @game = TicTacToe.new
16
+ 8 When I enter my name Renee
17
+ @game.player = name
18
+ 9 Then the computer welcomes me to the game with "Welcome Renee"
19
+ @game.welcome_player.should eq arg1
20
+ 10 And randomly chooses who goes first
21
+ [@game.player, "Computer"].should include @game.current_player
22
+ 11 And who is X and who is O
23
+ TicTacToe::SYMBOLS.should include @game.player_symbol, @game.computer_symbol
24
+
15
25
  == Copyright
16
26
 
17
27
  Copyright (c) 2014 psytau. See LICENSE.txt for
data/Rakefile CHANGED
@@ -38,8 +38,8 @@ task :simplecov do
38
38
  Rake::Task['spec'].execute
39
39
  end
40
40
 
41
- #require 'cucumber/rake/task'
42
- #Cucumber::Rake::Task.new(:features)
41
+ require 'cucumber/rake/task'
42
+ Cucumber::Rake::Task.new(:features)
43
43
 
44
44
  task :default => :spec
45
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/bin/cucumber-slices CHANGED
@@ -1,21 +1,71 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'cucumber-slices'
4
+ require 'docopt'
4
5
 
5
- feature_name = ARGV[0]
6
+ doc = <<DOCOPT
7
+ cucumber-slices
6
8
 
7
- cs = CucumberSlices.new
9
+ Usage:
10
+ cucumber-slices <feature_file> [--lines=<line_range>]
8
11
 
9
- feature_file = "./features/#{feature_name}.feature"
10
- step_file = "./features/step_definitions/#{feature_name}_steps.rb"
12
+ Options:
13
+ -h Show this message.
14
+ --version Show version.
15
+ --lines=<line_range> Range for feature file.
11
16
 
12
- open(step_file) do |file|
13
- cs.extract_steps file
17
+ DOCOPT
18
+ # opts = {}
19
+ begin
20
+ require "pp"
21
+ opts = Docopt::docopt(doc)
22
+ rescue Docopt::Exit => e
23
+ puts e.message
14
24
  end
15
25
 
16
- splice = []
17
- open(feature_file) do |file|
18
- splice = cs.splice_features file
26
+ if opts['-h']
27
+ puts doc
19
28
  end
20
29
 
21
- puts splice
30
+ puts opts
31
+
32
+ if opts['<feature_file>']
33
+ lines_range = nil
34
+ if opts['--lines']
35
+ lines_opt= opts['--lines'].split("-")
36
+ from_to = lines_opt.map {|line_no| line_no.to_i}
37
+ if (from_to.length != 2) or (from_to[0] == from_to[1])
38
+ puts "bad lines arguement #{lines}"
39
+ exit(0)
40
+ end
41
+ lines_range = (from_to[0]..from_to[1])
42
+ end
43
+ cs = CucumberSlices.new
44
+
45
+ feature_file = opts['<feature_file>']
46
+ feature_name = File.basename feature_file, '.feature'
47
+ step_file = "#{File.dirname feature_file}/step_definitions/#{feature_name}_steps.rb"
48
+ # also try with a - instead of a _
49
+ if ! File.exists? step_file
50
+ step_file_with_underscore = "#{File.dirname feature_file}/step_definitions/#{feature_name}-steps.rb"
51
+ step_file = step_file_with_underscore if File.exists? step_file_with_underscore
52
+ end
53
+
54
+ # catch 'em all!
55
+ # TODO: don't catch them all, just catch file not found
56
+ begin
57
+ open(step_file) do |file|
58
+ cs.extract_steps file
59
+ end
60
+
61
+ splice = []
62
+ open(feature_file) do |file|
63
+ splice = cs.splice_features file, lines_range
64
+ end
65
+ puts splice
66
+ rescue IOError
67
+ puts "#{$!}"
68
+ exit(0)
69
+ end
70
+
71
+ end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: cucumber-slices 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "cucumber-slices"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["psytau"]
14
+ s.date = "2014-03-12"
15
+ s.description = "view steps along with your cukes"
16
+ s.email = "rmanninoFoo@gmail.com"
17
+ s.executables = ["cucumber-slices"]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE.txt",
20
+ "README.rdoc"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".rspec",
25
+ "Gemfile",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/cucumber-slices",
31
+ "cucumber-slices.gemspec",
32
+ "features/cucumber-slices.feature",
33
+ "features/step_definitions/cucumber-slices_steps.rb",
34
+ "features/support/env.rb",
35
+ "lib/cucumber-slices.rb",
36
+ "spec/cucumber-slices_spec.rb",
37
+ "spec/spec_helper.rb"
38
+ ]
39
+ s.homepage = "http://github.com/psytau/cucumber-slices"
40
+ s.licenses = ["MIT"]
41
+ s.rubygems_version = "2.2.2"
42
+ s.summary = "view steps along with your cukes"
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 4
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
49
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
53
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
54
+ s.add_development_dependency(%q<docopt>, [">= 0.5.0", "~> 0.5"])
55
+ else
56
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
57
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
+ s.add_dependency(%q<cucumber>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_dependency(%q<simplecov>, [">= 0"])
62
+ s.add_dependency(%q<docopt>, [">= 0.5.0", "~> 0.5"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
66
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
67
+ s.add_dependency(%q<cucumber>, [">= 0"])
68
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
69
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
70
+ s.add_dependency(%q<simplecov>, [">= 0"])
71
+ s.add_dependency(%q<docopt>, [">= 0.5.0", "~> 0.5"])
72
+ end
73
+ end
74
+
@@ -1,9 +1,14 @@
1
- Feature: something something
2
- In order to something something
3
- A user something something
4
- something something something
1
+ Feature: View steps and cukes together
2
+ As a programmer I want to read cuke files more easily
3
+ In order to quickly match up the steps with the right cukes
4
+ A programmer would like to see them together
5
5
 
6
- Scenario: something something
7
- Given inspiration
8
- When I create a sweet new gem
9
- Then everyone should see how awesome I am
6
+ Scenario: View a cucumber-slice
7
+ Given a tic-tac-toe feature file and a step file
8
+ When I slice them.
9
+ Then The program should return lines of the cuke followed by the steps
10
+
11
+ Scenario: View a portion of a feature file
12
+ Given a tic-tac-toe feature file and a step file
13
+ When I slice them with a lines=(2..3) arguement
14
+ Then Then it should return lines 2 to 3 of the feature
@@ -0,0 +1,67 @@
1
+ Given(/^a tic\-tac\-toe feature file and a step file$/) do
2
+ cuke = <<CUKE
3
+ Given I have a started Tic-Tac-Toe game
4
+ And it is the computer's turn
5
+ And the computer is playing X
6
+ Then the computer randomly chooses an open position for its move
7
+ And the board should have an X on it
8
+ CUKE
9
+ @cuke_lines = cuke.split("\n")
10
+ steps = <<STEP
11
+ Given /^I have a started Tic\-Tac\-Toe game$/ do
12
+ @game = TicTacToe.new(:player)
13
+ @game.player = "Renee"
14
+ end
15
+
16
+ Given /^it is the computer's turn$/ do
17
+ @game = TicTacToe.new(:computer, :O)
18
+ @game.current_player.should eq "Computer"
19
+ end
20
+
21
+ Given /^the computer is playing X$/ do
22
+ @game.computer_symbol.should eq :X
23
+ end
24
+
25
+ Then /^the computer randomly chooses an open position for its move$/ do
26
+ open_spots = @game.open_spots
27
+ @com_move = @game.computer_move
28
+ open_spots.should include(@com_move)
29
+ end
30
+
31
+ Then /^the board should have an X on it$/ do
32
+ @game.current_state.should include 'X'
33
+ end
34
+ STEP
35
+ @step_lines = steps.split("\n")
36
+ end
37
+
38
+ When(/^I slice them\.$/) do
39
+ @cs = CucumberSlices.new
40
+ @cs.extract_steps @step_lines
41
+ @output = @cs.splice_features @cuke_lines
42
+ end
43
+
44
+ Then(/^The program should return lines of the cuke followed by the steps$/) do
45
+ @output[0].should == "1 #{@cuke_lines[0]}"
46
+ @output[1].should == " \t#{@step_lines[1]}"
47
+ @output[2].should == " \t#{@step_lines[2]}"
48
+ @output[3].should == "2 #{@cuke_lines[1]}"
49
+ @output[4].should == " \t\t#{@step_lines[6]}"
50
+ @output[5].should == " \t\t#{@step_lines[7]}"
51
+ @output[6].should == "3 #{@cuke_lines[2]}"
52
+ @output[7].should == " \t\t#{@step_lines[11]}"
53
+ end
54
+
55
+ When(/^I slice them with a lines=\((\d+)\.\.(\d+)\) arguement$/) do |arg1, arg2|
56
+ @cs = CucumberSlices.new
57
+ @cs.extract_steps @step_lines
58
+ @output = @cs.splice_features @cuke_lines, (arg1.to_i()..arg2.to_i())
59
+ end
60
+
61
+ Then(/^Then it should return lines 2 to 3 of the feature$/) do
62
+ @output[0].should == "2 #{@cuke_lines[1]}"
63
+ @output[1].should == " \t\t#{@step_lines[6]}"
64
+ @output[2].should == " \t\t#{@step_lines[7]}"
65
+ @output[3].should == "3 #{@cuke_lines[2]}"
66
+ @output[4].should == " \t\t#{@step_lines[11]}"
67
+ end
@@ -15,8 +15,6 @@ class CucumberSlices
15
15
  cmd = nil
16
16
  code = []
17
17
  @steps = []
18
- #open('features/step_definitions/tic-tac-toe-steps.rb') do |file|
19
- # open(file_name) do |file|
20
18
  file.each do |line|
21
19
  if line =~ /^end/
22
20
  in_cmd_block = false
@@ -32,24 +30,24 @@ class CucumberSlices
32
30
  code << line if in_cmd_block
33
31
  end
34
32
  end
35
- # end
36
33
  end
37
34
 
38
- def splice_features feature_file
39
- # open ('features/tic-tac-toe.feature') do |file|
35
+ def splice_features(feature_file, lines=nil)
40
36
  splice = []
41
37
  count = 0
42
38
  feature_file.each do |line|
43
39
  count = count + 1
44
- splice << "#{count.to_s} #{line}"
45
- if line =~ /^([ \t]+)(Given|When|Then|And) (.+)/
46
- indent = $1
47
- cmd = $2
48
- code = $3
49
- @steps.each do |step|
50
- if code =~ Regexp.new(step.regex)
51
- step.code.each do |l|
52
- splice << "#{indent}#{l}"
40
+ if !lines or lines.include?(count)
41
+ splice << "#{count.to_s} #{line}"
42
+ if line =~ /^([ \t]+)(Given|When|Then|And) (.+)/
43
+ indent = $1
44
+ cmd = $2
45
+ code = $3
46
+ @steps.each do |step|
47
+ if code =~ Regexp.new(step.regex)
48
+ step.code.each do |l|
49
+ splice << "#{indent}#{l}"
50
+ end
53
51
  end
54
52
  end
55
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-slices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - psytau
@@ -94,6 +94,26 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: docopt
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.5.0
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ version: '0.5'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: 0.5.0
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ version: '0.5'
97
117
  description: view steps along with your cukes
98
118
  email: rmanninoFoo@gmail.com
99
119
  executables:
@@ -111,6 +131,7 @@ files:
111
131
  - Rakefile
112
132
  - VERSION
113
133
  - bin/cucumber-slices
134
+ - cucumber-slices.gemspec
114
135
  - features/cucumber-slices.feature
115
136
  - features/step_definitions/cucumber-slices_steps.rb
116
137
  - features/support/env.rb