热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Ruby2.0support

ThispatchmakessomechangestosupportRuby2.0andadds2.0.0to

This patch makes some changes to support Ruby 2.0 and adds 2.0.0 to

1
.travis.yml

.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
 patch

diff --git .travis.yml .travis.yml

index 661dd2b..a3297f0 100644

--- .travis.yml

+++ .travis.yml

@@ -1,4 +1,5 @@

 rvm:

+  - 2.0.0

   - 1.9.3

   - 1.9.2



diff --git cucumber.yml cucumber.yml

index b081270..52e3727 100644

--- cucumber.yml

+++ cucumber.yml

@@ -15,6 +15,7 @@ jruby:  --tags ~ --tags ~

 jruby_win:  --tags ~ --tags ~ CUCUMBER_FORWARD_SLASH_PATHS=true

 windows_mri:  --tags ~ --tags ~ --tags ~ --tags ~-many-fonts CUCUMBER_FORWARD_SLASH_PATHS=true

 ruby_1_9:  --tags ~ --tags ~

+ruby_2_0:  --tags ~ --tags ~

 wip: --tags :3 --wip features

 none: --format pretty

 rerun:  --format rerun --out rerun.txt --strict --tags ~

diff --git fixtures/self_test/features/support/env.rb fixtures/self_test/features/support/env.rb

index 1ce0d3a..2dc9ff5 100644

--- fixtures/self_test/features/support/env.rb

+++ fixtures/self_test/features/support/env.rb

@@ -1,6 +1,6 @@

 require 'base64'

 begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end

-$KCODE = 'u' unless Cucumber::RUBY_1_9

+$KCODE = 'u' if Cucumber::RUBY_2_0



 Before('') do

   raise "Should never run"

diff --git gem_tasks/cucumber.rake gem_tasks/cucumber.rake

index 2789906..8bcfc82 100644

--- gem_tasks/cucumber.rake

+++ gem_tasks/cucumber.rake

@@ -3,12 +3,14 @@ require 'cucumber/platform'



 class Cucumber::Rake::Task

   def set_profile_for_current_ruby

-    self.profile = if(Cucumber::JRUBY)

+    self.profile = if Cucumber::JRUBY

       Cucumber::WINDOWS ? 'jruby_win' : 'jruby'

-    elsif(Cucumber::WINDOWS_MRI)

+    elsif Cucumber::WINDOWS_MRI

       'windows_mri'

-    elsif(Cucumber::RUBY_1_9)

+    elsif Cucumber::RUBY_1_9

       'ruby_1_9'

+    elsif Cucumber::RUBY_2_0

+      'ruby_2_0'

     end

   end

 end

diff --git legacy_features/support/env.rb legacy_features/support/env.rb

index 8a3d848..a70afef 100644

--- legacy_features/support/env.rb

+++ legacy_features/support/env.rb

@@ -101,7 +101,7 @@ class CucumberWorld

     stderr_file = Tempfile.new('cucumber')

     stderr_file.close

     in_current_dir do

-      mode = Cucumber::RUBY_1_9 ? {:external_encoding=>"UTF-8"} : 'r'

+      mode = Cucumber::RUBY_1_8_7 ? 'r' : {:external_encoding=>"UTF-8"}

       IO.popen("#{command} 2> #{stderr_file.path}", mode) do |io|

          = io.read

       end

diff --git lib/cucumber/core_ext/instance_exec.rb lib/cucumber/core_ext/instance_exec.rb

index 0346a34..d76c21e 100644

--- lib/cucumber/core_ext/instance_exec.rb

+++ lib/cucumber/core_ext/instance_exec.rb

@@ -54,7 +54,7 @@ class Object #:nodoc:



   def cucumber_arity(block)

     a = block.arity

-    Cucumber::RUBY_1_9 ? a : (a == -1 ? 0 : a)

+    Cucumber::RUBY_1_8_7 ? (a == -1 ? 0 : a) : a

   end



   def cucumber_compatible_arity?(args, block)

@@ -74,7 +74,7 @@ class Object #:nodoc:

     end

   end



-  INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::RUBY_1_8_7 || Cucumber::JRUBY) ? -3 : -4

+  INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_2_0 || Cucumber::RUBY_1_9 || Cucumber::RUBY_1_8_7 || Cucumber::JRUBY) ? -3 : -4



   def replace_instance_exec_invocation_line!(backtrace, instance_exec_invocation_line, pseudo_method)

     return if Cucumber.use_full_backtrace

diff --git lib/cucumber/formatter/unicode.rb lib/cucumber/formatter/unicode.rb

index 61fe#..0105d5e 100644

--- lib/cucumber/formatter/unicode.rb

+++ lib/cucumber/formatter/unicode.rb

@@ -2,10 +2,10 @@

 # Tips for improvement - esp. ruby 1.9: http://www.ruby-forum.com/topic/184730

 require 'cucumber/platform'

 require 'cucumber/formatter/ansicolor'

-$KCODE='u' unless Cucumber::RUBY_1_9

+$KCODE='u' if Cucumber::RUBY_2_0



 if Cucumber::WINDOWS

-  require 'iconv' unless Cucumber::RUBY_1_9

+  require 'iconv' if Cucumber::RUBY_2_0



   if ENV['CUCUMBER_OUTPUT_ENCODING']

     Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']

@@ -27,14 +27,7 @@ if Cucumber::WINDOWS

         o.instance_eval do

           alias cucumber_print print

           def print(*a)

-            if Cucumber::RUBY_1_9

-              begin

-                cucumber_print(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})

-              rescue Encoding::UndefinedConversionError => e

-                STDERR.cucumber_puts("WARNING: #{e.message}")

-                cucumber_print(*a)

-              end

-            else

+            if Cucumber::RUBY_1_8_7

               begin

                 cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))

               rescue Iconv::InvalidEncoding => e

@@ -44,19 +37,19 @@ if Cucumber::WINDOWS

                 STDERR.cucumber_puts("WARNING: #{e.message}")

                 cucumber_print(*a)

               end

+            else

+              begin

+                cucumber_print(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})

+              rescue Encoding::UndefinedConversionError => e

+                STDERR.cucumber_puts("WARNING: #{e.message}")

+                cucumber_print(*a)

+              end

             end

           end



           alias cucumber_puts puts

           def puts(*a)

-            if Cucumber::RUBY_1_9

-              begin

-                cucumber_puts(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})

-              rescue Encoding::UndefinedConversionError => e

-                STDERR.cucumber_puts("WARNING: #{e.message}")

-                cucumber_puts(*a)

-              end

-            else

+            if Cucumber::RUBY_1_8_7

               begin

                 cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))

               rescue Iconv::InvalidEncoding => e

@@ -66,6 +59,13 @@ if Cucumber::WINDOWS

                 STDERR.cucumber_puts("WARNING: #{e.message}")

                 cucumber_puts(*a)

               end

+            else

+              begin

+                cucumber_puts(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})

+              rescue Encoding::UndefinedConversionError => e

+                STDERR.cucumber_puts("WARNING: #{e.message}")

+                cucumber_puts(*a)

+              end

             end

           end

         end

diff --git lib/cucumber/platform.rb lib/cucumber/platform.rb

index a71eea4..9b99f62 100644

--- lib/cucumber/platform.rb

+++ lib/cucumber/platform.rb

@@ -14,6 +14,7 @@ unless defined?(Cucumber::VERSION)

   WINDOWS_MRI   = WINDOWS && !JRUBY && !IRONRUBY

   RAILS         = defined?(Rails)

   RUBY_BINARY   = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])

+  RUBY_2_0      = RUBY_VERSION =~ /^2\.0/

   RUBY_1_9      = RUBY_VERSION =~ /^1\.9/

   RUBY_1_8_7    = RUBY_VERSION =~ /^1\.8\.7/



@@ -21,7 +22,7 @@ unless defined?(Cucumber::VERSION)

     attr_accessor :use_full_backtrace



     def file_mode(m, encoding="UTF-8") #:nodoc:

-      RUBY_1_9 ? "#{m}:#{encoding}" : m

+      RUBY_1_8_7 ? m : "#{m}:#{encoding}"

     end

   end

   self.use_full_backtrace = false

diff --git lib/cucumber/rake/task.rb lib/cucumber/rake/task.rb

index 6596c7f..c5583ec 100644

--- lib/cucumber/rake/task.rb

+++ lib/cucumber/rake/task.rb

@@ -143,7 +143,7 @@ module Cucumber

       # true, +fork+ is implicit.

       attr_accessor :rcov

       def rcov=(flag)

-        if(flag && Cucumber::RUBY_1_9)

+        if flag && !Cucumber::RUBY_1_8_7

           raise failed + "RCov only works on Ruby 1.8.x. You may want to use SimpleCov: https://github.com/colszowka/simplecov" + reset

         end

          = flag

diff --git spec/cucumber/cli/configuration_spec.rb spec/cucumber/cli/configuration_spec.rb

index 88894ed..60293ae 100644

--- spec/cucumber/cli/configuration_spec.rb

+++ spec/cucumber/cli/configuration_spec.rb

@@ -8,9 +8,13 @@ module Cli

       attr_reader :options

     end



+    def convert_hash_to_yaml_erb(hash)

+      ["---", *hash.map { |k,v| "#{k}: #{v}" }].join "\n"

+    end

+

     def given_cucumber_yml_defined_as(hash_or_string)

       File.stub!(:exist?).and_return(true)

-      cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string

+      cucumber_yml = hash_or_string.is_a?(Hash) ? convert_hash_to_yaml_erb(hash_or_string) : hash_or_string

       IO.stub!(:read).with('cucumber.yml').and_return(cucumber_yml)

     end



diff --git spec/cucumber/core_ext/proc_spec.rb spec/cucumber/core_ext/proc_spec.rb

index f5fcb48..fc9fc44 100644

--- spec/cucumber/core_ext/proc_spec.rb

+++ spec/cucumber/core_ext/proc_spec.rb

@@ -35,20 +35,20 @@ describe Proc do

     }.should raise_error(Cucumber::ArityMismatchError, "Your block takes 2 arguments, but the Regexp matched 1 argument.")

   end



-  if Cucumber::RUBY_1_9

-    it "should allow varargs (expecting 0+)" do

+  if Cucumber::RUBY_1_8_7

+    # Ruby 1.8

+    it "should not allow varargs 0+ because Ruby 1.8 reports same arity as with no args, so we can't really tell the difference." do

       lambda {

         Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|

         end

-      }.should_not raise_error(Cucumber::ArityMismatchError)

+      }.should raise_error(Cucumber::ArityMismatchError, "Your block takes 0 arguments, but the Regexp matched 1 argument.")

     end

   else

-    # Ruby 1.8

-    it "should not allow varargs 0+ because Ruby 1.8 reports same arity as with no args, so we can't really tell the difference." do

+    it "should allow varargs (expecting 0+)" do

       lambda {

         Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|

         end

-      }.should raise_error(Cucumber::ArityMismatchError, "Your block takes 0 arguments, but the Regexp matched 1 argument.")

+      }.should_not raise_error(Cucumber::ArityMismatchError)

     end

   end



diff --git spec/cucumber/step_match_spec.rb spec/cucumber/step_match_spec.rb

index fb42702..35ce644 100644

--- spec/cucumber/step_match_spec.rb

+++ spec/cucumber/step_match_spec.rb

@@ -7,7 +7,7 @@ module Cucumber

   describe StepMatch do

     include RSpec::WorkInProgress



-    WORD = Cucumber::RUBY_1_9 ? '[[:word:]]' : '\w'

+    WORD = Cucumber::RUBY_1_8_7 ? '\w' : '[[:word:]]'



     before do

        = RbSupport::RbLanguage.new(nil)

diff --git spec/spec_helper.rb spec/spec_helper.rb

index fe145ae..f7e773d 100644

--- spec/spec_helper.rb

+++ spec/spec_helper.rb

@@ -13,7 +13,7 @@ require 'bundler'

 Bundler.setup



 require 'cucumber'

-$KCODE='u' unless Cucumber::RUBY_1_9

+$KCODE='u' if Cucumber::RUBY_1_8_7



 RSpec.configure do |c|

   c.before do

该提问来源于开源项目:cucumber/cucumber-ruby

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.


推荐阅读
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • 使用在线工具jsonschema2pojo根据json生成java对象
    本文介绍了使用在线工具jsonschema2pojo根据json生成java对象的方法。通过该工具,用户只需将json字符串复制到输入框中,即可自动将其转换成java对象。该工具还能解析列表式的json数据,并将嵌套在内层的对象也解析出来。本文以请求github的api为例,展示了使用该工具的步骤和效果。 ... [详细]
  • 移动端常用单位——rem的使用方法和注意事项
    本文介绍了移动端常用的单位rem的使用方法和注意事项,包括px、%、em、vw、vh等其他常用单位的比较。同时还介绍了如何通过JS获取视口宽度并动态调整rem的值,以适应不同设备的屏幕大小。此外,还提到了rem目前在移动端的主流地位。 ... [详细]
  • 树莓派语音控制的配置方法和步骤
    本文介绍了在树莓派上实现语音控制的配置方法和步骤。首先感谢博主Eoman的帮助,文章参考了他的内容。树莓派的配置需要通过sudo raspi-config进行,然后使用Eoman的控制方法,即安装wiringPi库并编写控制引脚的脚本。具体的安装步骤和脚本编写方法在文章中详细介绍。 ... [详细]
  • 本文介绍了Composer依赖管理的重要性及使用方法。对于现代语言而言,包管理器是标配,而Composer作为PHP的包管理器,解决了PEAR的问题,并且使用简单,方便提交自己的包。文章还提到了使用Composer能够避免各种include的问题,避免命名空间冲突,并且能够方便地安装升级扩展包。 ... [详细]
  • 本文介绍了RxJava在Android开发中的广泛应用以及其在事件总线(Event Bus)实现中的使用方法。RxJava是一种基于观察者模式的异步java库,可以提高开发效率、降低维护成本。通过RxJava,开发者可以实现事件的异步处理和链式操作。对于已经具备RxJava基础的开发者来说,本文将详细介绍如何利用RxJava实现事件总线,并提供了使用建议。 ... [详细]
  • 本文讨论了微软的STL容器类是否线程安全。根据MSDN的回答,STL容器类包括vector、deque、list、queue、stack、priority_queue、valarray、map、hash_map、multimap、hash_multimap、set、hash_set、multiset、hash_multiset、basic_string和bitset。对于单个对象来说,多个线程同时读取是安全的。但如果一个线程正在写入一个对象,那么所有的读写操作都需要进行同步。 ... [详细]
  • 用Vue实现的Demo商品管理效果图及实现代码
    本文介绍了一个使用Vue实现的Demo商品管理的效果图及实现代码。 ... [详细]
  • gitlab重置password
    ruby没怎么学,自己搭建的gitlab的rootpassword又忘了。幸好看见此帖子,试验okhttp:roland.kierkels.netgitreset-your-git ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • 站点用户可以在站点上注册,并且在注册期间可以提供名称.我希望此名称是有效名称,并且不包含任何HTML和其他时髦字符.strip_tags够吗?解决方法: ... [详细]
  • Thisworkcameoutofthediscussioninhttps://github.com/typesafehub/config/issues/272 ... [详细]
  • QuestionThereareatotalofncoursesyouhavetotake,labeledfrom0ton-1.Somecoursesmayhaveprerequi ... [详细]
  • 先记住几个专用名词,如下:Workspace:工作区IndexStage:暂存区Repository:仓库区(或本地仓库)Remote:远程仓库一、新建代码库#在当前目录新建一个G ... [详细]
  • Iwanttogettheaverageofthedifferencebetweenthecurrenttimeandadatetimevalueinthedat ... [详细]
author-avatar
黄承念63772
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有