rspec-english 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -5
- data/lib/rspec-english.rb +14 -24
- metadata +12 -9
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -11,18 +11,17 @@ code would read "RSpec outputs real English when rspec-english is available":
|
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
describe RSpec do
|
14
|
-
context '
|
14
|
+
context 'WHen rspec-english is available' do
|
15
15
|
it 'outputs real English' do
|
16
16
|
RSpec.english.should be_true
|
17
|
-
end
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
21
20
|
```
|
22
21
|
|
23
22
|
## Motivation
|
24
|
-
RSpec `context` groups are usually adverbial clauses, e.g.
|
25
|
-
...
|
23
|
+
RSpec `context` groups are usually adverbial clauses, e.g. "with ..." or "when
|
24
|
+
...". Following RSpec's standard description generation, these are placed
|
26
25
|
directly after the subject of the sentence (i.e. the description of the
|
27
26
|
preceeding `describe` groups). However, in standard English, these clauses are
|
28
27
|
nearly always placed either at the *beginning* of the sentence, if emphasis is
|
@@ -37,7 +36,20 @@ desired, or, more commonly, at the *end* of the sentence.
|
|
37
36
|
and then _time_, but the string will be generated in order of nesting, not
|
38
37
|
in their natural English order.
|
39
38
|
|
39
|
+
## Compatibility
|
40
|
+
I've only tested this with rspec-core 2.13.1, but I see no reason why it
|
41
|
+
wouldn't work with earlier versions as well. I've set a runtime dependency for
|
42
|
+
`~> 2.13.1`, but I'd be glad to update it if you let me know an earlier
|
43
|
+
version works.
|
44
|
+
|
40
45
|
## Future
|
41
46
|
I would like to rewrite this so that it takes into account a rudimentary model
|
42
47
|
of a normal English sentence, in order to fix defect 2, above. Other
|
43
|
-
suggestions are, of course, welcome.
|
48
|
+
suggestions are, of course, welcome. One benefit of doing it this way is that
|
49
|
+
it will obsolete the modification to `RSpec::Core.context` and will slim down
|
50
|
+
some of the other modifications a bit.
|
51
|
+
|
52
|
+
In addition, I would like to eventually modify descriptions and join them with
|
53
|
+
conjunctions where possible, e.g. turning "when one thing when another thing"
|
54
|
+
into something more readable like "when one thing and another thing." Ideally,
|
55
|
+
this can be done without requiring any modification to tests.
|
data/lib/rspec-english.rb
CHANGED
@@ -14,34 +14,24 @@ module ::RSpec
|
|
14
14
|
class Metadata < Hash
|
15
15
|
module GroupMetadataHash
|
16
16
|
def full_description
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
17
|
+
front = []
|
18
|
+
back = []
|
19
|
+
container_stack.reverse.each do |part|
|
20
|
+
target = part[:type] == :context ? back : front
|
21
|
+
target.push part[:description_args]
|
22
|
+
end
|
23
|
+
[front, back].map {|s| [do_build_description(*s.flatten)] }
|
25
24
|
end
|
26
25
|
end
|
27
26
|
module MetadataHash
|
27
|
+
alias_method :do_build_description, :build_description_from
|
28
|
+
|
28
29
|
def build_description_from(context, *parts)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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(' ')
|
30
|
+
context = [[context], [""]] unless context.is_a? Array
|
31
|
+
front, back = context
|
32
|
+
parts = front + parts + back
|
33
|
+
parts.delete_if(&:empty?)
|
34
|
+
do_build_description parts.shift, *parts
|
45
35
|
end
|
46
36
|
end
|
47
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-english
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Matthew Lanigan
|
@@ -13,6 +14,7 @@ dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rspec-core
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,13 +22,13 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 2.13.1
|
27
|
-
description:
|
28
|
-
|
29
|
-
natural-sounding English.
|
30
|
+
description: ! " Modifies RSpec's description generator to produce more\n natural-sounding
|
31
|
+
English.\n"
|
30
32
|
email: rintaun@gmail.com
|
31
33
|
executables: []
|
32
34
|
extensions: []
|
@@ -39,26 +41,27 @@ files:
|
|
39
41
|
homepage: https://github.com/rintaun/rspec-english
|
40
42
|
licenses:
|
41
43
|
- MIT
|
42
|
-
metadata: {}
|
43
44
|
post_install_message:
|
44
45
|
rdoc_options:
|
45
46
|
- --charset=UTF-8
|
46
47
|
require_paths:
|
47
48
|
- lib
|
48
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
49
51
|
requirements:
|
50
|
-
- - '>='
|
52
|
+
- - ! '>='
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: '0'
|
53
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
54
57
|
requirements:
|
55
|
-
- - '>='
|
58
|
+
- - ! '>='
|
56
59
|
- !ruby/object:Gem::Version
|
57
60
|
version: '0'
|
58
61
|
requirements: []
|
59
62
|
rubyforge_project:
|
60
|
-
rubygems_version:
|
63
|
+
rubygems_version: 1.8.25
|
61
64
|
signing_key:
|
62
|
-
specification_version:
|
65
|
+
specification_version: 3
|
63
66
|
summary: Better English for RSpec descriptions
|
64
67
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 7002859a5f733bdd08c4319c7adeb21a158694a1
|
4
|
-
data.tar.gz: 824d6ffa35c6a37903e6b15172ebbf4d87dafd60
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: d16df6942437d70d62a0475ebf87f9c9afb7b57c2fa9ffdc675038bb26e186d61210dc54471f7c198ef2938b87bf4103a94600c40f255d71066696c2377c924c
|
7
|
-
data.tar.gz: 39709c7528ff68184c24043b187e590e6c46fdd764441353522b55eb2dad7efa19c4b6b90c60972eb8b24d614d40253ebcd0c6929a796ec3be65ece8822327bb
|