rspex 0.0.5 → 0.0.6
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 +4 -4
- data/Gemfile +0 -6
- data/Guardfile +1 -1
- data/README.md +3 -2
- data/fake/gems/fakegem-1.0.0/spec/fake_spec.rb +7 -0
- data/lib/rspec_examples.rb +10 -8
- data/lib/rspex/version.rb +1 -1
- data/rspex.gemspec +4 -0
- data/spec/rspec_examples_spec.rb +26 -15
- metadata +70 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 327744f44a919fb6bf042f1d7d3704f896007919
|
4
|
+
data.tar.gz: f8477613717572833eab6171ec65febeb74225e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1bc9f91c502ffbacecd9d489406141d7fd25744003214cab6b8a5caf72e75be42971abcc67935d47f4c8638ed25a006686b6f7a8cf55980fed70d209a581506
|
7
|
+
data.tar.gz: 8b151c0f6db5db6dbe71d8f43cf0db8e81359351a58e0c694c8c0cbdaac6230a00b8db0e2928860ea78ece62abed4378e165fb18f76e1ec9f0e47a2207a7afb8
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard :rspec do
|
4
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
data/README.md
CHANGED
@@ -28,8 +28,9 @@ Learn how to writing spec in English from local gem's spec-files
|
|
28
28
|
## TODO
|
29
29
|
|
30
30
|
1. Must be Improve performance (It takes 15sec with loading 2500 spec files! )
|
31
|
-
2.
|
32
|
-
3.
|
31
|
+
2. Highlight search phrase
|
32
|
+
3. Make to configurable
|
33
|
+
4. Use Regular Expression
|
33
34
|
|
34
35
|
## Contributing
|
35
36
|
|
@@ -7,6 +7,13 @@ describe Fake do
|
|
7
7
|
expect(subject).to be_true
|
8
8
|
end
|
9
9
|
end
|
10
|
+
|
11
|
+
context "when arguments are valid" do
|
12
|
+
it "returns true" do
|
13
|
+
expect(subject).to be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
context "when params are invalid" do
|
11
18
|
it "returns false" do
|
12
19
|
expect(subject).to be_false
|
data/lib/rspec_examples.rb
CHANGED
@@ -19,27 +19,25 @@ end
|
|
19
19
|
|
20
20
|
|
21
21
|
class Example
|
22
|
-
attr_reader :path, :
|
22
|
+
attr_reader :path, :name, :describes, :contexts, :its, :results
|
23
23
|
|
24
24
|
def initialize path
|
25
25
|
raise ('argument must be path to spec file') unless valid?(path)
|
26
26
|
@path = path
|
27
|
-
@
|
27
|
+
@name = path.match(/^.*gems\/(.*)\/spec\//)[1]
|
28
28
|
@results = []
|
29
29
|
types = %w(describe context it)
|
30
30
|
types.each{|type| self.instance_variable_set("@#{type}s",[])}
|
31
31
|
|
32
|
-
|
32
|
+
open(path).read.each_line do |line|
|
33
33
|
types.each do |type|
|
34
|
-
|
34
|
+
if line =~ /.*#{type} .* do$/
|
35
|
+
set_example type, line.chomp.strip
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
def name
|
40
|
-
@path.match(/^.*gems\/(.*)\/spec\//)[1]
|
41
|
-
end
|
42
|
-
|
43
41
|
def matches word, type
|
44
42
|
if examples(type).any?
|
45
43
|
@results = examples(type).select{|example| example.include? word}
|
@@ -55,4 +53,8 @@ class Example
|
|
55
53
|
def valid?(path)
|
56
54
|
Pathname.new(path).exist? and path.include?('spec.rb')
|
57
55
|
end
|
56
|
+
|
57
|
+
def set_example type, sentence
|
58
|
+
examples(type) << sentence unless examples(type).include? sentence
|
59
|
+
end
|
58
60
|
end
|
data/lib/rspex/version.rb
CHANGED
data/rspex.gemspec
CHANGED
@@ -20,5 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3"
|
24
|
+
spec.add_development_dependency "guard-rspec"
|
25
|
+
spec.add_development_dependency "terminal-notifier-guard"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
23
27
|
spec.add_dependency 'thor'
|
24
28
|
end
|
data/spec/rspec_examples_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe RSpecExamples do
|
|
15
15
|
|
16
16
|
context "Success in Search" do
|
17
17
|
it { expect(@search.first.name).to eq "fakegem-1.0.0" }
|
18
|
-
it { expect(@search.first.results).to eq ["context \"when params are valid\" do", "context \"when params are invalid\" do"] }
|
18
|
+
it { expect(@search.first.results).to eq ["context \"when params are valid\" do", "context \"when arguments are valid\" do", "context \"when params are invalid\" do"] }
|
19
19
|
end
|
20
20
|
|
21
21
|
context "Fail in Search" do
|
@@ -33,12 +33,11 @@ describe Example do
|
|
33
33
|
|
34
34
|
describe '#attr_reader' do
|
35
35
|
context "with a valid path" do
|
36
|
-
it { expect(@example.
|
37
|
-
it { expect(@example.describes).to have(2).items }
|
36
|
+
it { expect(@example.describes.size).to eq(2) }
|
38
37
|
it { expect(@example.describes.first).to eq "describe Fake do" }
|
39
|
-
it { expect(@example.contexts).to
|
38
|
+
it { expect(@example.contexts.size).to eq(3) }
|
40
39
|
it { expect(@example.contexts.first).to eq "context \"when params are valid\" do" }
|
41
|
-
it { expect(@example.its).to
|
40
|
+
it { expect(@example.its.size).to eq(2) }
|
42
41
|
it { expect(@example.its.first).to eq "it \"returns true\" do" }
|
43
42
|
end
|
44
43
|
end
|
@@ -56,18 +55,30 @@ describe Example do
|
|
56
55
|
before do
|
57
56
|
@matches = @example.matches(word, type)
|
58
57
|
end
|
59
|
-
let(:type) { 'context' }
|
60
58
|
|
61
|
-
context
|
62
|
-
let(:
|
63
|
-
|
64
|
-
|
59
|
+
context 'When search from "context" sentences' do
|
60
|
+
let(:type) { 'context' }
|
61
|
+
|
62
|
+
context "Success in match the word" do
|
63
|
+
let(:word) { 'valid' }
|
64
|
+
it { expect(@matches.size).to eq(3) }
|
65
|
+
it { expect(@example.results).to eq ["context \"when params are valid\" do", "context \"when arguments are valid\" do", "context \"when params are invalid\" do"] }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "Fail in match the word" do
|
69
|
+
let(:word) { 'xxx' }
|
70
|
+
it { expect(@matches).to eq(false) }
|
71
|
+
it { expect(@example.results).to be_empty }
|
72
|
+
end
|
65
73
|
end
|
66
|
-
|
67
|
-
context
|
68
|
-
let(:
|
69
|
-
|
70
|
-
|
74
|
+
|
75
|
+
context 'When there are duplicated "it" sentences' do
|
76
|
+
let(:type) { 'it' }
|
77
|
+
let(:word) { 'true' }
|
78
|
+
|
79
|
+
it "should be ignore duplicated sentence" do
|
80
|
+
expect(@matches).to eq(["it \"returns true\" do"])
|
81
|
+
end
|
71
82
|
end
|
72
83
|
end
|
73
84
|
end
|
metadata
CHANGED
@@ -1,56 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daisuke Terada
|
8
|
-
-
|
8
|
+
- "@aq2bq"
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.3'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: guard-rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: terminal-notifier-guard
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: pry-byebug
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
40
96
|
- !ruby/object:Gem::Version
|
41
97
|
version: '0'
|
42
98
|
- !ruby/object:Gem::Dependency
|
43
99
|
name: thor
|
44
100
|
requirement: !ruby/object:Gem::Requirement
|
45
101
|
requirements:
|
46
|
-
- -
|
102
|
+
- - ">="
|
47
103
|
- !ruby/object:Gem::Version
|
48
104
|
version: '0'
|
49
105
|
type: :runtime
|
50
106
|
prerelease: false
|
51
107
|
version_requirements: !ruby/object:Gem::Requirement
|
52
108
|
requirements:
|
53
|
-
- -
|
109
|
+
- - ">="
|
54
110
|
- !ruby/object:Gem::Version
|
55
111
|
version: '0'
|
56
112
|
description: Learn how to writing spec in English from local gem's spec-files
|
@@ -61,8 +117,8 @@ executables:
|
|
61
117
|
extensions: []
|
62
118
|
extra_rdoc_files: []
|
63
119
|
files:
|
64
|
-
- .gitignore
|
65
|
-
- .rspec
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
66
122
|
- Gemfile
|
67
123
|
- Guardfile
|
68
124
|
- LICENSE.txt
|
@@ -86,17 +142,17 @@ require_paths:
|
|
86
142
|
- lib
|
87
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
144
|
requirements:
|
89
|
-
- -
|
145
|
+
- - ">="
|
90
146
|
- !ruby/object:Gem::Version
|
91
147
|
version: '0'
|
92
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
149
|
requirements:
|
94
|
-
- -
|
150
|
+
- - ">="
|
95
151
|
- !ruby/object:Gem::Version
|
96
152
|
version: '0'
|
97
153
|
requirements: []
|
98
154
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.2.2
|
100
156
|
signing_key:
|
101
157
|
specification_version: 4
|
102
158
|
summary: Learn how to writing spec in English from local gem's spec-files
|