active_cucumber 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84625341a239f1384db39f3c8979e8a7650d20d6
4
- data.tar.gz: fbb06f1bd5dbff549ca4c6c055e444b71d1e26cb
3
+ metadata.gz: 51a76f3bdbaa0df727d7aeca2971ff1eb003d179
4
+ data.tar.gz: 8241aaae7b03a1cd3c4367ad989d21a31bc35568
5
5
  SHA512:
6
- metadata.gz: 7ace1532c2149270645c7ebf827318be8391335a5a5539a2327c8708606d790a41c1a047c213d5648323ed3df46399e118391982c4af692df36a76dde2d1a5a3
7
- data.tar.gz: 305549c30e799b3657d02ee4c6f2ebca080a17eaa3d780302cd3bb868ba96bce9b59540a516e578592c988071eaa1103fe4da3eebe4db543c001def1b031f732
6
+ metadata.gz: c4ac02e89ff2de842f4dc2b468ebed869a814c776398450e21f1ccd98c2dc1b31aec223db46cace7ed01dcbf7f466910824fcef5c90aacd50400159b13d4bb90
7
+ data.tar.gz: 46cf5be5cee5156333881d9255b92fc34e3fd75bfa8ed96eae978f5c89b0e3818a9f556e09e162e232c3985ffc9aaacc58f38b0e74b53e5fc8d7d697ab930c5a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_cucumber (0.0.9)
4
+ active_cucumber (0.0.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'active_cucumber'
6
- s.version = '0.0.9'
6
+ s.version = '0.0.10'
7
7
  s.authors = ['Kevin Goslar']
8
8
  s.email = ['kevin.goslar@gmail.com']
9
9
  s.summary = %s(ActiveRecord tools for Cucumber)
@@ -69,3 +69,13 @@ Feature: ActiveCucumber.diff_all!
69
69
  | Star Trek TNG | All Good Things |
70
70
  Then the test fails
71
71
  And Cucumparer prints the error message "Tables were not identical"
72
+
73
+
74
+ Scenario: using context values
75
+ Given the subscriptions:
76
+ | SUBSCRIBER | SHOW |
77
+ | Q | Star Trek TNG |
78
+ When running "ActiveCucumber.diff_all! Subscription, table, context: { current_user: 'Q' }" with this table:
79
+ | SUBSCRIBER | SHOW |
80
+ | me | Star Trek TNG |
81
+ Then the test passes
@@ -53,3 +53,13 @@ Feature: ActiveCucumber.diff_one!
53
53
  | NAME | All Good Things |
54
54
  Then the test fails
55
55
  And Cucumparer prints the error message "Tables were not identical"
56
+
57
+
58
+ Scenario: using context values
59
+ Given the subscription:
60
+ | SUBSCRIBER | Q |
61
+ | SHOW | Star Trek TNG |
62
+ When running "ActiveCucumber.diff_one! @created_subscription, table, context: { current_user: 'Q' }" with this table:
63
+ | SUBSCRIBER | me |
64
+ | SHOW | Star Trek TNG |
65
+ Then the test passes
@@ -4,4 +4,8 @@ class SubscriptionCucumberator < ActiveCucumber::Cucumberator
4
4
  show.try :name
5
5
  end
6
6
 
7
+ def value_for_subscriber
8
+ subscriber == @current_user ? 'me' : subscriber
9
+ end
10
+
7
11
  end
@@ -8,8 +8,11 @@ module ActiveCucumber
8
8
  class Cucumberator
9
9
 
10
10
  # object - the instance to decorate
11
- def initialize object
11
+ def initialize object, context
12
12
  @object = object
13
+ context.each do |key, value|
14
+ instance_variable_set "@#{key}", value
15
+ end
13
16
  end
14
17
 
15
18
 
@@ -2,9 +2,10 @@ module ActiveCucumber
2
2
 
3
3
  class Cucumparer
4
4
 
5
- def initialize clazz, cucumber_table
5
+ def initialize clazz, cucumber_table, context
6
6
  @clazz = clazz
7
7
  @cucumber_table = cucumber_table
8
+ @context = context
8
9
  end
9
10
 
10
11
  # Returns all entries in the database as a horizontal Mortadella table
@@ -45,7 +46,7 @@ module ActiveCucumber
45
46
 
46
47
  # Returns the Cucumberator object for the given ActiveRecord instance
47
48
  def cucumberator_for object
48
- cucumberator_class.new object
49
+ cucumberator_class.new object, @context
49
50
  end
50
51
 
51
52
  end
@@ -26,15 +26,15 @@ module ActiveCucumber
26
26
  # matches the given horizontal Cucumber table.
27
27
  #
28
28
  # Sorts records by creation date.
29
- def self.diff_all! clazz, cucumber_table
30
- cucumparer = Cucumparer.new clazz, cucumber_table
29
+ def self.diff_all! clazz, cucumber_table, context: {}
30
+ cucumparer = Cucumparer.new clazz, cucumber_table, context
31
31
  cucumber_table.diff! cucumparer.to_horizontal_table
32
32
  end
33
33
 
34
34
 
35
35
  # Verifies that the given object matches the given vertical Cucumber table
36
- def self.diff_one! object, cucumber_table
37
- cucumparer = Cucumparer.new object.class, cucumber_table
36
+ def self.diff_one! object, cucumber_table, context: {}
37
+ cucumparer = Cucumparer.new object.class, cucumber_table, context
38
38
  cucumber_table.diff! cucumparer.to_vertical_table(object)
39
39
  end
40
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Goslar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-28 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord