specify 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51a6a40ea1a8835716239602449fa4b8feb22a8f
4
- data.tar.gz: c96cf0c60973e219a2546ec7ff04a5767392a855
3
+ metadata.gz: 3c481008f53c158790b8973606e46818aa144aa2
4
+ data.tar.gz: d1650d893f25b1c2a58084d1309d25f159df06d5
5
5
  SHA512:
6
- metadata.gz: 34052922c3cbc64d2fc96215996ce4b23f44c3abea5e2b9e6480322f2da1be17755e71d53198b29e75143b837bf23d54498aa6e31b5739e865e253bd69e27926
7
- data.tar.gz: c7df422b9314f06096b123549c949aaa1652580bcd28d1d6d6f6e198500ce494040734fa366399c5c06569bc1f288df50b8d4c24d7a3c26d7965ca54eef08e53
6
+ metadata.gz: 37b8be3fed44a9fea07ddf144bc20f80488ac04990d35176c3274467707fcc30bed0114d7bc28c4b79f823728df92f1680f08ecef1f53af6f6957c3b0f6656e0
7
+ data.tar.gz: ef72dc01b56e3deee8709ce44a0138f2f6a97b414a9a61c3a1832bf4879cee29357c1fe414ca15b1014a62bc551e411eb9d6a7ad25e972c5a17fc720ed2f9440
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'simplecov', '~> 0.9.0', require: false
4
+ gem 'coveralls', require: false
4
5
 
5
6
  # Specify your gem's dependencies in specify.gemspec
6
7
  gemspec
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Codeship Status for jnyman/specify](https://www.codeship.io/projects/6fd98900-39d1-0132-7358-4e57ec3927cd/status)](https://www.codeship.io/projects/42264)
4
4
 
5
+ [![Coverage Status](https://img.shields.io/coveralls/jnyman/specify.svg)](https://coveralls.io/r/jnyman/specify?branch=master)
5
6
  [![Gem Version](https://badge.fury.io/rb/specify.svg)](http://badge.fury.io/rb/specify)
6
7
  [![Dependency Status](https://gemnasium.com/jnyman/specify.svg)](https://gemnasium.com/jnyman/specify)
7
8
  [![Code Climate](https://codeclimate.com/github/jnyman/specify/badges/gpa.svg)](https://codeclimate.com/github/jnyman/specify)
@@ -1,6 +1,14 @@
1
1
  module RSpec
2
2
  module Specify
3
3
  module ExampleGroup
4
+
5
+ # In Rspec, example group bodies are delimited by 'describe' and
6
+ # 'context' methods. These encapsulate examples, which are
7
+ # delimited by 'it' methods. Example groups are evaluated in the
8
+ # context of an ExampleGroup instance. Individual examples are
9
+ # evaluated in the context of an instance of the ExampleGroup
10
+ # to which they belong.
11
+
4
12
  def include_steps(*args)
5
13
  name = args.shift
6
14
  shared_block = ::RSpec.world.shared_example_steps[name]
@@ -9,27 +17,46 @@ module RSpec
9
17
  end
10
18
 
11
19
  def Given(message, options={}, &block)
12
- RSpec.world.reporter.process_example_step(self, :given, message, options, &block)
20
+ Step :given, message, options, &block
13
21
  end
14
22
 
15
23
  def When(message, options={}, &block)
16
- RSpec.world.reporter.process_example_step(self, :when, message, options, &block)
24
+ Step :when, message, options, &block
17
25
  end
18
26
 
19
27
  def Then(message, options={}, &block)
20
- RSpec.world.reporter.process_example_step(self, :then, message, options, &block)
28
+ Step :then, message, options, &block
21
29
  end
22
30
 
23
31
  def And(message, options = {}, &block)
24
- RSpec.world.reporter.process_example_step(self, :and, message, options, &block)
32
+ Step :and, message, options, &block
25
33
  end
26
34
 
27
35
  def But(message, options = {}, &block)
28
- RSpec.world.reporter.process_example_step(self, :but, message, options, &block)
36
+ Step :but, message, options, &block
29
37
  end
30
38
 
31
39
  def _(message, options = {}, &block)
32
- RSpec.world.reporter.process_example_step(self, :_, message, options, &block)
40
+ Step :_, message, options, &block
41
+ end
42
+
43
+ private
44
+
45
+ def Step(type, message, options = {}, &block)
46
+ ::RSpec.world.reporter.example_step_started(self, type, message, options)
47
+
48
+ if block_given? && !options[:pending]
49
+ begin
50
+ yield
51
+ rescue Exception => e
52
+ ::RSpec.world.reporter.example_step_failed(self, type, message, options)
53
+ raise e
54
+ end
55
+ ::RSpec.world.reporter.example_step_passed(self, type, message, options)
56
+ else
57
+ ::RSpec.world.reporter.example_step_pending(self, type, message, options)
58
+ end
59
+
33
60
  end
34
61
  end
35
62
  end
@@ -1,5 +1,8 @@
1
1
  module RSpec
2
2
  module Specify
3
+
4
+ # In RSpec, notifications are value objects that are passed to formatters
5
+ # to provide those formatters with information about a particular event.
3
6
  class Notification < Struct.new(:example, :type, :message, :options)
4
7
  end
5
8
  end
@@ -1,21 +1,9 @@
1
1
  module RSpec
2
2
  module Specify
3
3
  module Reporter
4
- def process_example_step(example, type, message, options)
5
- example_step_started(self, type, message, options)
6
4
 
7
- if block_given? && !options[:pending]
8
- begin
9
- yield
10
- rescue Exception => e
11
- example_step_failed(self, type, message, options)
12
- raise e
13
- end
14
- example_step_passed(self, type, message, options)
15
- else
16
- example_step_pending(self, type, message, options)
17
- end
18
- end
5
+ # An RSpec reporter sends notifications to listeners. The listeners
6
+ # are usually formatters for a specific test run.
19
7
 
20
8
  def example_step_started(example, type, message, options)
21
9
  notify :example_step_started, Notification.new(example, type, message, options)
@@ -1,6 +1,10 @@
1
1
  module RSpec
2
2
  module Specify
3
3
  module World
4
+
5
+ # RSpec's world is an internal container for global
6
+ # non-configuration data.
7
+
4
8
  def shared_example_steps
5
9
  @shared_example_steps ||= {}
6
10
  end
@@ -0,0 +1,19 @@
1
+ module Specify
2
+ module Spec
3
+ def self.included(base)
4
+ base.instance_eval do
5
+ alias :Background :before
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ def self.Feature(*args, &block)
12
+ describe(*args, &block)
13
+ end
14
+
15
+ def self.Ability(*args, &block)
16
+ describe(*args, &block)
17
+ end
18
+
19
+ RSpec.configuration.include Specify::Spec
@@ -1,3 +1,3 @@
1
1
  module Specify
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/specify.rb CHANGED
@@ -11,6 +11,7 @@ require 'rspec/core/formatters'
11
11
  require 'rspec/core/formatters/console_codes'
12
12
  require 'rspec/core/formatters/documentation_formatter'
13
13
 
14
+ require 'specify/spec'
14
15
  require 'specify/rspec/example_group'
15
16
  require 'specify/rspec/notification'
16
17
  require 'specify/rspec/reporter'
@@ -30,7 +30,19 @@ shared_steps 'pull steps' do
30
30
  end
31
31
  end
32
32
 
33
- describe 'shared steps' do
33
+ context 'duplicate shared steps' do
34
+ it 'will raise an error' do
35
+ expect {
36
+ shared_steps 'duplicate' do
37
+ end
38
+
39
+ shared_steps 'duplicate' do
40
+ end
41
+ }.to raise_error
42
+ end
43
+ end
44
+
45
+ Feature 'shared steps' do
34
46
  let(:pipe) do
35
47
  Class.new do
36
48
  def initialize
@@ -55,22 +67,26 @@ describe 'shared steps' do
55
67
  end.new
56
68
  end
57
69
 
58
- steps 'push and pull steps' do
70
+ Scenario 'push and pull steps' do
59
71
  include_steps 'push steps'
60
72
  include_steps 'pull steps'
61
73
  end
62
74
 
63
- steps 'push, count and pull' do
75
+ Scenario 'push, count and pull' do
64
76
  include_steps 'push steps'
77
+
65
78
  Then 'pipe should have one item' do
66
79
  expect(pipe.items.size).to eq(1)
67
80
  end
81
+
68
82
  include_steps 'pull steps'
69
83
  end
70
84
 
71
- steps 'push with arguments and pull' do
72
- include_steps 'push with argument steps', 'testing'
73
- expect(pipe.items).to eq(['testing'])
85
+ Scenario 'push with arguments and pull' do
86
+ include_steps 'push with argument steps', 'specify'
87
+
88
+ expect(pipe.items).to eq(['specify'])
89
+
74
90
  include_steps 'pull steps'
75
91
  end
76
92
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  require 'simplecov'
2
+ require 'coveralls'
2
3
 
3
- SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
4
+ Coveralls.wear!
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
4
10
 
5
11
  SimpleCov.start do
6
12
  add_filter '/spec/'
data/spec/steps_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'specify steps' do
3
+ Ability 'specify steps' do
4
4
  describe 'Given/When/Then' do
5
5
  steps 'should execute blocks' do
6
6
  Given 'context' do
@@ -41,6 +41,19 @@ describe 'specify steps' do
41
41
  Given 'step without block'
42
42
  When 'step without block'
43
43
  Then 'step without block'
44
+
45
+ Given 'step without block and tag', pending: true
46
+ Given 'step without block and message', pending: 'wip'
47
+ end
48
+ end
49
+
50
+ describe 'Failing steps' do
51
+ steps 'will fail' do
52
+ expect {
53
+ _ 'expectation alerts failure' do
54
+ expect(2 + 2).to eq 5
55
+ end
56
+ }.to raise_error
44
57
  end
45
58
  end
46
59
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Nyman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-19 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,6 +88,7 @@ files:
88
88
  - lib/specify/rspec/reporter.rb
89
89
  - lib/specify/rspec/shared_steps.rb
90
90
  - lib/specify/rspec/world.rb
91
+ - lib/specify/spec.rb
91
92
  - lib/specify/version.rb
92
93
  - spec/shared_steps_spec.rb
93
94
  - spec/spec_helper.rb
@@ -98,7 +99,7 @@ licenses:
98
99
  - MIT
99
100
  metadata: {}
100
101
  post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n
101
- \ Specify 0.2.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
102
+ \ Specify 0.3.0 has been installed.\n\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
102
103
  (::) (::) (::)\n "
103
104
  rdoc_options: []
104
105
  require_paths: