bdd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/bdd.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/bdd.rb +14 -0
- data/lib/bdd/rspec.rb +8 -0
- data/lib/bdd/rspec/code.rb +170 -0
- data/lib/bdd/version.rb +3 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26bc9edd12abbfb44efd8697966b255f6c899347
|
4
|
+
data.tar.gz: 8a9572f9e28559163428f23f78bb0a060f2512f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7100c8e7cbfe604d8b15fe0a5db80008240e0ec32a163b79efd25e288657da4321052972f547eedae3655c7cae34bf6c468a777bf9866cf26839e708e65bdca
|
7
|
+
data.tar.gz: 196f90b2f5b424220cbffe9e4a4cb490946b1a66b867b232168f82f546a300d760a5d8c41453399a5da29892203f97a59bdcd4ffc6b1ca596766282f2e671fda
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Bdd
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bdd`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bdd'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bdd
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add this to your spec_helper.rb file
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'bdd'
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
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).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( https://github.com/[my-github-username]/bdd/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bdd.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bdd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bdd"
|
8
|
+
spec.version = Bdd::VERSION
|
9
|
+
spec.authors = ["James Pinto"]
|
10
|
+
spec.email = ["thejamespinto@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Cucumber style in your RSpec tests}
|
13
|
+
spec.description = %q{Cucumber style in your RSpec tests}
|
14
|
+
spec.homepage = "https://github.com/thejamespinto/bdd"
|
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'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'rspec-example_steps'
|
26
|
+
spec.add_runtime_dependency 'rspec'
|
27
|
+
spec.add_runtime_dependency 'colorize'
|
28
|
+
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
# spec.add_development_dependency 'rspec'
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bdd"
|
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
data/lib/bdd.rb
ADDED
data/lib/bdd/rspec.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# https://raw.githubusercontent.com/rspec/rspec-core/v3.2.2/lib/rspec/core/formatters/documentation_formatter.rb
|
2
|
+
# require "rspec/core/formatters/documentation_formatter"
|
3
|
+
|
4
|
+
RSpec::Support.require_rspec_core "formatters/base_text_formatter"
|
5
|
+
|
6
|
+
class RSpec::Core::ExampleGroup
|
7
|
+
def step(msg)
|
8
|
+
m = RSpec.current_example.metadata
|
9
|
+
|
10
|
+
if block_given?
|
11
|
+
# m[:step_messages] << msg #if m[:step_messages]
|
12
|
+
if @is_during_rspec_step
|
13
|
+
yield
|
14
|
+
else
|
15
|
+
m[:step_messages] << hash = {msg: msg}
|
16
|
+
@is_during_rspec_step = true
|
17
|
+
yield
|
18
|
+
# apply green color if example passes
|
19
|
+
hash[:color] = :green
|
20
|
+
@is_during_rspec_step = false
|
21
|
+
end
|
22
|
+
else
|
23
|
+
m[:step_messages] << {msg: "SKIPPED #{msg}"}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def Given(msg, &block)
|
28
|
+
step(["Given", msg], &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def When(msg, &block)
|
32
|
+
step([" When", msg], &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def Then(msg, &block)
|
36
|
+
step([" Then", msg], &block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def And(msg, &block)
|
40
|
+
step([" And", msg], &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def But(msg, &block)
|
44
|
+
step([" But", msg], &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
# def AndGiven(msg, &block)
|
48
|
+
# step("And Given #{msg}", &block)
|
49
|
+
# end
|
50
|
+
|
51
|
+
# def AndWhen(msg, &block)
|
52
|
+
# step(" And When #{msg}", &block)
|
53
|
+
# end
|
54
|
+
|
55
|
+
# def AndThen(msg, &block)
|
56
|
+
# step(" And Then #{msg}", &block)
|
57
|
+
# end
|
58
|
+
|
59
|
+
# def ButGiven(msg, &block)
|
60
|
+
# step("But Given #{msg}", &block)
|
61
|
+
# end
|
62
|
+
|
63
|
+
# def ButWhen(msg, &block)
|
64
|
+
# step(" But When #{msg}", &block)
|
65
|
+
# end
|
66
|
+
|
67
|
+
# def ButThen(msg, &block)
|
68
|
+
# step(" But Then #{msg}", &block)
|
69
|
+
# end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
module RSpec
|
74
|
+
module Core
|
75
|
+
module Formatters
|
76
|
+
# @private
|
77
|
+
class DocumentationFormatter < BaseTextFormatter
|
78
|
+
Formatters.register self
|
79
|
+
# , :example_group_started, :example_group_finished,
|
80
|
+
# :example_passed, :example_pending, :example_failed
|
81
|
+
|
82
|
+
def initialize(output)
|
83
|
+
super
|
84
|
+
@group_level = 0
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def example_started(notification)
|
89
|
+
notification.example.metadata[:step_messages] = []
|
90
|
+
end
|
91
|
+
|
92
|
+
def example_group_started(notification)
|
93
|
+
output.puts if @group_level == 0
|
94
|
+
output.puts "#{current_indentation}#{notification.group.description.strip}"
|
95
|
+
|
96
|
+
@group_level += 1
|
97
|
+
end
|
98
|
+
|
99
|
+
def example_group_finished(_notification)
|
100
|
+
@group_level -= 1
|
101
|
+
end
|
102
|
+
|
103
|
+
def example_passed(passed)
|
104
|
+
output.puts passed_output(passed.example)
|
105
|
+
output.puts read_steps(passed.example)
|
106
|
+
end
|
107
|
+
|
108
|
+
def example_pending(pending)
|
109
|
+
output.puts pending_output(pending.example,
|
110
|
+
pending.example.execution_result.pending_message)
|
111
|
+
output.puts read_steps(pending.example, :yellow)
|
112
|
+
end
|
113
|
+
|
114
|
+
def example_failed(failure)
|
115
|
+
output.puts failure_output(failure.example,
|
116
|
+
failure.example.execution_result.exception)
|
117
|
+
output.puts read_steps(failure.example, :red)
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
def read_steps(example, color2=nil)
|
123
|
+
last_step_title = ""
|
124
|
+
example.metadata[:step_messages].map do |hash|
|
125
|
+
msg = hash[:msg]
|
126
|
+
color = hash[:color] || color2 || :light_black
|
127
|
+
if msg.is_a? Array
|
128
|
+
msg0 = if msg[0] == last_step_title
|
129
|
+
blank_step_title
|
130
|
+
else
|
131
|
+
msg[0].light_white.bold
|
132
|
+
end
|
133
|
+
# msg0 = msg[0].white.bold
|
134
|
+
last_step_title = msg[0]
|
135
|
+
|
136
|
+
msg = [msg0, msg[1].colorize(color)].join(' ')
|
137
|
+
end
|
138
|
+
# light_black doesn't really get used because the test failure prevents other messages from being added
|
139
|
+
r = [next_indentation, msg]
|
140
|
+
r.join(' ')
|
141
|
+
# r = [next_indentation, "-".colorize(color), msg]
|
142
|
+
# r.join(' ').colorize(color)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def blank_step_title
|
147
|
+
" "
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
def next_failure_index
|
152
|
+
@next_failure_index ||= 0
|
153
|
+
@next_failure_index += 1
|
154
|
+
end
|
155
|
+
|
156
|
+
def current_indentation
|
157
|
+
' ' * @group_level
|
158
|
+
end
|
159
|
+
|
160
|
+
def next_indentation
|
161
|
+
' ' * (@group_level+1)
|
162
|
+
end
|
163
|
+
|
164
|
+
def example_group_chain
|
165
|
+
example_group.parent_groups.reverse
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
data/lib/bdd/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bdd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Pinto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-example_steps
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: Cucumber style in your RSpec tests
|
84
|
+
email:
|
85
|
+
- thejamespinto@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bdd.gemspec
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- lib/bdd.rb
|
100
|
+
- lib/bdd/rspec.rb
|
101
|
+
- lib/bdd/rspec/code.rb
|
102
|
+
- lib/bdd/version.rb
|
103
|
+
homepage: https://github.com/thejamespinto/bdd
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.5
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Cucumber style in your RSpec tests
|
126
|
+
test_files: []
|