rspec-english 0.0.1
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 +7 -0
- data/LICENSE +19 -0
- data/README.md +43 -0
- data/lib/rspec-english.rb +49 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7002859a5f733bdd08c4319c7adeb21a158694a1
|
4
|
+
data.tar.gz: 824d6ffa35c6a37903e6b15172ebbf4d87dafd60
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d16df6942437d70d62a0475ebf87f9c9afb7b57c2fa9ffdc675038bb26e186d61210dc54471f7c198ef2938b87bf4103a94600c40f255d71066696c2377c924c
|
7
|
+
data.tar.gz: 39709c7528ff68184c24043b187e590e6c46fdd764441353522b55eb2dad7efa19c4b6b90c60972eb8b24d614d40253ebcd0c6929a796ec3be65ece8822327bb
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Matthew Lanigan <rintaun@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# rspec-english
|
2
|
+
Better English for RSpec descriptions
|
3
|
+
|
4
|
+
## Description
|
5
|
+
rspec-english aims to modify how RSpec builds descriptions of specs/tests in
|
6
|
+
order to make them read like more natural English.
|
7
|
+
|
8
|
+
Specifically, `context` example groupings are modified to be placed _after_
|
9
|
+
the test description in the full description output, such that the following
|
10
|
+
code would read "RSpec outputs real English when rspec-english is available":
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
describe RSpec do
|
14
|
+
context 'when rspec-english is available' do
|
15
|
+
it 'outputs real English' do
|
16
|
+
RSpec.english.should be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Motivation
|
24
|
+
RSpec `context` groups are usually adverbial clauses, e.g. 'with ...' or 'when
|
25
|
+
...'. Following RSpec's standard description generation, these are placed
|
26
|
+
directly after the subject of the sentence (i.e. the description of the
|
27
|
+
preceeding `describe` groups). However, in standard English, these clauses are
|
28
|
+
nearly always placed either at the *beginning* of the sentence, if emphasis is
|
29
|
+
desired, or, more commonly, at the *end* of the sentence.
|
30
|
+
|
31
|
+
## Known Defects
|
32
|
+
1. Currently `describe` blocks nested within a `context` are still placed
|
33
|
+
before the test description. I have not yet decided if this is desirable or
|
34
|
+
not.
|
35
|
+
2. It is possible for some nested contexts to come out still reading as
|
36
|
+
less-than-standard English. They are normally ordered as _manner_, _place_,
|
37
|
+
and then _time_, but the string will be generated in order of nesting, not
|
38
|
+
in their natural English order.
|
39
|
+
|
40
|
+
## Future
|
41
|
+
I would like to rewrite this so that it takes into account a rudimentary model
|
42
|
+
of a normal English sentence, in order to fix defect 2, above. Other
|
43
|
+
suggestions are, of course, welcome.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rspec/core/example_group'
|
2
|
+
require 'rspec/core/metadata'
|
3
|
+
require 'rspec/core/formatters/progress_formatter'
|
4
|
+
module ::RSpec
|
5
|
+
def english; true end
|
6
|
+
module Core
|
7
|
+
class ExampleGroup
|
8
|
+
def self.context(*args, &example_group_block)
|
9
|
+
o = self.describe *args, &example_group_block
|
10
|
+
o.metadata[:example_group][:type] = :context
|
11
|
+
o
|
12
|
+
end
|
13
|
+
end
|
14
|
+
class Metadata < Hash
|
15
|
+
module GroupMetadataHash
|
16
|
+
def full_description
|
17
|
+
desc_parts = container_stack.reverse.collect { |a|
|
18
|
+
this_part = a[:description_args]
|
19
|
+
this_part = this_part.join(' ')
|
20
|
+
if a[:type] == :context
|
21
|
+
def this_part.after?; end
|
22
|
+
end
|
23
|
+
this_part
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
module MetadataHash
|
28
|
+
def build_description_from(context, *parts)
|
29
|
+
front = []
|
30
|
+
if context.is_a?(Array)
|
31
|
+
context.each do |this_part|
|
32
|
+
if this_part.respond_to? :after?
|
33
|
+
parts.push this_part
|
34
|
+
else
|
35
|
+
front.push this_part
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
parts.unshift context
|
40
|
+
end
|
41
|
+
front.reverse.each do |part|
|
42
|
+
parts.unshift part
|
43
|
+
end
|
44
|
+
parts.join(' ')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-english
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matthew Lanigan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.13.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.13.1
|
27
|
+
description: |2
|
28
|
+
Modifies RSpec's description generator to produce more
|
29
|
+
natural-sounding English.
|
30
|
+
email: rintaun@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.md
|
35
|
+
files:
|
36
|
+
- lib/rspec-english.rb
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
homepage: https://github.com/rintaun/rspec-english
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.0.0.rc.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Better English for RSpec descriptions
|
64
|
+
test_files: []
|