transpec 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4282d3fbc1652d1d78046fe2a04392fea0cee1c
4
- data.tar.gz: 6eab8ef44e5a6b8e672246b7fd420bf220cd7006
3
+ metadata.gz: beba3d9ff0b918b0a1cddea7745022270fdfb5ee
4
+ data.tar.gz: 014a462a96ef9bbed89c5fc27be89cdddea42e4f
5
5
  SHA512:
6
- metadata.gz: c4e376be4d7ef6f6c33c2cdc9d31a66f2817d0902be4d83541b3d79f637e83c4b23f0a021791a623d4214ee215e3909ffbaa602e0357f0bc1b1989325cb7c3eb
7
- data.tar.gz: 4d1b3b9346eea8526948a8475c4c0fba32e2c1c35a1dfeecba9eec5c69f3df11dc0387f38baba7f9b596bfc78e92c0b0c81c18a213998693fc5f5d9fddd5ac50
6
+ metadata.gz: 477b28e6fddc2cdad7b215339510cda28f6c826f721bef67388518e4640dbc82b98f6047ce425cce826aae04e3c99096407b493cb17e109a54920377539d2050
7
+ data.tar.gz: e0d529dc8bf9e6159ecbb4d8d16e0c2a12001c080ad155d572c83f05b186a7234144108fa97a2371e92c576ef292c6a818e76160226d5ab0a817b104b6c142d2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## v0.2.5
6
+
7
+ * Do not touch file if the source does need to be rewritten
8
+
5
9
  ## v0.2.4
6
10
 
7
11
  * Improve context detection
@@ -64,24 +64,14 @@ module Transpec
64
64
 
65
65
  def non_monkey_patch_expectation_available?
66
66
  return @expectation_available if instance_variable_defined?(:@expectation_available)
67
-
68
- return @expectation_available = true if scopes == [:def]
69
-
70
- @expectation_available = NON_MONKEY_PATCH_EXPECTATION_AVAILABLE_CONTEXT.any? do |suffix|
71
- scopes.end_with?(suffix)
72
- end
67
+ @expectation_available = match_scopes(NON_MONKEY_PATCH_EXPECTATION_AVAILABLE_CONTEXT)
73
68
  end
74
69
 
75
70
  alias_method :expect_to_matcher_available?, :non_monkey_patch_expectation_available?
76
71
 
77
72
  def non_monkey_patch_mock_available?
78
73
  return @mock_available if instance_variable_defined?(:@mock_available)
79
-
80
- return @mock_available = true if scopes == [:def]
81
-
82
- @mock_available = NON_MONKEY_PATCH_MOCK_AVAILABLE_CONTEXT.any? do |suffix|
83
- scopes.end_with?(suffix)
84
- end
74
+ @mock_available = match_scopes(NON_MONKEY_PATCH_MOCK_AVAILABLE_CONTEXT)
85
75
  end
86
76
 
87
77
  alias_method :expect_to_receive_available?, :non_monkey_patch_mock_available?
@@ -140,6 +130,14 @@ module Transpec
140
130
  :each_before_after
141
131
  end
142
132
 
133
+ def match_scopes(scope_suffixes)
134
+ return true if scopes == [:def]
135
+
136
+ scope_suffixes.any? do |suffix|
137
+ scopes.end_with?(suffix)
138
+ end
139
+ end
140
+
143
141
  module ArrayExtension
144
142
  def end_with?(*args)
145
143
  tail = args.flatten
@@ -28,6 +28,7 @@ module Transpec
28
28
  def rewrite_file!(file_path)
29
29
  source = File.read(file_path)
30
30
  rewritten_source = rewrite(source, file_path)
31
+ return if source == rewritten_source
31
32
  File.write(file_path, rewritten_source)
32
33
  end
33
34
 
@@ -5,7 +5,7 @@ module Transpec
5
5
  module Version
6
6
  MAJOR = 0
7
7
  MINOR = 2
8
- PATCH = 4
8
+ PATCH = 5
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,8 @@ RSpec.configure do |config|
13
13
  config.color_enabled = true
14
14
  config.treat_symbols_as_metadata_keys_with_true_values = true
15
15
 
16
+ config.filter_run_excluding :skip_on_jruby if RUBY_ENGINE == 'jruby'
17
+
16
18
  config.before(:all) do
17
19
  require 'rainbow'
18
20
  Sickill::Rainbow.enabled = false
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  require 'transpec/context'
5
5
 
6
6
  module Transpec
7
- describe Context do
7
+ describe Context, :skip_on_jruby do
8
8
  include ::AST::Sexp
9
9
  include_context 'parsed objects'
10
10
  include_context 'isolated environment'
@@ -15,6 +15,7 @@ module Transpec
15
15
 
16
16
  before do
17
17
  File.write(file_path, 'This is a spec')
18
+ File.utime(0, 0, file_path)
18
19
  rewriter.stub(:rewrite).and_return('This is the rewritten spec')
19
20
  end
20
21
 
@@ -22,6 +23,17 @@ module Transpec
22
23
  rewriter.rewrite_file!(file_path)
23
24
  File.read(file_path).should == 'This is the rewritten spec'
24
25
  end
26
+
27
+ context 'when the source does not need rewrite' do
28
+ before do
29
+ rewriter.stub(:rewrite).and_return('This is a spec')
30
+ end
31
+
32
+ it 'does not touch the file' do
33
+ rewriter.rewrite_file!(file_path)
34
+ File.mtime(file_path).should == Time.at(0)
35
+ end
36
+ end
25
37
  end
26
38
 
27
39
  describe '#rewrite' do
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.2.4
4
+ version: 0.2.5
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-10-12 00:00:00.000000000 Z
11
+ date: 2013-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser