aruba 0.10.0.pre → 0.10.0.pre2

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: f28f6c27992873436132f1a1026bf1fefca105da
4
- data.tar.gz: a84562c8730d436682f1e297e9a1f93e5875cc54
3
+ metadata.gz: 8629fdb3cc71266ccb714b5423728671ef1216b9
4
+ data.tar.gz: 5451d0a593fcb71b59275a3b83f7ecdbacc79d8d
5
5
  SHA512:
6
- metadata.gz: 3cef82f178232a44414a87e5e4b8f1b7582974b4e1e1517defd7154343a5c21a59778951ef71116dae59ea76870924f9945d35f2e69894c637c4f36448a6a424
7
- data.tar.gz: 8cdd376cb0f7f4d2d70e508135e6b679ec288a5cbd55c55ebbe7d58972da4261a9ccec084017ee1fe5f1cc736f9cc434f2357169fdabd7c2f212ed04a5a31646
6
+ metadata.gz: b61b360369dd57186dc7a4de4c0e2c5c367fa3109a0ed4d63205f704787344392e9b677216fc00b2d5eb33a19ed0c66b8c087d3d08492260911033d2655d813b
7
+ data.tar.gz: 3e69d2bdc444786404a5e09edef498afb4c5f6a041858d950ff90528c87d01971eb550977b8ed65e8c9a3fe9729d02eecba9ec03ce4ae84f51d7fe0349e695d7
data/.travis.yml CHANGED
@@ -19,9 +19,9 @@ rvm:
19
19
  matrix:
20
20
  allow_failures:
21
21
  - rvm: rbx
22
- - rvm: jrbuby-9.0.0.0
23
- - rvm: jrbuby-9.0.0.0-20mode
24
- - rvm: jrbuby-9.0.0.0-21mode
22
+ - rvm: jruby-9.0.0.0
23
+ - rvm: jruby-9.0.0.0-20mode
24
+ - rvm: jruby-9.0.0.0-21mode
25
25
  notifications:
26
26
  email:
27
27
  - cukes-devs@googlegroups.com
data/History.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Latest Release
2
2
 
3
+ ## [v0.10.0.pre2](https://github.com/cucumber/aruba/compare/v0.10.0.pre...v0.10.0.pre2)
4
+
5
+ * Take over code from `RSpec::Support::ObjectFormatter` since `rspec-support`
6
+ is not intended for public use.
7
+
8
+ # Old releases
9
+
3
10
  ## [v0.10.0.pre](https://github.com/cucumber/aruba/compare/v0.9.0...v0.10.0)
4
11
 
5
12
  * Add some new steps to make writing documentation easier using "cucumber",
@@ -14,7 +21,6 @@
14
21
  * Added work around because of method name conflict between Capybara and RSpec
15
22
  (https://github.com/cucumber/aruba/commit/1939c4049d5195ffdd967485f50119bdd86e98a0)
16
23
 
17
- # Old releases
18
24
 
19
25
  ## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.9.0.pre2...v0.9.0)
20
26
 
@@ -1,4 +1,4 @@
1
- require 'rspec/support/object_formatter'
1
+ require 'aruba/matchers/base/object_formatter'
2
2
 
3
3
  module Aruba
4
4
  module Matchers
@@ -87,7 +87,7 @@ module Aruba
87
87
  # a `description` method, returns the description; otherwise
88
88
  # returns `object.inspect`.
89
89
  def description_of(object)
90
- RSpec::Support::ObjectFormatter.format(object)
90
+ Aruba::Matchers::ObjectFormatter.format(object)
91
91
  end
92
92
  end
93
93
  end
@@ -0,0 +1,110 @@
1
+ module Aruba
2
+ module Matchers
3
+ # Provide additional output details beyond what `inspect` provides when
4
+ # printing Time, DateTime, or BigDecimal
5
+ module ObjectFormatter
6
+ # @api private
7
+ def self.format(object)
8
+ prepare_for_inspection(object).inspect
9
+ end
10
+
11
+ # rubocop:disable MethodLength
12
+ # rubocop:disable Metrics/CyclomaticComplexity
13
+
14
+ # @private
15
+ # Prepares the provided object to be formatted by wrapping it as needed
16
+ # in something that, when `inspect` is called on it, will produce the
17
+ # desired output.
18
+ #
19
+ # This allows us to apply the desired formatting to hash/array data structures
20
+ # at any level of nesting, simply by walking that structure and replacing items
21
+ # with custom items that have `inspect` defined to return the desired output
22
+ # for that item. Then we can just use `Array#inspect` or `Hash#inspect` to
23
+ # format the entire thing.
24
+ def self.prepare_for_inspection(object)
25
+ case object
26
+ when Array
27
+ return object.map { |o| prepare_for_inspection(o) }
28
+ when Hash
29
+ return prepare_hash(object)
30
+ when Time
31
+ inspection = format_time(object)
32
+ else
33
+ if defined?(DateTime) && DateTime === object
34
+ inspection = format_date_time(object)
35
+ elsif defined?(BigDecimal) && BigDecimal === object
36
+ inspection = "#{object.to_s 'F'} (#{object.inspect})"
37
+ elsif RSpec::Support.is_a_matcher?(object) && object.respond_to?(:description)
38
+ inspection = object.description
39
+ else
40
+ return DelegatingInspector.new(object)
41
+ end
42
+ end
43
+
44
+ InspectableItem.new(inspection)
45
+ end
46
+ # rubocop:enable Metrics/CyclomaticComplexity
47
+ # rubocop:enable MethodLength
48
+
49
+ # @private
50
+ def self.prepare_hash(input)
51
+ input.each_with_object({}) do |(k, v), hash|
52
+ hash[prepare_for_inspection(k)] = prepare_for_inspection(v)
53
+ end
54
+ end
55
+
56
+ TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
57
+
58
+ if Time.method_defined?(:nsec)
59
+ # @private
60
+ def self.format_time(time)
61
+ time.strftime("#{TIME_FORMAT}.#{format('%09d', time.nsec)} %z")
62
+ end
63
+ else # for 1.8.7
64
+ # @private
65
+ def self.format_time(time)
66
+ time.strftime("#{TIME_FORMAT}.#{format('%06d', time.usec)} %z")
67
+ end
68
+ end
69
+
70
+ DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z"
71
+
72
+ # ActiveSupport sometimes overrides inspect. If `ActiveSupport` is
73
+ # defined use a custom format string that includes more time precision.
74
+ # @private
75
+ def self.format_date_time(date_time)
76
+ if defined?(ActiveSupport)
77
+ date_time.strftime(DATE_TIME_FORMAT)
78
+ else
79
+ date_time.inspect
80
+ end
81
+ end
82
+
83
+ # @private
84
+ InspectableItem = Struct.new(:inspection) do
85
+ def inspect
86
+ inspection
87
+ end
88
+
89
+ def pretty_print(pp)
90
+ pp.text inspection
91
+ end
92
+ end
93
+
94
+ # @private
95
+ DelegatingInspector = Struct.new(:object) do
96
+ def inspect
97
+ if defined?(::Delegator) && ::Delegator === object
98
+ "#<#{object.class}(#{ObjectFormatter.format(object.__getobj__)})>"
99
+ else
100
+ object.inspect
101
+ end
102
+ end
103
+
104
+ def pretty_print(pp)
105
+ pp.text inspect
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
data/lib/aruba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aruba
2
- VERSION = '0.10.0.pre'
2
+ VERSION = '0.10.0.pre2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aruba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.pre
4
+ version: 0.10.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2015-10-17 00:00:00.000000000 Z
16
+ date: 2015-10-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: cucumber
@@ -292,6 +292,7 @@ files:
292
292
  - lib/aruba/initializer.rb
293
293
  - lib/aruba/jruby.rb
294
294
  - lib/aruba/matchers/base/base_matcher.rb
295
+ - lib/aruba/matchers/base/object_formatter.rb
295
296
  - lib/aruba/matchers/collection.rb
296
297
  - lib/aruba/matchers/collection/all.rb
297
298
  - lib/aruba/matchers/collection/include_an_object.rb
@@ -431,7 +432,7 @@ rubyforge_project:
431
432
  rubygems_version: 2.4.5.1
432
433
  signing_key:
433
434
  specification_version: 4
434
- summary: aruba-0.10.0.pre
435
+ summary: aruba-0.10.0.pre2
435
436
  test_files:
436
437
  - features/announce.feature
437
438
  - features/api/command/run.feature