veritas-sql-generator 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,17 @@
1
+ language: ruby
1
2
  bundler_args: --without guard metrics
2
3
  script: "bundle exec rake spec"
3
4
  rvm:
4
5
  - 1.8.7
5
6
  - 1.9.2
6
7
  - 1.9.3
7
- - ruby-head
8
+ - jruby-18mode
9
+ - jruby-19mode
10
+ - rbx-18mode
11
+ - rbx-19mode
8
12
  - ree
9
- - jruby
10
- - rbx
11
- - rbx-2.0
13
+ - ruby-head
14
+ - jruby-head
15
+ notifications:
16
+ email:
17
+ - dan.kubb@gmail.com
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- source :rubygems
3
+ source 'https://rubygems.org'
4
4
 
5
- gem 'veritas', '~> 0.0.6', :git => 'git://github.com/dkubb/veritas.git'
5
+ gem 'veritas', '~> 0.0.7', :git => 'git://github.com/dkubb/veritas.git'
6
6
 
7
7
  group :development do
8
8
  gem 'backports', '~> 2.3.0'
@@ -3,6 +3,7 @@
3
3
  # Extend DateTime with methods available in ruby 1.9
4
4
  class DateTime
5
5
 
6
+ # TODO: remove the rbx guard when fractional seconds are handled properly in 1.9 mode
6
7
  SEC_FRACTION_MULTIPLIER = RUBY_VERSION < '1.9' ? 60 * 60 * 24 : 1
7
8
 
8
9
  # Return the DateTime in ISO8601 date-time format
@@ -3,7 +3,7 @@
3
3
  module Veritas
4
4
  module SQL
5
5
  module Generator
6
- VERSION = '0.0.6'
6
+ VERSION = '0.0.7'
7
7
  end # module Generator
8
8
  end # module SQL
9
9
  end # module Veritas
@@ -4,3 +4,4 @@
4
4
  --xrefs
5
5
  --profile
6
6
  --text-summary
7
+ --failure-threshold 100
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'backports'
5
- require 'backports/basic_object'
5
+ require 'backports/basic_object' unless RUBY_VERSION >= '1.9.2' && (RUBY_PLATFORM.include?('java') || RUBY_ENGINE == 'rbx')
6
6
  require 'veritas-sql-generator'
7
7
  require 'spec'
8
8
  require 'spec/autorun'
@@ -0,0 +1,112 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe DateTime, '#iso8601' do
6
+
7
+ # ruby 1.9.3 has problems with fractional nanoseconds
8
+ def self.it_supports_nanoseconds(message = 'returns the expected date-time', &block)
9
+ if RUBY_VERSION >= '1.9.3'
10
+ it(message) { pending('Fix rounding error in 1.9.3', &block) }
11
+ else
12
+ it(message, &block)
13
+ end
14
+ end
15
+
16
+ let(:object) { described_class.new(2010, 12, 31, 23, 59, 59 + nsec_in_seconds) }
17
+ let(:nsec_in_seconds) { 1 - Rational(1, 10**9) }
18
+
19
+ context 'with no arguments' do
20
+ subject { object.iso8601 }
21
+
22
+ context 'when the datetime is frozen' do
23
+ before do
24
+ object.freeze
25
+ end
26
+
27
+ it { should respond_to(:to_s) }
28
+
29
+ it_supports_nanoseconds do
30
+ should == '2010-12-31T23:59:59+00:00'
31
+ end
32
+ end
33
+
34
+ context 'when the datetime is not frozen' do
35
+ it { should respond_to(:to_s) }
36
+
37
+ it { should == '2010-12-31T23:59:59+00:00' }
38
+ end
39
+ end
40
+
41
+ context 'with a time scale of 0' do
42
+ subject { object.iso8601(time_scale) }
43
+
44
+ let(:time_scale) { 0 }
45
+
46
+ context 'when the datetime is frozen' do
47
+ before do
48
+ object.freeze
49
+ end
50
+
51
+ it { should respond_to(:to_s) }
52
+
53
+ it_supports_nanoseconds do
54
+ should == '2010-12-31T23:59:59+00:00'
55
+ end
56
+ end
57
+
58
+ context 'when the datetime is not frozen' do
59
+ it { should respond_to(:to_s) }
60
+
61
+ it { should == '2010-12-31T23:59:59+00:00' }
62
+ end
63
+ end
64
+
65
+ context 'with a time scale of 1' do
66
+ subject { object.iso8601(time_scale) }
67
+
68
+ let(:time_scale) { 1 }
69
+
70
+ context 'when the datetime is frozen' do
71
+ before do
72
+ object.freeze
73
+ end
74
+
75
+ it { should respond_to(:to_s) }
76
+
77
+ it_supports_nanoseconds do
78
+ should == '2010-12-31T23:59:59.9+00:00'
79
+ end
80
+ end
81
+
82
+ context 'when the datetime is not frozen' do
83
+ it { should respond_to(:to_s) }
84
+
85
+ it { should == '2010-12-31T23:59:59.9+00:00' }
86
+ end
87
+ end
88
+
89
+ context 'with a time scale of 9' do
90
+ subject { object.iso8601(time_scale) }
91
+
92
+ let(:time_scale) { 9 }
93
+
94
+ context 'when the datetime is frozen' do
95
+ before do
96
+ object.freeze
97
+ end
98
+
99
+ it { should respond_to(:to_s) }
100
+
101
+ it_supports_nanoseconds do
102
+ should == '2010-12-31T23:59:59.999999999+00:00'
103
+ end
104
+ end
105
+
106
+ context 'when the datetime is not frozen' do
107
+ it { should respond_to(:to_s) }
108
+
109
+ it { should == '2010-12-31T23:59:59.999999999+00:00' }
110
+ end
111
+ end
112
+ end
@@ -21,16 +21,13 @@ describe SQL::Generator::Literal, '#visit_date_time' do
21
21
  its(:to_s) { should eql("'2010-12-31T23:59:59.000000000+00:00'") }
22
22
  end
23
23
 
24
- # rubinius 1.2.3 has problems with fractional seconds above 59
25
- unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' && Rubinius::VERSION <= '1.2.3'
26
- context 'and the nanoseconds are greater than 0' do
27
- let(:nsec) { 1 }
28
- let(:date_time) { DateTime.new(2010, 12, 31, 23, 59, 59 + nsec_in_seconds, offset).freeze }
24
+ context 'and the nanoseconds are greater than 0' do
25
+ let(:nsec) { 1 }
26
+ let(:date_time) { DateTime.new(2010, 12, 31, 23, 59, 59 + nsec_in_seconds, offset).freeze }
29
27
 
30
- it_should_behave_like 'a generated SQL expression'
28
+ it_should_behave_like 'a generated SQL expression'
31
29
 
32
- its(:to_s) { should eql("'2010-12-31T23:59:59.000000001+00:00'") }
33
- end
30
+ its(:to_s) { should eql("'2010-12-31T23:59:59.000000001+00:00'") }
34
31
  end
35
32
  end
36
33
 
@@ -46,16 +43,13 @@ describe SQL::Generator::Literal, '#visit_date_time' do
46
43
  its(:to_s) { should eql("'2010-12-31T23:59:59.000000000+00:00'") }
47
44
  end
48
45
 
49
- # rubinius 1.2.3 has problems with fractional seconds above 59
50
- unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' && Rubinius::VERSION <= '1.2.3'
51
- context 'and the nanoseconds are greater than 0' do
52
- let(:nsec) { 1 }
53
- let(:date_time) { DateTime.new(2010, 12, 31, 15, 59, 59 + nsec_in_seconds, offset).freeze }
46
+ context 'and the nanoseconds are greater than 0' do
47
+ let(:nsec) { 1 }
48
+ let(:date_time) { DateTime.new(2010, 12, 31, 15, 59, 59 + nsec_in_seconds, offset).freeze }
54
49
 
55
- it_should_behave_like 'a generated SQL expression'
50
+ it_should_behave_like 'a generated SQL expression'
56
51
 
57
- its(:to_s) { should eql("'2010-12-31T23:59:59.000000001+00:00'") }
58
- end
52
+ its(:to_s) { should eql("'2010-12-31T23:59:59.000000001+00:00'") }
59
53
  end
60
54
  end
61
55
  end
@@ -5,9 +5,9 @@ require 'spec_helper'
5
5
  describe SQL::Generator::Literal, '#visit_time' do
6
6
  subject { object.visit_time(time) }
7
7
 
8
- # Time#iso8601 is currently broken in JRuby 1.6.2 when fractional seconds are not 0
8
+ # Time#iso8601 is currently broken in JRuby 1.7.0.dev when fractional seconds are not 0
9
9
  def self.time_iso8601_broken?
10
- RUBY_PLATFORM.include?('java') && JRUBY_VERSION <= '1.6.2' && RUBY_VERSION >= '1.9.2'
10
+ RUBY_PLATFORM.include?('java') && JRUBY_VERSION <= '1.7.0.dev' && RUBY_VERSION >= '1.9.2'
11
11
  end
12
12
 
13
13
  let(:described_class) { Class.new(SQL::Generator::Visitor) { include SQL::Generator::Literal } }
@@ -1,7 +1,7 @@
1
1
  desc 'Run metrics with Heckle'
2
- task :ci => [ 'ci:metrics', :heckle ]
2
+ task :ci => %w[ ci:metrics heckle ]
3
3
 
4
4
  namespace :ci do
5
5
  desc 'Run metrics'
6
- task :metrics => [ :verify_measurements, :flog, :flay, :reek, :roodi, 'metrics:all' ]
6
+ task :metrics => %w[ verify_measurements flog flay reek roodi metrics:all ]
7
7
  end
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
6
6
  begin
7
7
  require 'pathname'
8
8
  require 'backports'
9
- require 'backports/basic_object'
9
+ require 'backports/basic_object' unless RUBY_VERSION >= '1.9.2' && (RUBY_PLATFORM.include?('java') || RUBY_ENGINE == 'rbx')
10
10
  require 'active_support/inflector'
11
11
  require 'heckle'
12
12
  require 'mspec'
@@ -27,13 +27,16 @@ begin
27
27
  end
28
28
 
29
29
  desc 'Heckle each module and class'
30
- task :heckle => :verify_rcov do
30
+ task :heckle => :rcov do
31
31
  unless Ruby2Ruby::VERSION == '1.2.2'
32
32
  raise "ruby2ruby version #{Ruby2Ruby::VERSION} may not work properly, 1.2.2 *only* is recommended for use with heckle"
33
33
  end
34
34
 
35
35
  require 'veritas/sql/generator'
36
- root_module = 'Veritas::SQL::Generator'
36
+
37
+ root_module_regexp = Regexp.union(
38
+ 'Veritas::SQL::Generator'
39
+ )
37
40
 
38
41
  spec_dir = Pathname('spec/unit')
39
42
 
@@ -50,7 +53,7 @@ begin
50
53
  unhandled_mutations = 0
51
54
 
52
55
  ObjectSpace.each_object(Module) do |mod|
53
- next unless mod.name =~ /\A#{root_module}(?::|\z)/
56
+ next unless mod.name =~ /\A#{root_module_regexp}(?::|\z)/
54
57
 
55
58
  spec_prefix = spec_dir.join(mod.name.underscore)
56
59
 
@@ -135,9 +138,9 @@ begin
135
138
  descedant_specs = []
136
139
 
137
140
  ObjectSpace.each_object(Module) do |descedant|
138
- next unless descedant.name =~ /\A#{root_module}(?::|\z)/ && mod >= descedant
141
+ next unless descedant.name =~ /\A#{root_module_regexp}(?::|\z)/ && mod >= descedant
139
142
  descedant_spec_prefix = spec_dir.join(descedant.name.underscore)
140
- descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('*_spec.rb')))
143
+ descedant_specs << descedant_spec_prefix
141
144
 
142
145
  if method.to_s == 'initialize'
143
146
  descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/new_spec.rb')))
@@ -151,9 +154,8 @@ begin
151
154
  descedant_specs = []
152
155
 
153
156
  ObjectSpace.each_object(Module) do |descedant|
154
- next unless descedant.name =~ /\A#{root_module}(?::|\z)/ && mod >= descedant
155
- descedant_spec_prefix = spec_dir.join(descedant.name.underscore)
156
- descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/*_spec.rb')))
157
+ next unless descedant.name =~ /\A#{root_module_regexp}(?::|\z)/ && mod >= descedant
158
+ descedant_specs << spec_dir.join(descedant.name.underscore).join('class_methods')
157
159
  end
158
160
 
159
161
  specs << [ ".#{method}", descedant_specs ]
@@ -1,37 +1,46 @@
1
1
  spec_defaults = lambda do |spec|
2
- spec.pattern = 'spec/**/*_spec.rb'
3
- spec.libs << 'lib' << 'spec'
4
2
  spec.spec_opts << '--options' << 'spec/spec.opts'
5
3
  end
6
4
 
7
5
  begin
8
6
  require 'spec/rake/spectask'
9
7
 
10
- Spec::Rake::SpecTask.new(:spec, &spec_defaults)
8
+ desc 'Run all specs'
9
+ task :spec => %w[ spec:unit spec:integration ]
10
+
11
+ namespace :spec do
12
+ desc 'Run unit specs'
13
+ Spec::Rake::SpecTask.new(:unit) do |unit|
14
+ spec_defaults.call(unit)
15
+ unit.pattern = 'spec/unit/**/*_spec.rb'
16
+ end
17
+
18
+ desc 'Run integration specs'
19
+ Spec::Rake::SpecTask.new(:integration) do |integration|
20
+ spec_defaults.call(integration)
21
+ integration.pattern = 'spec/integration/**/*_spec.rb'
22
+ end
23
+ end
11
24
  rescue LoadError
12
- task :spec do
13
- abort 'rspec is not available. In order to run spec, you must: gem install rspec'
25
+ %w[ spec spec:unit spec:integration ].each do |name|
26
+ task name do
27
+ abort "rspec is not available. In order to run #{name}, you must: gem install rspec"
28
+ end
14
29
  end
15
30
  end
16
31
 
17
32
  begin
18
33
  require 'rcov'
19
- require 'spec/rake/verify_rcov'
20
34
 
21
35
  Spec::Rake::SpecTask.new(:rcov) do |rcov|
22
36
  spec_defaults.call(rcov)
23
37
  rcov.rcov = true
38
+ rcov.pattern = 'spec/unit/**/*_spec.rb'
24
39
  rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
25
40
  end
26
-
27
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
28
- rcov.threshold = 100
29
- end
30
41
  rescue LoadError
31
- %w[ rcov verify_rcov ].each do |name|
32
- task name do
33
- abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
34
- end
42
+ task :rcov do
43
+ abort 'rcov is not available. In order to run rcov, you must: gem install rcov'
35
44
  end
36
45
  end
37
46
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "veritas-sql-generator"
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Kubb"]
12
- s.date = "2011-10-04"
12
+ s.date = "2012-03-08"
13
13
  s.description = "Generate SQL from a veritas relation"
14
14
  s.email = "dan.kubb@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -61,7 +61,7 @@ Gem::Specification.new do |s|
61
61
  "spec/spec.opts",
62
62
  "spec/spec_helper.rb",
63
63
  "spec/unit/date/iso8601_spec.rb",
64
- "spec/unit/date_time/iso_8601_spec.rb",
64
+ "spec/unit/date_time/iso8601_spec.rb",
65
65
  "spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb",
66
66
  "spec/unit/veritas/sql/generator/class_methods/parenthesize_spec.rb",
67
67
  "spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb",
@@ -157,21 +157,21 @@ Gem::Specification.new do |s|
157
157
  ]
158
158
  s.homepage = "https://github.com/dkubb/veritas-sql-generator"
159
159
  s.require_paths = ["lib"]
160
- s.rubygems_version = "1.8.10"
160
+ s.rubygems_version = "1.8.16"
161
161
  s.summary = "Relational algebra SQL generator"
162
162
 
163
163
  if s.respond_to? :specification_version then
164
164
  s.specification_version = 3
165
165
 
166
166
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
167
- s.add_runtime_dependency(%q<veritas>, ["~> 0.0.6"])
167
+ s.add_runtime_dependency(%q<veritas>, ["~> 0.0.7"])
168
168
  s.add_development_dependency(%q<backports>, ["~> 2.3.0"])
169
169
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
170
170
  s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
171
171
  s.add_development_dependency(%q<rspec>, ["~> 1.3.2"])
172
172
  s.add_development_dependency(%q<yard>, ["~> 0.7.2"])
173
173
  else
174
- s.add_dependency(%q<veritas>, ["~> 0.0.6"])
174
+ s.add_dependency(%q<veritas>, ["~> 0.0.7"])
175
175
  s.add_dependency(%q<backports>, ["~> 2.3.0"])
176
176
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
177
177
  s.add_dependency(%q<rake>, ["~> 0.9.2"])
@@ -179,7 +179,7 @@ Gem::Specification.new do |s|
179
179
  s.add_dependency(%q<yard>, ["~> 0.7.2"])
180
180
  end
181
181
  else
182
- s.add_dependency(%q<veritas>, ["~> 0.0.6"])
182
+ s.add_dependency(%q<veritas>, ["~> 0.0.7"])
183
183
  s.add_dependency(%q<backports>, ["~> 2.3.0"])
184
184
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
185
185
  s.add_dependency(%q<rake>, ["~> 0.9.2"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veritas-sql-generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Kubb
@@ -15,28 +15,27 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-04 00:00:00 Z
18
+ date: 2012-03-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
25
  - - ~>
27
26
  - !ruby/object:Gem::Version
28
- hash: 19
27
+ hash: 17
29
28
  segments:
30
29
  - 0
31
30
  - 0
32
- - 6
33
- version: 0.0.6
34
- version_requirements: *id001
31
+ - 7
32
+ version: 0.0.7
33
+ prerelease: false
34
+ requirement: *id001
35
35
  name: veritas
36
36
  - !ruby/object:Gem::Dependency
37
37
  type: :development
38
- prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -47,12 +46,12 @@ dependencies:
47
46
  - 3
48
47
  - 0
49
48
  version: 2.3.0
50
- version_requirements: *id002
49
+ prerelease: false
50
+ requirement: *id002
51
51
  name: backports
52
52
  - !ruby/object:Gem::Dependency
53
53
  type: :development
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
55
  none: false
57
56
  requirements:
58
57
  - - ~>
@@ -63,12 +62,12 @@ dependencies:
63
62
  - 6
64
63
  - 4
65
64
  version: 1.6.4
66
- version_requirements: *id003
65
+ prerelease: false
66
+ requirement: *id003
67
67
  name: jeweler
68
68
  - !ruby/object:Gem::Dependency
69
69
  type: :development
70
- prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
72
71
  none: false
73
72
  requirements:
74
73
  - - ~>
@@ -79,12 +78,12 @@ dependencies:
79
78
  - 9
80
79
  - 2
81
80
  version: 0.9.2
82
- version_requirements: *id004
81
+ prerelease: false
82
+ requirement: *id004
83
83
  name: rake
84
84
  - !ruby/object:Gem::Dependency
85
85
  type: :development
86
- prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
86
+ version_requirements: &id005 !ruby/object:Gem::Requirement
88
87
  none: false
89
88
  requirements:
90
89
  - - ~>
@@ -95,12 +94,12 @@ dependencies:
95
94
  - 3
96
95
  - 2
97
96
  version: 1.3.2
98
- version_requirements: *id005
97
+ prerelease: false
98
+ requirement: *id005
99
99
  name: rspec
100
100
  - !ruby/object:Gem::Dependency
101
101
  type: :development
102
- prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
102
+ version_requirements: &id006 !ruby/object:Gem::Requirement
104
103
  none: false
105
104
  requirements:
106
105
  - - ~>
@@ -111,7 +110,8 @@ dependencies:
111
110
  - 7
112
111
  - 2
113
112
  version: 0.7.2
114
- version_requirements: *id006
113
+ prerelease: false
114
+ requirement: *id006
115
115
  name: yard
116
116
  description: Generate SQL from a veritas relation
117
117
  email: dan.kubb@gmail.com
@@ -167,7 +167,7 @@ files:
167
167
  - spec/spec.opts
168
168
  - spec/spec_helper.rb
169
169
  - spec/unit/date/iso8601_spec.rb
170
- - spec/unit/date_time/iso_8601_spec.rb
170
+ - spec/unit/date_time/iso8601_spec.rb
171
171
  - spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb
172
172
  - spec/unit/veritas/sql/generator/class_methods/parenthesize_spec.rb
173
173
  - spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  requirements: []
290
290
 
291
291
  rubyforge_project:
292
- rubygems_version: 1.8.10
292
+ rubygems_version: 1.8.16
293
293
  signing_key:
294
294
  specification_version: 3
295
295
  summary: Relational algebra SQL generator
@@ -1,115 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe DateTime, '#iso8601' do
6
-
7
- # ruby 1.9.3 has problems with fractional nanoseconds
8
- def self.it_supports_nanoseconds(message = 'returns the expected date-time', &block)
9
- if RUBY_VERSION >= '1.9.3'
10
- it(message) { pending('Fix rounding error in 1.9.3', &block) }
11
- else
12
- it(message, &block)
13
- end
14
- end
15
-
16
- let(:object) { described_class.new(2010, 12, 31, 23, 59, 59 + nsec_in_seconds) }
17
- let(:nsec_in_seconds) { 1 - Rational(1, 10**9) }
18
-
19
- # rubinius 1.2.3 has problems with fractional seconds above 59
20
- unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' && Rubinius::VERSION <= '1.2.3'
21
- context 'with no arguments' do
22
- subject { object.iso8601 }
23
-
24
- context 'when the datetime is frozen' do
25
- before do
26
- object.freeze
27
- end
28
-
29
- it { should respond_to(:to_s) }
30
-
31
- it_supports_nanoseconds do
32
- should == '2010-12-31T23:59:59+00:00'
33
- end
34
- end
35
-
36
- context 'when the datetime is not frozen' do
37
- it { should respond_to(:to_s) }
38
-
39
- it { should == '2010-12-31T23:59:59+00:00' }
40
- end
41
- end
42
-
43
- context 'with a time scale of 0' do
44
- subject { object.iso8601(time_scale) }
45
-
46
- let(:time_scale) { 0 }
47
-
48
- context 'when the datetime is frozen' do
49
- before do
50
- object.freeze
51
- end
52
-
53
- it { should respond_to(:to_s) }
54
-
55
- it_supports_nanoseconds do
56
- should == '2010-12-31T23:59:59+00:00'
57
- end
58
- end
59
-
60
- context 'when the datetime is not frozen' do
61
- it { should respond_to(:to_s) }
62
-
63
- it { should == '2010-12-31T23:59:59+00:00' }
64
- end
65
- end
66
-
67
- context 'with a time scale of 1' do
68
- subject { object.iso8601(time_scale) }
69
-
70
- let(:time_scale) { 1 }
71
-
72
- context 'when the datetime is frozen' do
73
- before do
74
- object.freeze
75
- end
76
-
77
- it { should respond_to(:to_s) }
78
-
79
- it_supports_nanoseconds do
80
- should == '2010-12-31T23:59:59.9+00:00'
81
- end
82
- end
83
-
84
- context 'when the datetime is not frozen' do
85
- it { should respond_to(:to_s) }
86
-
87
- it { should == '2010-12-31T23:59:59.9+00:00' }
88
- end
89
- end
90
-
91
- context 'with a time scale of 9' do
92
- subject { object.iso8601(time_scale) }
93
-
94
- let(:time_scale) { 9 }
95
-
96
- context 'when the datetime is frozen' do
97
- before do
98
- object.freeze
99
- end
100
-
101
- it { should respond_to(:to_s) }
102
-
103
- it_supports_nanoseconds do
104
- should == '2010-12-31T23:59:59.999999999+00:00'
105
- end
106
- end
107
-
108
- context 'when the datetime is not frozen' do
109
- it { should respond_to(:to_s) }
110
-
111
- it { should == '2010-12-31T23:59:59.999999999+00:00' }
112
- end
113
- end
114
- end
115
- end