transpec 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/transpec/syntax/example.rb +8 -0
- data/lib/transpec/syntax/mixin/monkey_patch_any_instance.rb +1 -6
- data/lib/transpec/syntax/mixin/send.rb +1 -1
- data/lib/transpec/version.rb +1 -1
- data/spec/transpec/syntax/example_spec.rb +16 -0
- data/spec/transpec/syntax/should_receive_spec.rb +39 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65c3e2a67d42f7fc8b2ca50e0853242a6057bfcb
|
4
|
+
data.tar.gz: facb20a69acc7f105f48b47524e2b6486b68c1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dc1164f70806bad460e845710010a9365751e02ccc106034f71d25a0d979efe8e283b0837be635385558317a988f5c71ab72c78216a3fae1ddfc6b0d93d18f2
|
7
|
+
data.tar.gz: 05d9de7fa3d15cb62da0e91cfa85c71f6ad615c70452c7ddee00aa0c9cb3925a3dfe87f2b383d210adb26661ffb8134190821ddbc3e6706ae5686a8997a6c586
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v1.9.3
|
6
|
+
|
7
|
+
* Handle `variable.any_instance` ([#46](https://github.com/yujinakayama/transpec/issues/46))
|
8
|
+
* Fix a bug where the DSL `example` (an alias of `it`) was confused with current example object (e.g. `example 'it does something' do ... end` was converted to `example 'it does something' do |example| ... end`)
|
9
|
+
|
5
10
|
## v1.9.2
|
6
11
|
|
7
12
|
* Fix a bug where `expect(method_returns_collection :some_arg).to have(2).items` was converted to `expect(method_returns_collection :some_arg.size).to eq(2)` ([#43](https://github.com/yujinakayama/transpec/issues/43))
|
@@ -12,6 +12,14 @@ module Transpec
|
|
12
12
|
|
13
13
|
METHODS_YIELD_EXAMPLE = (EXAMPLE_METHODS + HOOK_METHODS + HELPER_METHODS).freeze
|
14
14
|
|
15
|
+
def self.target_node?(node, runtime_data = nil)
|
16
|
+
receiver_node, method_name, *_ = *node
|
17
|
+
return false if receiver_node
|
18
|
+
return false unless [:example, :running_example].include?(method_name)
|
19
|
+
return false if Util.block_node_taken_by_method(node)
|
20
|
+
check_target_node_dynamically(node, runtime_data)
|
21
|
+
end
|
22
|
+
|
15
23
|
def self.target_method?(receiver_node, method_name)
|
16
24
|
receiver_node.nil? && [:example, :running_example].include?(method_name)
|
17
25
|
end
|
@@ -55,12 +55,7 @@ module Transpec
|
|
55
55
|
receiver_node, method_name = *subject_node
|
56
56
|
return nil unless receiver_node
|
57
57
|
return nil unless method_name == :any_instance
|
58
|
-
|
59
|
-
if receiver_node.const_type? || receiver_node == s(:send, nil, :described_class)
|
60
|
-
receiver_node
|
61
|
-
else
|
62
|
-
nil
|
63
|
-
end
|
58
|
+
receiver_node
|
64
59
|
end
|
65
60
|
end
|
66
61
|
end
|
@@ -27,7 +27,7 @@ module Transpec
|
|
27
27
|
source_location = source_location(node, runtime_data)
|
28
28
|
return true unless source_location
|
29
29
|
file_path = source_location.first
|
30
|
-
!file_path.match(%r{/
|
30
|
+
!file_path.match(%r{/rspec\-[^/]+/lib/rspec/}).nil?
|
31
31
|
end
|
32
32
|
|
33
33
|
def source_location(node, runtime_data)
|
data/lib/transpec/version.rb
CHANGED
@@ -197,6 +197,22 @@ module Transpec
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
context "when it is `example 'it does something' do do_something end` form", :no_auto_convert do
|
201
|
+
let(:source) do
|
202
|
+
<<-END
|
203
|
+
describe 'example' do
|
204
|
+
example 'it does something' do
|
205
|
+
do_something
|
206
|
+
end
|
207
|
+
end
|
208
|
+
END
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'does nothing' do
|
212
|
+
rewritten_source.should == source
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
200
216
|
context 'when it is `def helper_method example; end` form' do
|
201
217
|
let(:source) do
|
202
218
|
<<-END
|
@@ -508,7 +508,45 @@ module Transpec
|
|
508
508
|
end
|
509
509
|
end
|
510
510
|
|
511
|
-
context 'when it is `variable.any_instance.should_receive(:method)` form
|
511
|
+
context 'when it is `variable.any_instance.should_receive(:method)` form' do
|
512
|
+
let(:source) do
|
513
|
+
<<-END
|
514
|
+
describe 'example' do
|
515
|
+
it 'receives #foo' do
|
516
|
+
variable = String
|
517
|
+
variable.any_instance.should_receive(:foo)
|
518
|
+
'string'.foo
|
519
|
+
end
|
520
|
+
end
|
521
|
+
END
|
522
|
+
end
|
523
|
+
|
524
|
+
let(:expected_source) do
|
525
|
+
<<-END
|
526
|
+
describe 'example' do
|
527
|
+
it 'receives #foo' do
|
528
|
+
variable = String
|
529
|
+
expect_any_instance_of(variable).to receive(:foo)
|
530
|
+
'string'.foo
|
531
|
+
end
|
532
|
+
end
|
533
|
+
END
|
534
|
+
end
|
535
|
+
|
536
|
+
it 'converts into `expect_any_instance_of(variable).to receive(:method)` form' do
|
537
|
+
should_receive_object.expectize!
|
538
|
+
rewritten_source.should == expected_source
|
539
|
+
end
|
540
|
+
|
541
|
+
it 'adds record `Klass.any_instance.should_receive(:message)` ' \
|
542
|
+
'-> `expect_any_instance_of(Klass).to receive(:message)`' do
|
543
|
+
should_receive_object.expectize!
|
544
|
+
record.original_syntax.should == 'Klass.any_instance.should_receive(:message)'
|
545
|
+
record.converted_syntax.should == 'expect_any_instance_of(Klass).to receive(:message)'
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
context 'when it is `variable.should_receive(:method)` form ' \
|
512
550
|
'and the variable is an AnyInstance::Recorder' do
|
513
551
|
context 'with runtime information' do
|
514
552
|
include_context 'dynamic analysis objects'
|
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: 1.9.
|
4
|
+
version: 1.9.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: 2014-02-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|