proverbs 0.1.0 → 0.2.0

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: 5e9a8eac26fbc73b47d7eeef6f7eeec9dad5c276
4
- data.tar.gz: ee01be7d32988cf29517920342ccf3d67d3226a8
3
+ metadata.gz: b993f96f749a9378b7b3e6af864002b4c6aa5f10
4
+ data.tar.gz: 2dbca7a6c81f52a8f30c4b0b69bf7039659a8bfe
5
5
  SHA512:
6
- metadata.gz: 7b34b3b3212d64609d476cc9a675e8d4fd2777cb068e06ccc35a6d02fd8734d0d4691b983890f2e6938b9aa844c3aa7f1def128517b863a3bf06236826dae547
7
- data.tar.gz: 9ec480382465b2da380005ec0ed9b6032e11d7caad4a193c5faba295dd424df2a7948451fd94fb5c7c1e82f23171c1223a864b15fb8214466fe12648020a4f37
6
+ metadata.gz: 8f2eda0cccd87f5d2de1d09391e5cea43122730d4776c0118e6a71e57c439c3afefde4a8ab1faeefea3d594372b68a98cee14fc562e3694ecf42089a6a85842c
7
+ data.tar.gz: 5b66f27525a208377f014e5671ec82c0e6454b7b613962caf89d9336d5f96d7bf7aa1aafb4afd46c4aa88fc211706f6226227370ace8efc16da00cd9e206842c
data/.hound.yml CHANGED
@@ -67,6 +67,12 @@ Metrics/ParameterLists:
67
67
  Metrics/LineLength:
68
68
  Enabled: false
69
69
 
70
+ # Changing this due to how Proverbs ties in with RSpec and my
71
+ # desire not to break apart functionality that does in fact
72
+ # belong together.
73
+ Metrics/AbcSize:
74
+ Max: 22
75
+
70
76
  # This is necessary in order to allow the method names to have
71
77
  # uppercase, in order to match Gherkin.
72
78
  Style/MethodName:
data/README.md CHANGED
@@ -1,11 +1,24 @@
1
1
  # Proverbs
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/proverbs.svg)](http://badge.fury.io/rb/proverbs)
4
+ [![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jeffnyman/data_builder/blob/master/LICENSE.txt)
5
+
6
+ [![Dependency Status](https://gemnasium.com/jeffnyman/proverbs.png)](https://gemnasium.com/jeffnyman/proverbs)
7
+
3
8
  > _Let not mercy and truth forsake thee: bind them about thy neck;
4
9
  > write them upon the table of thine heart._
5
10
  >
6
11
  >     **Proverbs 3:3**
7
12
 
13
+ A proverb is basically a simple and concrete saying. The idea is that it expresses a truth based on common sense or experience. Here I'm simply extending that idea to apply to how tools like RSpec use simple, concrete sayings -- in a particular context -- to express a truth. The "truth" in this case is the observable of a test.
14
+
15
+ Proverbs provides a very thin wrapper around RSpec that provides for more syntax possibilities and thus allows different modes of expression.
8
16
 
17
+ More specifically, Proverbs provides an internal DSL, similar to the [RSpec Story Runner](https://github.com/dchelimsky/rspec-stories), which was the predecessor of the [Cucumber](http://cukes.info/) external DSL provided by [Gherkin](http://cukes.info/gherkin.html). A goal of many of these tools is to put an emphasis on communication and they do so by making it somewhat easy to encode that communication as expressions. Tools like Cucumber focus on allowing communication via a description language that is structured by Gherkin keywords.
18
+
19
+ However, while the ideas behind Gherkin are viable, tools like Cucumber abstract away the nuts and bolts of your tests. Abstraction can be a good thing but Cucumber gives you no choice in the matter. It hides code blocks behind a "call by regular expression" invocation mechanism instead of making those code blocks readily available in the test description.
20
+
21
+ Proverbs lets you write as much logic beside your specifications as you want by leveraging the RSpec ecosystem with the addition of a Gherkin-like syntax. Beyond that, the syntax is not just limited to Gherkin.
9
22
 
10
23
  ## Installation
11
24
 
@@ -31,7 +44,13 @@ You can also install Tapestry just as you would any other gem:
31
44
 
32
45
  ## Usage
33
46
 
34
- TODO: Write usage instructions here
47
+ To use Proverbs you simply have to require it within your `spec_helper` file:
48
+
49
+ ```ruby
50
+ require 'proverbs'
51
+ ```
52
+
53
+ You can then use the DSL that Proverbs provides to structure your tests. Once you've done that, then you simply run your `rspec` command as normal against your test suite.
35
54
 
36
55
  ## Development
37
56
 
@@ -55,6 +74,17 @@ To contribute to Proverbs:
55
74
 
56
75
  * [Jeff Nyman](http://testerstories.com)
57
76
 
77
+ ## Credits
78
+
79
+ Proverbs has been inspired by the following projects:
80
+
81
+ * [maniok_bdd](https://github.com/21croissants/maniok_bdd)
82
+ * [rspec-gherkin](https://github.com/sheerun/rspec-gherkin)
83
+ * [rspec example steps](https://github.com/railsware/rspec-example_steps)
84
+ * [rspec-steps](https://github.com/LRDesign/rspec-steps)
85
+ * [rspec-given](https://github.com/jimweirich/rspec-given)
86
+ * [XSpec](https://github.com/xaviershay/xspec)
87
+
58
88
  ## License
59
89
 
60
90
  Proverbs is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
data/lib/proverbs.rb CHANGED
@@ -7,6 +7,7 @@ require "rspec/core/formatters/console_codes"
7
7
  require "rspec/core/formatters/documentation_formatter"
8
8
 
9
9
  require "proverbs/version"
10
+ require "proverbs/contexts"
10
11
  require "proverbs/rspec/world"
11
12
  require "proverbs/rspec/reporter"
12
13
  require "proverbs/rspec/notification"
@@ -19,19 +20,25 @@ RSpec::Core::World.send :include, RSpec::Proverbs::World
19
20
 
20
21
  RSpec::Core::Formatters::DocumentationFormatter.send :include, RSpec::Proverbs::DocumentationFormatter
21
22
 
22
- # This one is from rspec-examples
23
- ## RSpec::Core::ExampleGroup.define_example_method :Steps, with_steps: true
23
+ RSpec::Core::ExampleGroup.define_example_method :Scenario, with_steps: true
24
+ RSpec::Core::ExampleGroup.define_example_method :Behavior, with_steps: true
24
25
 
25
- RSpec::Core::ExampleGroup.define_example_method :Scenario, with_steps: true
26
+ RSpec::Core::ExampleGroup.define_example_method :steps, with_steps: true
27
+ RSpec::Core::ExampleGroup.define_example_method :rules, with_steps: true
28
+ RSpec::Core::ExampleGroup.define_example_method :tests, with_steps: true
29
+ RSpec::Core::ExampleGroup.define_example_method :facts, with_steps: true
26
30
 
27
31
  formatter = RSpec.world.reporter.find_registered_formatter(RSpec::Core::Formatters::DocumentationFormatter)
28
- RSpec.world.reporter.register_listener(
29
- formatter,
30
- :example_started,
31
- :example_step_passed,
32
- :example_step_pending,
33
- :example_step_failed
34
- ) if formatter
32
+
33
+ if formatter
34
+ RSpec.world.reporter.register_listener(
35
+ formatter,
36
+ :example_started,
37
+ :example_step_passed,
38
+ :example_step_pending,
39
+ :example_step_failed
40
+ )
41
+ end
35
42
 
36
43
  require "proverbs/rspec/shared_steps"
37
44
  include RSpec::Proverbs::SharedSteps
@@ -0,0 +1,39 @@
1
+ module Proverbs
2
+ module Contexts
3
+ def self.included(caller)
4
+ caller.instance_eval do
5
+ alias :Background :before
6
+ alias :Setup :before
7
+ alias :Teardown :after
8
+
9
+ alias :Feature :context
10
+ alias :Ability :context
11
+ alias :Story :context
12
+ alias :Workflow :context
13
+ alias :Component :context
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.Feature(*args, &block)
20
+ describe(*args, &block)
21
+ end
22
+
23
+ def self.Ability(*args, &block)
24
+ describe(*args, &block)
25
+ end
26
+
27
+ def self.Story(*args, &block)
28
+ describe(*args, &block)
29
+ end
30
+
31
+ def self.Component(*args, &block)
32
+ describe(*args, &block)
33
+ end
34
+
35
+ def self.Workflow(*args, &block)
36
+ describe(*args, &block)
37
+ end
38
+
39
+ RSpec.configuration.include Proverbs::Contexts
@@ -45,11 +45,10 @@ module RSpec
45
45
  full_message = "#{current_indentation} #{keyword.capitalize} #{notification.message}" unless no_keyword_display.include?(keyword)
46
46
  full_message = "#{current_indentation} #{notification.message}" if no_keyword_display.include?(keyword)
47
47
 
48
- if notification.options[:pending] && notification.options[:pending] != true
49
- full_message << " (PENDING: #{notification.options[:pending]})"
50
- else
51
- full_message << ' (PENDING)'
52
- end
48
+ pending_check = notification.options[:pending] && notification.options[:pending]
49
+
50
+ full_message << " (PENDING: #{notification.options[:pending]})" unless pending_check
51
+ full_message << ' (PENDING)' if pending_check
53
52
 
54
53
  output.puts Core::Formatters::ConsoleCodes.wrap(full_message, :pending)
55
54
  end
@@ -35,6 +35,34 @@ module RSpec
35
35
  action :but, message, options, &block
36
36
  end
37
37
 
38
+ def rule(message, options = {}, &block)
39
+ action :rule, message, options, &block
40
+ end
41
+
42
+ def fact(message, options = {}, &block)
43
+ action :fact, message, options, &block
44
+ end
45
+
46
+ def test(message, options = {}, &block)
47
+ action :test, message, options, &block
48
+ end
49
+
50
+ def step(message, options = {}, &block)
51
+ action :step, message, options, &block
52
+ end
53
+
54
+ def it(message, options = {}, &block)
55
+ action :it, message, options, &block
56
+ end
57
+
58
+ def specify(message, options = {}, &block)
59
+ action :specify, message, options, &block
60
+ end
61
+
62
+ def example(message, options = {}, &block)
63
+ action :example, message, options, &block
64
+ end
65
+
38
66
  private
39
67
 
40
68
  def action(type, message, options = {}, &_block)
@@ -44,7 +72,7 @@ module RSpec
44
72
  if block_given? && !options[:pending]
45
73
  begin
46
74
  yield
47
- rescue Exception => e
75
+ rescue StandardError => e
48
76
  ::RSpec.world.reporter.example_step_failed(self, type, message, options)
49
77
  raise e
50
78
  end
@@ -1,3 +1,3 @@
1
1
  module Proverbs
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proverbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Nyman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-25 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - bin/console
121
121
  - bin/setup
122
122
  - lib/proverbs.rb
123
+ - lib/proverbs/contexts.rb
123
124
  - lib/proverbs/rspec/documentation_formatter.rb
124
125
  - lib/proverbs/rspec/example_group.rb
125
126
  - lib/proverbs/rspec/notification.rb
@@ -133,7 +134,7 @@ licenses:
133
134
  - MIT
134
135
  metadata: {}
135
136
  post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
136
- \ Proverbs 0.1.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
137
+ \ Proverbs 0.2.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
137
138
  (::) (::) (::)\n "
138
139
  rdoc_options: []
139
140
  require_paths: