热门标签 | 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.


推荐阅读
  • python3 nmap函数简介及使用方法
    本文介绍了python3 nmap函数的简介及使用方法,python-nmap是一个使用nmap进行端口扫描的python库,它可以生成nmap扫描报告,并帮助系统管理员进行自动化扫描任务和生成报告。同时,它也支持nmap脚本输出。文章详细介绍了python-nmap的几个py文件的功能和用途,包括__init__.py、nmap.py和test.py。__init__.py主要导入基本信息,nmap.py用于调用nmap的功能进行扫描,test.py用于测试是否可以利用nmap的扫描功能。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • imx6ull开发板驱动MT7601U无线网卡的方法和步骤详解
    本文详细介绍了在imx6ull开发板上驱动MT7601U无线网卡的方法和步骤。首先介绍了开发环境和硬件平台,然后说明了MT7601U驱动已经集成在linux内核的linux-4.x.x/drivers/net/wireless/mediatek/mt7601u文件中。接着介绍了移植mt7601u驱动的过程,包括编译内核和配置设备驱动。最后,列举了关键词和相关信息供读者参考。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • 如何在HTML中获取鼠标的当前位置
    本文介绍了在HTML中获取鼠标当前位置的三种方法,分别是相对于屏幕的位置、相对于窗口的位置以及考虑了页面滚动因素的位置。通过这些方法可以准确获取鼠标的坐标信息。 ... [详细]
  • 本文介绍了贝叶斯垃圾邮件分类的机器学习代码,代码来源于https://www.cnblogs.com/huangyc/p/10327209.html,并对代码进行了简介。朴素贝叶斯分类器训练函数包括求p(Ci)和基于词汇表的p(w|Ci)。 ... [详细]
  • IsitpossibletomakeanAppfortheIphonethatapplychangestotheOriginalIphoneSMSapp?是否有 ... [详细]
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社区 版权所有