transpec 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +9 -0
- data/Guardfile +4 -0
- data/README.md +102 -5
- data/README.md.erb +107 -0
- data/Rakefile +26 -5
- data/bin/transpec +1 -1
- data/lib/transpec/ast/scanner.rb +3 -0
- data/lib/transpec/ast/scope_stack.rb +2 -0
- data/lib/transpec/cli.rb +4 -0
- data/lib/transpec/rewriter.rb +14 -2
- data/lib/transpec/syntax.rb +36 -1
- data/lib/transpec/syntax/any_instanceable.rb +24 -0
- data/lib/transpec/syntax/be_close.rb +32 -0
- data/lib/transpec/syntax/double.rb +14 -8
- data/lib/transpec/syntax/expectizable.rb +20 -0
- data/lib/transpec/syntax/matcher.rb +16 -8
- data/lib/transpec/syntax/method_stub.rb +26 -40
- data/lib/transpec/syntax/send_node_syntax.rb +2 -4
- data/lib/transpec/syntax/should.rb +25 -16
- data/lib/transpec/syntax/should_receive.rb +32 -35
- data/lib/transpec/version.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/support/shared_context.rb +4 -0
- data/spec/transpec/ast/scanner_spec.rb +1 -1
- data/spec/transpec/ast/scope_stack_spec.rb +1 -0
- data/spec/transpec/cli_spec.rb +1 -0
- data/spec/transpec/configuration_spec.rb +1 -0
- data/spec/transpec/git_spec.rb +8 -0
- data/spec/transpec/rewriter_spec.rb +30 -0
- data/spec/transpec/syntax/be_close_spec.rb +50 -0
- data/spec/transpec/syntax/double_spec.rb +3 -2
- data/spec/transpec/syntax/matcher_spec.rb +1 -0
- data/spec/transpec/syntax/method_stub_spec.rb +1 -0
- data/spec/transpec/syntax/should_receive_spec.rb +1 -0
- data/spec/transpec/syntax/should_spec.rb +1 -0
- data/spec/transpec/util_spec.rb +1 -0
- data/transpec.gemspec +1 -0
- metadata +23 -3
- data/lib/transpec.rb +0 -17
data/lib/transpec/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
+
# Yes, I'm writing specs in should syntax intentionally!
|
4
5
|
config.expect_with :rspec do |c|
|
5
|
-
|
6
|
+
c.syntax = :should
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |c|
|
6
10
|
c.syntax = :should
|
7
11
|
end
|
8
12
|
|
@@ -10,10 +14,6 @@ RSpec.configure do |config|
|
|
10
14
|
config.filter_run_excluding do_not_run_in_transpeced_spec: ENV['TRANSPECED_SPEC']
|
11
15
|
end
|
12
16
|
|
13
|
-
Dir[File.join(File.dirname(__FILE__), 'support', '*')].each do |path|
|
14
|
-
require path
|
15
|
-
end
|
16
|
-
|
17
17
|
require 'simplecov'
|
18
18
|
SimpleCov.coverage_dir(File.join('spec', 'coverage'))
|
19
19
|
|
@@ -30,4 +30,6 @@ SimpleCov.start do
|
|
30
30
|
add_filter '/vendor/bundle/'
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '*')].each do |path|
|
34
|
+
require path
|
35
|
+
end
|
data/spec/transpec/cli_spec.rb
CHANGED
data/spec/transpec/git_spec.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'transpec/git'
|
4
5
|
|
5
6
|
module Transpec
|
6
7
|
describe Git do
|
7
8
|
include_context 'isolated environment'
|
8
9
|
|
10
|
+
if ENV['TRAVIS']
|
11
|
+
before do
|
12
|
+
system('git config --global user.email "you@example.com"')
|
13
|
+
system('git config --global user.name "Your Name"')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
describe '.command_available?' do
|
10
18
|
subject { Git.command_available? }
|
11
19
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'transpec/rewriter'
|
4
5
|
|
5
6
|
module Transpec
|
6
7
|
describe Rewriter do
|
@@ -34,6 +35,7 @@ module Transpec
|
|
34
35
|
something.stub!(:message)
|
35
36
|
something.should_receive(:message)
|
36
37
|
something.should_not == 'foo'
|
38
|
+
expect(1.0 / 3.0).to be_close(0.333, 0.001)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
END
|
@@ -137,6 +139,34 @@ module Transpec
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
142
|
+
context 'when the configuration #replace_deprecated_method? is true' do
|
143
|
+
before { configuration.replace_deprecated_method = true }
|
144
|
+
|
145
|
+
it 'invokes Double#convert_to_double!' do
|
146
|
+
Syntax::Double.any_instance.should_receive(:convert_to_double!)
|
147
|
+
rewriter.rewrite(source)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'invokes BeClose#convert_to_be_within!' do
|
151
|
+
Syntax::BeClose.any_instance.should_receive(:convert_to_be_within!)
|
152
|
+
rewriter.rewrite(source)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'when the configuration #replace_deprecated_method? is true' do
|
157
|
+
before { configuration.replace_deprecated_method = false }
|
158
|
+
|
159
|
+
it 'does not invoke Double#convert_to_double!' do
|
160
|
+
Syntax::Double.any_instance.should_not_receive(:convert_to_double!)
|
161
|
+
rewriter.rewrite(source)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'does not invoke BeClose#convert_to_be_within!' do
|
165
|
+
Syntax::BeClose.any_instance.should_not_receive(:convert_to_be_within!)
|
166
|
+
rewriter.rewrite(source)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
140
170
|
context 'when the source have overlapped rewrite targets' do
|
141
171
|
let(:source) do
|
142
172
|
<<-END
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'transpec/syntax/be_close'
|
5
|
+
|
6
|
+
module Transpec
|
7
|
+
class Syntax
|
8
|
+
describe BeClose do
|
9
|
+
include_context 'parsed objects'
|
10
|
+
|
11
|
+
subject(:be_close_object) do
|
12
|
+
AST::Scanner.scan(ast) do |node, ancestor_nodes|
|
13
|
+
next unless BeClose.target_node?(node)
|
14
|
+
return BeClose.new(
|
15
|
+
node,
|
16
|
+
ancestor_nodes,
|
17
|
+
in_example_group_context?,
|
18
|
+
source_rewriter
|
19
|
+
)
|
20
|
+
end
|
21
|
+
fail 'No be_close node is found!'
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:in_example_group_context?) { true }
|
25
|
+
|
26
|
+
describe '#convert_to_be_within!' do
|
27
|
+
let(:source) do
|
28
|
+
<<-END
|
29
|
+
it 'is close to 0.333' do
|
30
|
+
(1.0 / 3.0).should be_close(0.333, 0.001)
|
31
|
+
end
|
32
|
+
END
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:expected_source) do
|
36
|
+
<<-END
|
37
|
+
it 'is close to 0.333' do
|
38
|
+
(1.0 / 3.0).should be_within(0.001).of(0.333)
|
39
|
+
end
|
40
|
+
END
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'converts into `be_within(delta).of(expected)` form' do
|
44
|
+
be_close_object.convert_to_be_within!
|
45
|
+
rewritten_source.should == expected_source
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'transpec/syntax/double'
|
4
5
|
|
5
6
|
module Transpec
|
6
7
|
class Syntax
|
@@ -37,9 +38,9 @@ module Transpec
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
describe '#
|
41
|
+
describe '#convert_to_double!' do
|
41
42
|
before do
|
42
|
-
double_object.
|
43
|
+
double_object.convert_to_double!
|
43
44
|
end
|
44
45
|
|
45
46
|
[:mock, :stub].each do |method|
|
data/spec/transpec/util_spec.rb
CHANGED
data/transpec.gemspec
CHANGED
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'rubocop', '~> 0.10'
|
29
29
|
spec.add_development_dependency 'guard-rspec', '~> 3.0'
|
30
30
|
spec.add_development_dependency 'guard-rubocop', '~> 0.2'
|
31
|
+
spec.add_development_dependency 'guard-shell', '~> 0.5'
|
31
32
|
spec.add_development_dependency 'ruby_gntp', '~> 0.3'
|
32
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transpec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-shell
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.5'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.5'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: ruby_gntp
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,13 +162,14 @@ files:
|
|
148
162
|
- .gitignore
|
149
163
|
- .rubocop.yml
|
150
164
|
- .travis.yml
|
165
|
+
- CHANGELOG.md
|
151
166
|
- Gemfile
|
152
167
|
- Guardfile
|
153
168
|
- LICENSE.txt
|
154
169
|
- README.md
|
170
|
+
- README.md.erb
|
155
171
|
- Rakefile
|
156
172
|
- bin/transpec
|
157
|
-
- lib/transpec.rb
|
158
173
|
- lib/transpec/ast/scanner.rb
|
159
174
|
- lib/transpec/ast/scope_stack.rb
|
160
175
|
- lib/transpec/cli.rb
|
@@ -162,7 +177,10 @@ files:
|
|
162
177
|
- lib/transpec/git.rb
|
163
178
|
- lib/transpec/rewriter.rb
|
164
179
|
- lib/transpec/syntax.rb
|
180
|
+
- lib/transpec/syntax/any_instanceable.rb
|
181
|
+
- lib/transpec/syntax/be_close.rb
|
165
182
|
- lib/transpec/syntax/double.rb
|
183
|
+
- lib/transpec/syntax/expectizable.rb
|
166
184
|
- lib/transpec/syntax/matcher.rb
|
167
185
|
- lib/transpec/syntax/method_stub.rb
|
168
186
|
- lib/transpec/syntax/send_node_syntax.rb
|
@@ -181,6 +199,7 @@ files:
|
|
181
199
|
- spec/transpec/configuration_spec.rb
|
182
200
|
- spec/transpec/git_spec.rb
|
183
201
|
- spec/transpec/rewriter_spec.rb
|
202
|
+
- spec/transpec/syntax/be_close_spec.rb
|
184
203
|
- spec/transpec/syntax/double_spec.rb
|
185
204
|
- spec/transpec/syntax/matcher_spec.rb
|
186
205
|
- spec/transpec/syntax/method_stub_spec.rb
|
@@ -224,6 +243,7 @@ test_files:
|
|
224
243
|
- spec/transpec/configuration_spec.rb
|
225
244
|
- spec/transpec/git_spec.rb
|
226
245
|
- spec/transpec/rewriter_spec.rb
|
246
|
+
- spec/transpec/syntax/be_close_spec.rb
|
227
247
|
- spec/transpec/syntax/double_spec.rb
|
228
248
|
- spec/transpec/syntax/matcher_spec.rb
|
229
249
|
- spec/transpec/syntax/method_stub_spec.rb
|
data/lib/transpec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'transpec/configuration'
|
4
|
-
require 'transpec/cli'
|
5
|
-
require 'transpec/git'
|
6
|
-
require 'transpec/rewriter'
|
7
|
-
require 'transpec/util'
|
8
|
-
require 'transpec/version'
|
9
|
-
require 'transpec/ast/scanner'
|
10
|
-
require 'transpec/ast/scope_stack'
|
11
|
-
require 'transpec/syntax'
|
12
|
-
require 'transpec/syntax/send_node_syntax'
|
13
|
-
require 'transpec/syntax/double'
|
14
|
-
require 'transpec/syntax/matcher'
|
15
|
-
require 'transpec/syntax/method_stub'
|
16
|
-
require 'transpec/syntax/should'
|
17
|
-
require 'transpec/syntax/should_receive'
|