transpec 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
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.1.2
4
+ version: 0.1.3
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-09-29 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -188,9 +188,9 @@ files:
188
188
  - lib/transpec/ast/builder.rb
189
189
  - lib/transpec/ast/node.rb
190
190
  - lib/transpec/ast/scanner.rb
191
- - lib/transpec/ast/scope_stack.rb
192
191
  - lib/transpec/cli.rb
193
192
  - lib/transpec/configuration.rb
193
+ - lib/transpec/context.rb
194
194
  - lib/transpec/git.rb
195
195
  - lib/transpec/rewriter.rb
196
196
  - lib/transpec/syntax.rb
@@ -210,14 +210,13 @@ files:
210
210
  - lib/transpec/version.rb
211
211
  - spec/.rubocop.yml
212
212
  - spec/spec_helper.rb
213
- - spec/spec_spec.rb
214
213
  - spec/support/file_helper.rb
215
214
  - spec/support/shared_context.rb
216
215
  - spec/transpec/ast/node_spec.rb
217
216
  - spec/transpec/ast/scanner_spec.rb
218
- - spec/transpec/ast/scope_stack_spec.rb
219
217
  - spec/transpec/cli_spec.rb
220
218
  - spec/transpec/configuration_spec.rb
219
+ - spec/transpec/context_spec.rb
221
220
  - spec/transpec/git_spec.rb
222
221
  - spec/transpec/rewriter_spec.rb
223
222
  - spec/transpec/syntax/be_close_spec.rb
@@ -229,6 +228,9 @@ files:
229
228
  - spec/transpec/syntax/should_receive_spec.rb
230
229
  - spec/transpec/syntax/should_spec.rb
231
230
  - spec/transpec/util_spec.rb
231
+ - tasks/ci/spec.rake
232
+ - tasks/readme.rake
233
+ - tasks/test.rake
232
234
  - transpec.gemspec
233
235
  homepage: https://github.com/yujinakayama/transpec
234
236
  licenses:
@@ -257,14 +259,13 @@ summary: RSpec syntax converter
257
259
  test_files:
258
260
  - spec/.rubocop.yml
259
261
  - spec/spec_helper.rb
260
- - spec/spec_spec.rb
261
262
  - spec/support/file_helper.rb
262
263
  - spec/support/shared_context.rb
263
264
  - spec/transpec/ast/node_spec.rb
264
265
  - spec/transpec/ast/scanner_spec.rb
265
- - spec/transpec/ast/scope_stack_spec.rb
266
266
  - spec/transpec/cli_spec.rb
267
267
  - spec/transpec/configuration_spec.rb
268
+ - spec/transpec/context_spec.rb
268
269
  - spec/transpec/git_spec.rb
269
270
  - spec/transpec/rewriter_spec.rb
270
271
  - spec/transpec/syntax/be_close_spec.rb
@@ -1,78 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'transpec/util'
4
-
5
- module Transpec
6
- module AST
7
- class ScopeStack < Array
8
- EXAMPLE_GROUP_METHOD_NAMES = [
9
- :describe, :context,
10
- :shared_examples, :shared_context, :share_examples_for, :shared_examples_for
11
- ].freeze
12
-
13
- def push_scope(node)
14
- push(scope_type(node))
15
- end
16
-
17
- def pop_scope
18
- pop
19
- end
20
-
21
- def in_example_group_context?
22
- if include?(:example_group)
23
- scopes_in_example_group = inner_scopes_in_scope(:example_group)
24
- return false if include_class_scope?(scopes_in_example_group)
25
- include_method_or_block_scope?(scopes_in_example_group)
26
- elsif include?(:rspec_configure)
27
- scopes_in_rspec_configure = inner_scopes_in_scope(:rspec_configure)
28
- return false if include_class_scope?(scopes_in_rspec_configure)
29
- include_method_or_block_scope?(scopes_in_rspec_configure)
30
- elsif first == :def
31
- scopes_in_method = self[1..-1]
32
- !include_class_scope?(scopes_in_method)
33
- elsif include?(:module)
34
- scopes_in_module = inner_scopes_in_scope(:module)
35
- return false if include_class_scope?(scopes_in_module)
36
- scopes_in_module.include?(:def)
37
- else
38
- false
39
- end
40
- end
41
-
42
- private
43
-
44
- def scope_type(node)
45
- return node.type unless node.type == :block
46
-
47
- send_node = node.children.first
48
- receiver_node, method_name, *_ = *send_node
49
-
50
- if Util.const_name(receiver_node) == 'RSpec' && method_name == :configure
51
- :rspec_configure
52
- elsif receiver_node
53
- node.type
54
- elsif EXAMPLE_GROUP_METHOD_NAMES.include?(method_name)
55
- :example_group
56
- else
57
- node.type
58
- end
59
- end
60
-
61
- def inner_scopes_in_scope(scope_type)
62
- index = rindex(scope_type)
63
- return nil unless index
64
- self[Range.new(index + 1, -1)]
65
- end
66
-
67
- def include_class_scope?(scopes)
68
- !(scopes & [:class, :sclass]).empty?
69
- end
70
-
71
- def include_method_or_block_scope?(scopes)
72
- # TODO: Should validate whether the method taking the block is RSpec's
73
- # special method. (e.g. #subject, #let, #before, #after)
74
- !(scopes & [:def, :block]).empty?
75
- end
76
- end
77
- end
78
- end
@@ -1,51 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec'
5
- require 'tmpdir'
6
- require 'English'
7
-
8
- describe 'Transpec project spec', :do_not_run_in_converted_spec do
9
- copied_project_root = Dir.mktmpdir
10
-
11
- before(:all) do
12
- Dir.chdir(Transpec.root) do
13
- FileUtils.cp_r(Dir['*'], copied_project_root)
14
- end
15
- end
16
-
17
- around do |example|
18
- Dir.chdir(copied_project_root) do
19
- example.run
20
- end
21
- end
22
-
23
- def silent_system(*args)
24
- original_env = ENV.to_hash
25
-
26
- if args.first.is_a?(Hash)
27
- custom_env = args.shift
28
- ENV.update(custom_env)
29
- end
30
-
31
- command = args.shelljoin
32
- `#{command}`
33
-
34
- ENV.replace(original_env)
35
- $CHILD_STATUS.success?
36
- rescue
37
- ENV.replace(original_env)
38
- false
39
- end
40
-
41
- it 'can be converted by Transpec itself without error' do
42
- silent_system('./bin/transpec', '--force').should be_true
43
- end
44
-
45
- describe 'converted spec' do
46
- it 'passes all' do
47
- env = { 'TRANSPEC_CONVERTED_SPEC' => 'true' }
48
- silent_system(env, 'rspec').should be_true
49
- end
50
- end
51
- end
@@ -1,95 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/ast/scope_stack'
5
-
6
- module Transpec
7
- module AST
8
- describe ScopeStack do
9
- describe '#in_example_group_context?' do
10
- subject { ScopeStack.new(scopes).in_example_group_context? }
11
-
12
- context 'when in top level' do
13
- let(:scopes) { [] }
14
- it { should be_false }
15
- end
16
-
17
- context 'when in an instance method in top level' do
18
- let(:scopes) { [:def] }
19
- it { should be_true }
20
- end
21
-
22
- context 'when in a block in an instance method in top level' do
23
- let(:scopes) { [:def, :block] }
24
- it { should be_true }
25
- end
26
-
27
- context 'when in #describe block in top level' do
28
- let(:scopes) { [:example_group] }
29
- it { should be_false }
30
- end
31
-
32
- context 'when in #describe block in a module' do
33
- let(:scopes) { [:module, :example_group] }
34
- it { should be_false }
35
- end
36
-
37
- context 'when in an instance method in #describe block' do
38
- let(:scopes) { [:example_group, :def] }
39
- it { should be_true }
40
- end
41
-
42
- context 'when in an instance method in #describe block in a module' do
43
- let(:scopes) { [:module, :example_group, :def] }
44
- it { should be_true }
45
- end
46
-
47
- context 'when in a block in #describe block' do
48
- let(:scopes) { [:example_group, :block] }
49
- it { should be_true }
50
- end
51
-
52
- context 'when in a block in #describe block in a module' do
53
- let(:scopes) { [:module, :example_group, :block] }
54
- it { should be_true }
55
- end
56
-
57
- context 'when in a class in a block in #describe block' do
58
- let(:scopes) { [:example_group, :block, :class] }
59
- it { should be_false }
60
- end
61
-
62
- context 'when in an instance method in a class in a block in #describe block' do
63
- let(:scopes) { [:example_group, :block, :class, :def] }
64
- it { should be_false }
65
- end
66
-
67
- context 'when in an instance method in a module' do
68
- # Instance methods of module can be used by `include SomeModule` in #describe block.
69
- let(:scopes) { [:module, :def] }
70
- it { should be_true }
71
- end
72
-
73
- context 'when in an instance method in a class' do
74
- let(:scopes) { [:class, :def] }
75
- it { should be_false }
76
- end
77
-
78
- context 'when in RSpec.configure' do
79
- let(:scopes) { [:rspec_configure] }
80
- it { should be_false }
81
- end
82
-
83
- context 'when in a block in RSpec.configure' do
84
- let(:scopes) { [:rspec_configure, :block] }
85
- it { should be_true }
86
- end
87
-
88
- context 'when in an instance method in RSpec.configure' do
89
- let(:scopes) { [:rspec_configure, :def] }
90
- it { should be_true }
91
- end
92
- end
93
- end
94
- end
95
- end