with_model 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.1.4
2
+
3
+ Add ability to pass arguments to create_table.
4
+
1
5
  ### 0.1.2
2
6
 
3
- Make Mixico optional.
7
+ Make Mixico optional.
data/README.rdoc CHANGED
@@ -112,6 +112,19 @@ In an RSpec example group, call +with_model+ and inside its block pass it a +tab
112
112
  end
113
113
  end
114
114
 
115
+ describe "with table options" do
116
+ with_model :with_options do
117
+ table :id => false do |t|
118
+ t.string 'foo'
119
+ t.timestamps
120
+ end
121
+ end
122
+
123
+ it "should respect the additional options" do
124
+ WithOptions.columns.map(&:name).should_not include("id")
125
+ end
126
+ end
127
+
115
128
  === Mixico
116
129
 
117
130
  If you have the +mixico+ gem installed, WithModel will automatically unmix any modules that were mixed into your model class. Without +mixico+, each module will hold a reference to the class for the remainder of your test suite.
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
4
  environments = %w[rspec1 rspec2]
5
+ major, minor, revision = RUBY_VERSION.split(".").map{|str| str.to_i }
5
6
 
6
7
  in_environment = lambda do |environment, command|
7
8
  sh %Q{export BUNDLE_GEMFILE="gemfiles/#{environment}/Gemfile"; bundle --quiet && bundle exec #{command}}
@@ -21,7 +22,7 @@ autotest_styles = {
21
22
 
22
23
  desc "Run all specs against Rspec 1 and 2"
23
24
  task "spec" do
24
- in_environment.call('rspec1', 'spec spec')
25
+ in_environment.call('rspec1', 'spec spec') if major == 1 && minor < 9
25
26
  in_environment.call('rspec2', 'rspec spec')
26
27
  end
27
28
 
@@ -41,4 +42,4 @@ namespace "doc" do
41
42
  end
42
43
  end
43
44
 
44
- task :default => :spec
45
+ task :default => :spec
@@ -38,8 +38,8 @@ module WithModel
38
38
  end
39
39
  end
40
40
 
41
- def table(&block)
42
- @example_group.with_table(@table_name, &block)
41
+ def table(options = {}, &block)
42
+ @example_group.with_table(@table_name, options, &block)
43
43
  end
44
44
 
45
45
  def model(&block)
@@ -1,3 +1,3 @@
1
1
  module WithModel
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/with_model.rb CHANGED
@@ -5,11 +5,11 @@ module WithModel
5
5
  Dsl.new(name, self).instance_eval(&block)
6
6
  end
7
7
 
8
- def with_table(name, &block)
8
+ def with_table(name, options = {}, &block)
9
9
  connection = ActiveRecord::Base.connection
10
10
  before do
11
11
  connection.drop_table(name) if connection.table_exists?(name)
12
- connection.create_table(name, &block)
12
+ connection.create_table(name, options, &block)
13
13
  end
14
14
 
15
15
  after do
data/spec/readme_spec.rb CHANGED
@@ -78,4 +78,17 @@
78
78
  it "should not have the constant anymore" do
79
79
  defined?(BlogPost).should be_false
80
80
  end
81
- end
81
+ end
82
+
83
+ describe "with table options" do
84
+ with_model :with_options do
85
+ table :id => false do |t|
86
+ t.string 'foo'
87
+ t.timestamps
88
+ end
89
+ end
90
+
91
+ it "should respect the additional options" do
92
+ WithOptions.columns.map(&:name).should_not include("id")
93
+ end
94
+ end
@@ -126,4 +126,17 @@ describe "a temporary ActiveRecord model created with with_model" do
126
126
  end
127
127
  end
128
128
 
129
+ context "with table options" do
130
+ with_model :with_options do
131
+ table :id => false do |t|
132
+ t.string 'foo'
133
+ t.timestamps
134
+ end
135
+ end
136
+
137
+ it "should respect the additional options" do
138
+ WithOptions.columns.map(&:name).should_not include("id")
139
+ end
140
+ end
141
+
129
142
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
5
+ version: 0.1.4
11
6
  platform: ruby
12
7
  authors:
13
8
  - Case Commons, LLC
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-02-03 00:00:00 -05:00
13
+ date: 2011-03-30 00:00:00 -04:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,19 +21,9 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 9
30
- segments:
31
- - 2
32
- - 3
33
- - 5
34
24
  version: 2.3.5
35
25
  - - <
36
26
  - !ruby/object:Gem::Version
37
- hash: 63
38
- segments:
39
- - 4
40
- - 0
41
- - 0
42
27
  version: 4.0.0
43
28
  type: :runtime
44
29
  version_requirements: *id001
@@ -85,23 +70,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
70
  requirements:
86
71
  - - ">="
87
72
  - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
73
  version: "0"
92
74
  required_rubygems_version: !ruby/object:Gem::Requirement
93
75
  none: false
94
76
  requirements:
95
77
  - - ">="
96
78
  - !ruby/object:Gem::Version
97
- hash: 3
98
- segments:
99
- - 0
100
79
  version: "0"
101
80
  requirements: []
102
81
 
103
82
  rubyforge_project:
104
- rubygems_version: 1.4.2
83
+ rubygems_version: 1.5.2
105
84
  signing_key:
106
85
  specification_version: 3
107
86
  summary: Dynamically build a model within an Rspec context