kikambii 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +64 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/kikambii.gemspec +19 -0
- data/lib/kikambii.rb +11 -0
- data/lib/kikambii/feature.rb +33 -0
- data/lib/kikambii/feature_factory.rb +21 -0
- data/lib/kikambii/runner.rb +5 -0
- data/lib/kikambii/version.rb +3 -0
- data/lib/tasks/cucumber.rake +18 -0
- data/spec/lib/kikambii/feature_factory_spec.rb +46 -0
- data/spec/lib/kikambii/feature_spec.rb +85 -0
- data/spec/spec_helper.rb +1 -0
- metadata +67 -0
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@kikambii --create
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kikambii (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
remote: http://geminabox.ir7.com.br/
|
9
|
+
specs:
|
10
|
+
builder (3.1.4)
|
11
|
+
coderay (1.0.8)
|
12
|
+
diff-lcs (1.1.3)
|
13
|
+
geminabox (0.8.0)
|
14
|
+
builder
|
15
|
+
httpclient
|
16
|
+
sinatra
|
17
|
+
guard (1.5.4)
|
18
|
+
listen (>= 0.4.2)
|
19
|
+
lumberjack (>= 1.0.2)
|
20
|
+
pry (>= 0.9.10)
|
21
|
+
thor (>= 0.14.6)
|
22
|
+
guard-rspec (2.3.1)
|
23
|
+
guard (>= 1.1)
|
24
|
+
rspec (~> 2.11)
|
25
|
+
httpclient (2.3.0.1)
|
26
|
+
listen (0.6.0)
|
27
|
+
lumberjack (1.0.2)
|
28
|
+
method_source (0.8.1)
|
29
|
+
pry (0.9.10)
|
30
|
+
coderay (~> 1.0.5)
|
31
|
+
method_source (~> 0.8)
|
32
|
+
slop (~> 3.3.1)
|
33
|
+
rack (1.4.1)
|
34
|
+
rack-protection (1.3.2)
|
35
|
+
rack
|
36
|
+
rake (10.0.3)
|
37
|
+
rspec (2.12.0)
|
38
|
+
rspec-core (~> 2.12.0)
|
39
|
+
rspec-expectations (~> 2.12.0)
|
40
|
+
rspec-mocks (~> 2.12.0)
|
41
|
+
rspec-core (2.12.1)
|
42
|
+
rspec-expectations (2.12.0)
|
43
|
+
diff-lcs (~> 1.1.3)
|
44
|
+
rspec-mocks (2.12.0)
|
45
|
+
sinatra (1.3.3)
|
46
|
+
rack (~> 1.3, >= 1.3.6)
|
47
|
+
rack-protection (~> 1.2)
|
48
|
+
tilt (~> 1.3, >= 1.3.3)
|
49
|
+
slop (3.3.3)
|
50
|
+
thor (0.16.0)
|
51
|
+
tilt (1.3.3)
|
52
|
+
toleman (4.3.1)
|
53
|
+
geminabox
|
54
|
+
rake
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
guard-rspec
|
61
|
+
kikambii!
|
62
|
+
rake
|
63
|
+
rspec
|
64
|
+
toleman
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Lucas Souza
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Kikambii
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'kikambii'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install kikambii
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require './lib/kikambii'
|
data/kikambii.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kikambii/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "kikambii"
|
8
|
+
gem.version = Kikambii::VERSION
|
9
|
+
gem.authors = ["Lucas Souza"]
|
10
|
+
gem.email = ["lasouza@sp.r7.com"]
|
11
|
+
gem.description = ""
|
12
|
+
gem.summary = ""
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
data/lib/kikambii.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module Kikambii
|
4
|
+
include Rake::DSL if defined? Rake::DSL
|
5
|
+
load File.expand_path("../tasks/cucumber.rake", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
require "kikambii/version"
|
9
|
+
require "kikambii/feature"
|
10
|
+
require "kikambii/feature_factory"
|
11
|
+
require "kikambii/runner"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Kikambii::Feature
|
2
|
+
|
3
|
+
MAXIMUM_RETRIES = 3
|
4
|
+
|
5
|
+
attr_reader :attemps, :feature, :runner, :scenarios
|
6
|
+
|
7
|
+
def initialize(dependencies)
|
8
|
+
@feature, @scenarios, @runner, @attemps = dependencies[:feature], dependencies[:scenarios], dependencies[:runner], 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
return true unless should_run?
|
13
|
+
|
14
|
+
@scenarios.delete_if { |scenario| @runner.run command_for(scenario) }
|
15
|
+
@attemps += 1
|
16
|
+
|
17
|
+
@scenarios.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
def fail?
|
21
|
+
@scenarios.any?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def command_for(scenario)
|
27
|
+
"#{@feature}:#{scenario}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def should_run?
|
31
|
+
@attemps < MAXIMUM_RETRIES
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Kikambii::FeatureFactory
|
2
|
+
|
3
|
+
def initialize(dependencies)
|
4
|
+
@failures = dependencies[:failures]
|
5
|
+
end
|
6
|
+
|
7
|
+
def features
|
8
|
+
features = @failures.split(/\s/)
|
9
|
+
features.map { |feature| Kikambii::Feature.new feature: name_of(feature), scenarios: scenarios_of(feature), runner: Kikambii::Runner.new }
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def scenarios_of(feature)
|
15
|
+
feature.split(/:/)[1..-1]
|
16
|
+
end
|
17
|
+
|
18
|
+
def name_of(feature)
|
19
|
+
feature.split(/:/).first
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
desc 'rerun cucumber failures'
|
5
|
+
task :kikambii do |task|
|
6
|
+
if File.exist?(File.join(Rails.root, 'rerun.txt'))
|
7
|
+
failures = File.read(File.join(Rails.root, 'rerun.txt'))
|
8
|
+
features = Kikambii::FeatureFactory.new(failures: failures).features
|
9
|
+
|
10
|
+
features.each do |f|
|
11
|
+
while(!f.run) do
|
12
|
+
puts "Running feature: #{f.feature}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
fail "Some features failed" if features.any? { |f| f.fail? }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kikambii::FeatureFactory do
|
4
|
+
|
5
|
+
describe "#features" do
|
6
|
+
|
7
|
+
let(:runner) { mock.as_null_object }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Kikambii::Runner.stub(:new).and_return(runner)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "just features" do
|
14
|
+
subject { described_class.new failures: "features/article_images.feature features/article_related_content.feature" }
|
15
|
+
|
16
|
+
it "should return all features" do
|
17
|
+
subject.features.should have(2).features
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return feature objects" do
|
21
|
+
subject.features.first.feature.should == "features/article_images.feature"
|
22
|
+
subject.features.last.feature.should == "features/article_related_content.feature"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "features with runner" do
|
27
|
+
subject { described_class.new failures: "features/article_images.feature" }
|
28
|
+
|
29
|
+
it "should return features setting runner" do
|
30
|
+
subject.features.first.runner.should == runner
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "features with scenarios" do
|
35
|
+
subject { described_class.new failures: "features/article_images.feature:5:20:35" }
|
36
|
+
|
37
|
+
it "should return features" do
|
38
|
+
subject.features.first.feature.should == "features/article_images.feature"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return features setting scenarios" do
|
42
|
+
subject.features.first.scenarios.should == ["5", "20", "35"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kikambii::Feature do
|
4
|
+
|
5
|
+
let(:runner) { mock.as_null_object }
|
6
|
+
subject { described_class.new feature: "feature/test.feature", scenarios: [1, 10], runner: runner }
|
7
|
+
|
8
|
+
describe "#run" do
|
9
|
+
it "should run feature command for each scenario" do
|
10
|
+
runner.should_receive(:run).with("feature/test.feature:1")
|
11
|
+
runner.should_receive(:run).with("feature/test.feature:10")
|
12
|
+
|
13
|
+
subject.run
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should increment attemps number" do
|
17
|
+
subject.run
|
18
|
+
subject.attemps.should == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when all runs were true" do
|
22
|
+
before do
|
23
|
+
runner.stub(:run).and_return(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
it { subject.run.should be_true }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when some run fail" do
|
30
|
+
before do
|
31
|
+
runner.stub(:run).and_return(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
it { subject.run.should be_false }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when runner return true" do
|
38
|
+
before do
|
39
|
+
runner.stub(:run).with("feature/test.feature:1").and_return(false)
|
40
|
+
runner.stub(:run).with("feature/test.feature:10").and_return(true)
|
41
|
+
|
42
|
+
subject.run
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not run the same scenario again" do
|
46
|
+
runner.should_receive(:run).with("feature/test.feature:1")
|
47
|
+
runner.should_not_receive(:run).with("feature/test.feature:10")
|
48
|
+
|
49
|
+
subject.run
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when attemps sold up" do
|
54
|
+
before do
|
55
|
+
subject.instance_variable_set "@attemps", 3
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should not run any scenario" do
|
59
|
+
runner.should_not_receive(:run)
|
60
|
+
subject.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#fail?" do
|
66
|
+
context "when attemps sold up" do
|
67
|
+
|
68
|
+
context "and there are scenarios to run" do
|
69
|
+
before do
|
70
|
+
subject.instance_variable_set "@scenarios", ["1"]
|
71
|
+
end
|
72
|
+
|
73
|
+
it { subject.fail?.should be_true }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "and there aren't scenarios to run" do
|
77
|
+
before do
|
78
|
+
subject.instance_variable_set "@scenarios", []
|
79
|
+
end
|
80
|
+
|
81
|
+
it { subject.fail?.should be_false }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path("lib/kikambii")
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kikambii
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lucas Souza
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ''
|
15
|
+
email:
|
16
|
+
- lasouza@sp.r7.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rspec
|
23
|
+
- .rvmrc
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- Guardfile
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- kikambii.gemspec
|
31
|
+
- lib/kikambii.rb
|
32
|
+
- lib/kikambii/feature.rb
|
33
|
+
- lib/kikambii/feature_factory.rb
|
34
|
+
- lib/kikambii/runner.rb
|
35
|
+
- lib/kikambii/version.rb
|
36
|
+
- lib/tasks/cucumber.rake
|
37
|
+
- spec/lib/kikambii/feature_factory_spec.rb
|
38
|
+
- spec/lib/kikambii/feature_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
homepage: ''
|
41
|
+
licenses: []
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.15
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: ''
|
64
|
+
test_files:
|
65
|
+
- spec/lib/kikambii/feature_factory_spec.rb
|
66
|
+
- spec/lib/kikambii/feature_spec.rb
|
67
|
+
- spec/spec_helper.rb
|