cuke-patterns 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cuke-patterns}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brendan Baldwin"]
@@ -3,6 +3,7 @@ When ":ivar_name contains :list" do |ivar, array|
3
3
  end
4
4
 
5
5
  Pattern :list, /(.+(?:,| and ).+)/ do |list|
6
+ assert_pony!
6
7
  list.split(/ *(?:,|and) */).map do |item|
7
8
  Pattern :value, item
8
9
  end
@@ -26,5 +26,6 @@ end
26
26
  Pattern :ivar_name, /(@\w+)/
27
27
 
28
28
  Pattern :value, /(.*)/ do |expression|
29
+ assert_pony!
29
30
  eval(expression)
30
31
  end
@@ -2,3 +2,13 @@ $LOAD_PATH.push File.expand_path(File.join(File.dirname(__FILE__),'..','..','lib
2
2
 
3
3
  require 'cuke-patterns'
4
4
 
5
+ class MyWorld
6
+ # This method is here to ensure we test the proper binding for applied patterns.
7
+ def assert_pony!
8
+ :bray!
9
+ end
10
+ end
11
+
12
+ World do
13
+ MyWorld.new
14
+ end
@@ -1,8 +1,8 @@
1
1
  module CukePatterns
2
2
  module RbDslExt
3
3
 
4
- def apply_rb_cuke_pattern(name, string)
5
- @rb_language.apply_rb_cuke_pattern(name, string)
4
+ def apply_rb_cuke_pattern(name, string, world)
5
+ @rb_language.apply_rb_cuke_pattern(name, string, world)
6
6
  end
7
7
 
8
8
  def register_rb_cuke_pattern(*args, &proc)
@@ -42,12 +42,12 @@ module CukePatterns
42
42
  @default_cuke_pattern_generators ||= []
43
43
  end
44
44
 
45
- def apply_rb_cuke_pattern(name, string)
45
+ def apply_rb_cuke_pattern(name, string, world)
46
46
  name = ":#{name}" if name.is_a?(Symbol)
47
47
  regexp, proc = lookup_cuke_pattern(name)
48
48
  match = regexp.match(string)
49
49
  raise "Pattern #{regexp.to_s} does not match #{string.inspect}" unless match
50
- return instance_exec(*match.captures, &proc) if proc
50
+ return world.instance_exec(*match.captures, &proc) if proc
51
51
  return match.to_s
52
52
  end
53
53
 
@@ -3,7 +3,7 @@ module CukePatterns
3
3
  module RbWorldExt
4
4
 
5
5
  def Pattern(name, string)
6
- Cucumber::RbSupport::RbDsl.apply_rb_cuke_pattern(name, string)
6
+ Cucumber::RbSupport::RbDsl.apply_rb_cuke_pattern(name, string, self)
7
7
  end
8
8
 
9
9
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brendan Baldwin