turnip-dry_run 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d64427233c1de1b501845592dc6aeedd364224f
4
+ data.tar.gz: 57b049068b05107a41b65e49eb95be614872e804
5
+ SHA512:
6
+ metadata.gz: a81ad1f7f3b799c8c2997fa33a63a809d88b79805eb285d508aef74ef4b5391125566f8e5da0974e50aae2b10c8b1aeded799ace454f15f3f94dad79dcf259be
7
+ data.tar.gz: 0f08b58f95d4641da856a4994c1d4aeed9b33af5460870c77292cdc2629ab8c37c68bcf9a4f581b5a3ce0393ef8d1aa68bc7622df720651df4426220037d1b8a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ -r turnip/rspec
4
+ -r turnip/dry_run
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ script: bundle exec rspec
5
+ gemfile:
6
+ - Gemfile
7
+ - rspec-3.2.x.gemfile
8
+ - rspec-3.1.x.gemfile
9
+ - rspec-3.0.x.gemfile
10
+ - rspec-2.99.x.gemfile
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turnip-dry_run.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Seiei Higa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Turnip::DryRun
2
+ [![Build Status](https://travis-ci.org/hanachin/turnip-dry_run.svg?branch=master)](https://travis-ci.org/hanachin/turnip-dry_run)
3
+
4
+ Do dry run for turnip feature specs to get some step metadata.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'turnip-dry_run'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install turnip-dry_run
21
+
22
+ ## Usage
23
+
24
+ `spec/support/turnip-dry_run.rb`
25
+
26
+ ```rb
27
+ if ENV['DRY_RUN']
28
+ Turnip::RSpec::Execute.prepend(Turnip::DryRun)
29
+
30
+ RSpec.configure do |config|
31
+ config.formatter = Turnip::DryRun::TextFormatter
32
+ end
33
+ end
34
+ ```
35
+
36
+ then
37
+
38
+ ```
39
+ $ DRY_RUN=t bundle exec rspec
40
+ ```
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/hanachin/turnip-dry_run/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "turnip/dry_run"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ Feature: Attacking a monster
2
+ Background:
3
+ Given there is a monster called "Kijimun"
4
+
5
+ Scenario: attack the monster
6
+ When I change its name to "Kijimuna"
7
+ Then it should be called "Kijimuna"
@@ -0,0 +1,11 @@
1
+ step "there is a monster called :name" do |name|
2
+ @monster_name = name
3
+ end
4
+
5
+ step "I change its name to :name" do |name|
6
+ @monster_name = name
7
+ end
8
+
9
+ step 'it should be called "Kijimuna"' do
10
+ expect(@monster_name).to eq "Kijimuna"
11
+ end
@@ -0,0 +1,61 @@
1
+ require 'rspec/core/formatters/base_formatter'
2
+ require "turnip/dry_run/version"
3
+ require "turnip/dry_run/base_formatter"
4
+ require "turnip/dry_run/text_formatter"
5
+
6
+ module Turnip
7
+ module DryRun
8
+ class StepMetadata < Struct.new(:feature_file, :step, :step_method)
9
+ def method_name
10
+ step_method.name
11
+ end
12
+
13
+ def method_lineno
14
+ step_method.source_location.last
15
+ end
16
+
17
+ def method_filename
18
+ step_method.source_location.first
19
+ end
20
+ end
21
+
22
+ def run_step(feature_file, step)
23
+ step_metadata = StepMetadata.new(feature_file, step, super)
24
+
25
+ example = Turnip::RSpec.fetch_current_example(self)
26
+ example.metadata[:steps] ||= []
27
+ example.metadata[:steps] << step_metadata
28
+ end
29
+
30
+ def step(step_or_description, *extra_args)
31
+ #
32
+ # This code clone from turnip source tree,
33
+ # lib/turnip/execute.rb
34
+ # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
35
+ if step_or_description.respond_to?(:extra_args)
36
+ description = step_or_description.description
37
+ extra_args.concat(step_or_description.extra_args)
38
+ else
39
+ description = step_or_description
40
+ end
41
+
42
+ matches = methods.map do |method|
43
+ next unless method.to_s.start_with?("match: ")
44
+ send(method.to_s, description)
45
+ end.compact
46
+
47
+ if matches.length == 0
48
+ raise Turnip::Pending, description
49
+ end
50
+
51
+ if matches.length > 1
52
+ msg = ['Ambiguous step definitions'].concat(matches.map(&:trace)).join("\r\n")
53
+ raise Turnip::Ambiguous, msg
54
+ end
55
+ # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
56
+
57
+ m = matches.first
58
+ method(m.method_name)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,9 @@
1
+ module Turnip
2
+ module DryRun
3
+ class BaseFormatter < ::RSpec::Core::Formatters::BaseFormatter
4
+ def initialize(output)
5
+ super(output)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ module Turnip
2
+ module DryRun
3
+ class TextFormatter < BaseFormatter
4
+ # FIXME
5
+ if ::RSpec::Core::Formatters.respond_to?(:register)
6
+ ::RSpec::Core::Formatters.register self, :example_passed
7
+ end
8
+
9
+ def example_passed(notification)
10
+ # FIXME
11
+ example = notification.respond_to?(:example) ? notification.example : notification
12
+
13
+ feature_path_width = example.metadata[:steps].map {|s|
14
+ "#{s.feature_file}:#{s.step.line}".size
15
+ }.max
16
+ step_width = example.metadata[:steps].map {|s|
17
+ s.step.description.size
18
+ }.max
19
+ method_name_width = example.metadata[:steps].map {|s|
20
+ s.method_name.size
21
+ }.max
22
+ method_path_width = example.metadata[:steps].map {|s|
23
+ "#{s.method_filename}:#{s.method_lineno}".size
24
+ }.max
25
+ example.metadata[:steps].each do |s|
26
+ m = ["#{s.feature_file}:#{s.step.line}", s.step.description, "#{s.method_filename}:#{s.method_lineno}", s.method_name]
27
+ output << "%-#{feature_path_width}s %-#{step_width}s -> %-#{method_path_width}s %-#{method_name_width}s#{$/}" % m
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Turnip
2
+ module DryRun
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turnip-dry_run.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec', '~> 2.99.0'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turnip-dry_run.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec', '~> 3.0.0'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turnip-dry_run.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec', '~> 3.1.0'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turnip-dry_run.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec', '~> 3.2.0'
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'turnip/dry_run/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "turnip-dry_run"
8
+ spec.version = Turnip::DryRun::VERSION
9
+ spec.authors = ["Seiei Higa"]
10
+ spec.email = ["hanachin@gmail.com"]
11
+
12
+ spec.summary = %q{Do dry run for turnip feature specs to get some step metadata.}
13
+ spec.homepage = "https://github.com/hanachin/turnip-dry_run"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
23
+ end
24
+
25
+ spec.add_dependency "turnip", "~> 1.2.4"
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec"
29
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turnip-dry_run
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seiei Higa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: turnip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - hanachin@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - examples/hello.feature
87
+ - examples/steps/monster_steps.rb
88
+ - lib/turnip/dry_run.rb
89
+ - lib/turnip/dry_run/base_formatter.rb
90
+ - lib/turnip/dry_run/text_formatter.rb
91
+ - lib/turnip/dry_run/version.rb
92
+ - rspec-2.99.x.gemfile
93
+ - rspec-3.0.x.gemfile
94
+ - rspec-3.1.x.gemfile
95
+ - rspec-3.2.x.gemfile
96
+ - turnip-dry_run.gemspec
97
+ homepage: https://github.com/hanachin/turnip-dry_run
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ allowed_push_host: https://rubygems.org
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.4.5
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Do dry run for turnip feature specs to get some step metadata.
122
+ test_files: []
123
+ has_rdoc: