ar_default_values 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -13,4 +13,5 @@ group :development do
13
13
  gem "rdoc"
14
14
  gem "bundler"
15
15
  gem "jeweler"
16
+ gem "sqlite3"
16
17
  end
data/Gemfile.lock CHANGED
@@ -35,6 +35,7 @@ GEM
35
35
  rspec-expectations (2.9.0)
36
36
  diff-lcs (~> 1.1.3)
37
37
  rspec-mocks (2.9.0)
38
+ sqlite3 (1.3.5)
38
39
  tzinfo (0.3.32)
39
40
 
40
41
  PLATFORMS
@@ -47,3 +48,4 @@ DEPENDENCIES
47
48
  jeweler
48
49
  rdoc
49
50
  rspec
51
+ sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ar_default_values"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["masarakki"]
12
- s.date = "2012-03-23"
12
+ s.date = "2012-03-24"
13
13
  s.description = "ActiveRecord with default values"
14
14
  s.email = "masaki@hisme.net"
15
15
  s.extra_rdoc_files = [
@@ -28,12 +28,14 @@ Gem::Specification.new do |s|
28
28
  "ar_default_values.gemspec",
29
29
  "lib/ar_default_values.rb",
30
30
  "spec/ar_default_values_spec.rb",
31
- "spec/spec_helper.rb"
31
+ "spec/spec_helper.rb",
32
+ "spec/test.sqlite3",
33
+ "test.sqlite3"
32
34
  ]
33
35
  s.homepage = "http://github.com/masarakki/ar_default_values"
34
36
  s.licenses = ["MIT"]
35
37
  s.require_paths = ["lib"]
36
- s.rubygems_version = "1.8.10"
38
+ s.rubygems_version = "1.8.15"
37
39
  s.summary = "ActiveRecord with default values"
38
40
 
39
41
  if s.respond_to? :specification_version then
@@ -46,6 +48,7 @@ Gem::Specification.new do |s|
46
48
  s.add_development_dependency(%q<rdoc>, [">= 0"])
47
49
  s.add_development_dependency(%q<bundler>, [">= 0"])
48
50
  s.add_development_dependency(%q<jeweler>, [">= 0"])
51
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
49
52
  else
50
53
  s.add_dependency(%q<activesupport>, [">= 0"])
51
54
  s.add_dependency(%q<activerecord>, [">= 0"])
@@ -53,6 +56,7 @@ Gem::Specification.new do |s|
53
56
  s.add_dependency(%q<rdoc>, [">= 0"])
54
57
  s.add_dependency(%q<bundler>, [">= 0"])
55
58
  s.add_dependency(%q<jeweler>, [">= 0"])
59
+ s.add_dependency(%q<sqlite3>, [">= 0"])
56
60
  end
57
61
  else
58
62
  s.add_dependency(%q<activesupport>, [">= 0"])
@@ -61,6 +65,7 @@ Gem::Specification.new do |s|
61
65
  s.add_dependency(%q<rdoc>, [">= 0"])
62
66
  s.add_dependency(%q<bundler>, [">= 0"])
63
67
  s.add_dependency(%q<jeweler>, [">= 0"])
68
+ s.add_dependency(%q<sqlite3>, [">= 0"])
64
69
  end
65
70
  end
66
71
 
@@ -1,17 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
 
4
- class Sample < ActiveRecord::Base
5
-
6
- define_attribute_methods ['foo', 'bar', 'buzz', 'other']
7
- attr_accessor :foo, :bar, :buzz, :other
8
-
4
+ class Book < ActiveRecord::Base
9
5
  default_values do
10
6
  lambda do
11
7
  {
12
- :foo => 'foo',
13
- :bar => 'bar',
14
- :time => Time.now
8
+ :price => 0,
9
+ :edition => 1,
10
+ :released_at => Time.now
15
11
  }
16
12
  end
17
13
  end
@@ -20,12 +16,36 @@ end
20
16
  describe "ArDefaultValues" do
21
17
  subject { @sample }
22
18
  before do
23
- @t = Time.now
24
- Time.stub(:now).and_return(@t)
25
- @sample = Sample.new(:bar => 'test')
19
+ @now = Time.now
20
+ Time.stub(:now).and_return(@now)
21
+ end
22
+ context :without_attributes do
23
+ before do
24
+ @sample = Book.new
25
+ end
26
+ its(:title) { should be_nil }
27
+ its(:price) { should == 0 }
28
+ its(:edition) { should == 1 }
29
+ its(:released_at) { should == @now }
30
+ end
31
+ context :with_attributes do
32
+ before do
33
+ @sample = Book.new(:price => 100)
34
+ end
35
+ its(:title) { should be_nil }
36
+ its(:price) { should == 100 }
37
+ its(:edition) { should == 1 }
38
+ its(:released_at) { should == @now }
39
+ end
40
+ context :with_block do
41
+ before do
42
+ @sample = Book.new(:edition => 3) do |t|
43
+ t.title = 'foo'
44
+ end
45
+ end
46
+ its(:title) { should == 'foo' }
47
+ its(:price) { should == 0 }
48
+ its(:edition) { should == 3 }
49
+ its(:released_at) { should == @now }
26
50
  end
27
- its(:foo) { should == 'foo' }
28
- its(:bar) { should == 'test' }
29
- its(:buzz) { should be_nil }
30
- its(:time) { should == @t }
31
51
  end
data/spec/spec_helper.rb CHANGED
@@ -8,5 +8,7 @@ require 'ar_default_values'
8
8
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
9
 
10
10
  RSpec.configure do |config|
11
-
11
+
12
12
  end
13
+
14
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'spec/test.sqlite3')
data/spec/test.sqlite3 ADDED
Binary file
data/test.sqlite3 ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_default_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-23 00:00:00.000000000 Z
12
+ date: 2012-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &82056080 !ruby/object:Gem::Requirement
16
+ requirement: &12866580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82056080
24
+ version_requirements: *12866580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &82072030 !ruby/object:Gem::Requirement
27
+ requirement: &12861600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *82072030
35
+ version_requirements: *12861600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &82069630 !ruby/object:Gem::Requirement
38
+ requirement: &12873500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *82069630
46
+ version_requirements: *12873500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &82068230 !ruby/object:Gem::Requirement
49
+ requirement: &12870120 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *82068230
57
+ version_requirements: *12870120
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &82065550 !ruby/object:Gem::Requirement
60
+ requirement: &12867500 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *82065550
68
+ version_requirements: *12867500
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &82201020 !ruby/object:Gem::Requirement
71
+ requirement: &12881540 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,18 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *82201020
79
+ version_requirements: *12881540
80
+ - !ruby/object:Gem::Dependency
81
+ name: sqlite3
82
+ requirement: &12879380 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *12879380
80
91
  description: ActiveRecord with default values
81
92
  email: masaki@hisme.net
82
93
  executables: []
@@ -97,6 +108,8 @@ files:
97
108
  - lib/ar_default_values.rb
98
109
  - spec/ar_default_values_spec.rb
99
110
  - spec/spec_helper.rb
111
+ - spec/test.sqlite3
112
+ - test.sqlite3
100
113
  homepage: http://github.com/masarakki/ar_default_values
101
114
  licenses:
102
115
  - MIT
@@ -112,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
125
  version: '0'
113
126
  segments:
114
127
  - 0
115
- hash: 227115949
128
+ hash: -2944734096084027538
116
129
  required_rubygems_version: !ruby/object:Gem::Requirement
117
130
  none: false
118
131
  requirements:
@@ -121,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
134
  version: '0'
122
135
  requirements: []
123
136
  rubyforge_project:
124
- rubygems_version: 1.8.10
137
+ rubygems_version: 1.8.15
125
138
  signing_key:
126
139
  specification_version: 3
127
140
  summary: ActiveRecord with default values