merb_sequel 1.0.0 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+ require 'merb-core/dispatch/session/store_container'
3
+ require File.join( File.dirname(__FILE__), "..", "lib", 'merb', 'session', 'sequel_session')
4
+
5
+ describe Merb::SequelSession do
6
+
7
+ before(:each) do
8
+ @session_class = Merb::SequelSession
9
+ @session = @session_class.generate
10
+ end
11
+
12
+ it "should have a session_store_type class attribute" do
13
+ @session.class.session_store_type.should == :sequel
14
+ end
15
+
16
+ it "should persist values" do
17
+ response = request(url(:set))
18
+ response.should be_successful
19
+ response.body.should == 'value'
20
+
21
+ response = request(url(:get))
22
+ response.should be_successful
23
+ response.body.should == 'value'
24
+ end
25
+
26
+ it "should persist empty data" do
27
+ response = request(url(:set))
28
+ response.should be_successful
29
+ response.body.should == 'value'
30
+
31
+ response = request(url(:clear))
32
+ response.should be_successful
33
+
34
+ response = request(url(:get))
35
+ response.should be_successful
36
+ response.body.should be_empty
37
+ end
38
+
39
+ it "should allow changes" do
40
+ response = request(url(:set))
41
+ response.should be_successful
42
+ response.body.should == 'value'
43
+
44
+ response = request(url(:change))
45
+ response.should be_successful
46
+ response.body.should == 'changed'
47
+
48
+ response = request(url(:get))
49
+ response.should be_successful
50
+ response.body.should == 'changed'
51
+ end
52
+
53
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Merb::Orms::Sequel::Connect do
4
+ it "should be loaded at plugin bootstrap" do
5
+ defined?(Merb::Orms::Sequel::Connect).should == "constant"
6
+ end
7
+
8
+ it "should be Merb::BootLoader" do
9
+ Merb::Orms::Sequel::Connect.superclass.should eql(Merb::BootLoader)
10
+ end
11
+
12
+ it "should provide default settings" do
13
+ Merb::Plugins.config[:merb_sequel].should include(:load_activemodel_compatibility)
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/merb_sequel/rspec/sequel'
3
+
4
+ CreateSpecModel.apply(Sequel::Model.db, :up)
5
+ class SpecModel < Sequel::Model; end
6
+
7
+ describe "Transaction enabled examples" do
8
+
9
+ it "should wrap each example in transaction and rollback" do
10
+ a = SpecModel.create(:name => 'Pavel')
11
+ a.should_not be_new
12
+ end
13
+
14
+ it "should not have Pavel in the database" do
15
+ a = SpecModel.find(:name => 'Pavel')
16
+ a.should be_nil
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ CreateSpecModel.apply(Sequel::Model.db, :up)
4
+ class SpecModel < Sequel::Model; end
5
+
6
+ describe 'Merb::Orms::Sequel::Model' do
7
+
8
+ describe "active model" do
9
+ it "should load active model plugin when > 3.5" do
10
+ begin
11
+ SpecModel.plugins.should include(Sequel::Plugins::ActiveModel)
12
+ rescue NoMethodError
13
+ pending("For this SPEC to run and pass you need to install Sequel >= 3.5")
14
+ end
15
+ end
16
+
17
+ it "should include ActiveModelCompatibility module if plugin is not available" do
18
+ begin
19
+ Sequel::Model.plugin :active_model
20
+ pending("For this SPEC to run and pass you need to install Sequel < 3.5")
21
+ rescue LoadError, NoMethodError
22
+ SpecModel.ancestors.should include(Merb::Orms::Sequel::Model::ActiveModelCompatibility)
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "ActiveModelCompatiblity" do
28
+ it "should add new_record?" do
29
+ m = SpecModel.new
30
+ m.should be_new_record
31
+ end
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,20 @@
1
+ class SpecController < Merb::Controller
2
+ def clear
3
+ session.clear
4
+ render session[:key].to_s
5
+ end
6
+
7
+ def change
8
+ session[:key] = 'changed'
9
+ render session[:key].to_s
10
+ end
11
+
12
+ def get
13
+ render session[:key].to_s
14
+ end
15
+
16
+ def set
17
+ session[:key] = 'value'
18
+ render session[:key].to_s
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+
3
+ # Use current merb-core sources if running from a typical dev checkout.
4
+ lib = File.expand_path('../../../merb/merb-core/lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
6
+ require "merb-core"
7
+ require "sequel"
8
+ require "merb_sequel"
9
+
10
+ Merb.start(:adapter => 'runner',
11
+ :log_level => :error,
12
+ :merb_root => File.dirname(__FILE__),
13
+ :session_store => 'sequel',
14
+ :environment => 'test'
15
+ )
16
+
17
+ # Load extensions if we use new versions of Sequel
18
+ require 'sequel/extensions/migration' if Merb::Orms::Sequel.new_sequel?
19
+
20
+ Spec::Runner.configure do |config|
21
+ config.include Merb::Test::RequestHelper
22
+
23
+ config.after(:all) do
24
+ CreateSpecModel.apply(Sequel::Model.db, :up)
25
+ end
26
+ end
27
+
28
+ require File.join( File.dirname(__FILE__), 'spec_model')
29
+ require File.join( File.dirname(__FILE__), 'spec_controller')
30
+
31
+ Merb::Router.prepare do
32
+ match('/change').to(:controller => :spec_controller, :action => :change).name(:change)
33
+ match('/clear').to(:controller => :spec_controller, :action => :clear).name(:clear)
34
+ match('/get').to(:controller => :spec_controller, :action => :get).name(:get)
35
+ match('/set').to(:controller => :spec_controller, :action => :set).name(:set)
36
+ end
@@ -0,0 +1,13 @@
1
+ # Migrations to create the table
2
+ class CreateSpecModel < Sequel::Migration
3
+ def up
4
+ create_table! :spec_models do
5
+ primary_key :id
6
+ text :name
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :spec_models
12
+ end
13
+ end
Binary file
metadata CHANGED
@@ -1,15 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
- - Wayne E. Seguin, Lance Carlson, Lori Holden
7
+ - Wayne E. Seguin
8
+ - Lance Carlson
9
+ - Lori Holden
10
+ - Pavel Kunc
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
14
 
12
- date: 2009-01-02 00:00:00 -08:00
15
+ date: 2009-11-10 00:00:00 +00:00
13
16
  default_executable:
14
17
  dependencies:
15
18
  - !ruby/object:Gem::Dependency
@@ -30,69 +33,73 @@ dependencies:
30
33
  requirements:
31
34
  - - ">="
32
35
  - !ruby/object:Gem::Version
33
- version: 1.4.0
36
+ version: 2.7.0
34
37
  version:
35
- description: Merb plugin that provides support for Sequel and Sequel::Model
36
- email: wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ type: :development
41
+ version_requirement:
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.2.9
47
+ version:
48
+ description: Merb plugin that provides support for Sequel
49
+ email: wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com, pavel.kunc@gmail.com
37
50
  executables: []
38
51
 
39
52
  extensions: []
40
53
 
41
54
  extra_rdoc_files:
42
- - README
43
55
  - LICENSE
44
- - TODO
56
+ - README.rdoc
45
57
  files:
58
+ - CHANGELOG
59
+ - Generators
46
60
  - LICENSE
47
- - README
61
+ - README.rdoc
48
62
  - Rakefile
49
63
  - TODO
50
- - Generators
51
- - lib/generators
52
64
  - lib/generators/migration.rb
53
65
  - lib/generators/model.rb
54
66
  - lib/generators/resource_controller.rb
55
67
  - lib/generators/session_migration.rb
56
- - lib/generators/templates
57
- - lib/generators/templates/migration
58
- - lib/generators/templates/migration/schema
59
- - lib/generators/templates/migration/schema/migrations
60
68
  - lib/generators/templates/migration/schema/migrations/%file_name%.rb
61
- - lib/generators/templates/model
62
- - lib/generators/templates/model/app
63
- - lib/generators/templates/model/app/models
64
69
  - lib/generators/templates/model/app/models/%file_name%.rb
65
- - lib/generators/templates/resource_controller
66
- - lib/generators/templates/resource_controller/app
67
- - lib/generators/templates/resource_controller/app/controllers
68
70
  - lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
69
- - lib/generators/templates/resource_controller/app/views
70
- - lib/generators/templates/resource_controller/app/views/%file_name%
71
71
  - lib/generators/templates/resource_controller/app/views/%file_name%/edit.html.erb
72
72
  - lib/generators/templates/resource_controller/app/views/%file_name%/index.html.erb
73
73
  - lib/generators/templates/resource_controller/app/views/%file_name%/new.html.erb
74
74
  - lib/generators/templates/resource_controller/app/views/%file_name%/show.html.erb
75
- - lib/generators/templates/session_migration
76
- - lib/generators/templates/session_migration/schema
77
- - lib/generators/templates/session_migration/schema/migrations
78
75
  - lib/generators/templates/session_migration/schema/migrations/%version%_sessions.rb
79
- - lib/merb
80
- - lib/merb/orms
81
- - lib/merb/orms/sequel
82
76
  - lib/merb/orms/sequel/connection.rb
83
77
  - lib/merb/orms/sequel/database.yml.sample
84
- - lib/merb/session
78
+ - lib/merb/orms/sequel/model.rb
85
79
  - lib/merb/session/sequel_session.rb
86
- - lib/merb_sequel
87
- - lib/merb_sequel/merbtasks.rb
88
80
  - lib/merb_sequel.rb
89
- - lib/sequel_ext
90
- - lib/sequel_ext/model.rb
81
+ - lib/merb_sequel/merbtasks.rb
82
+ - lib/merb_sequel/rspec/sequel.rb
83
+ - lib/merb_sequel/version.rb
84
+ - spec/config/database.yml
85
+ - spec/log/merb_test.log
86
+ - spec/log/test.log
87
+ - spec/merb_sequel_session_spec.rb
88
+ - spec/merb_sequel_spec.rb
89
+ - spec/rspec/sequel_spec.rb
90
+ - spec/sequel_ext_spec.rb
91
+ - spec/spec.opts
92
+ - spec/spec_controller.rb
93
+ - spec/spec_helper.rb
94
+ - spec/spec_model.rb
95
+ - spec/test.db
91
96
  has_rdoc: true
92
- homepage: http://merbivore.com
93
- post_install_message:
94
- rdoc_options: []
97
+ homepage: http://github.com/merb/merb_sequel
98
+ licenses: []
95
99
 
100
+ post_install_message:
101
+ rdoc_options:
102
+ - --charset=UTF-8
96
103
  require_paths:
97
104
  - lib
98
105
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -109,10 +116,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
116
  version:
110
117
  requirements: []
111
118
 
112
- rubyforge_project: merb
113
- rubygems_version: 1.3.1
119
+ rubyforge_project:
120
+ rubygems_version: 1.3.5
114
121
  signing_key:
115
- specification_version: 2
116
- summary: Merb plugin that provides support for Sequel and Sequel::Model
117
- test_files: []
118
-
122
+ specification_version: 3
123
+ summary: Merb plugin that provides support for Sequel
124
+ test_files:
125
+ - spec/merb_sequel_session_spec.rb
126
+ - spec/merb_sequel_spec.rb
127
+ - spec/rspec/sequel_spec.rb
128
+ - spec/sequel_ext_spec.rb
129
+ - spec/spec_controller.rb
130
+ - spec/spec_helper.rb
131
+ - spec/spec_model.rb
data/README DELETED
@@ -1,49 +0,0 @@
1
- = merb_sequel
2
-
3
- A plugin for the Merb framework that provides support for Sequel models.
4
-
5
-
6
- = Connection options
7
-
8
- Merb Sequel plugin uses config/database.yml for connection configuration.
9
-
10
- Options are:
11
-
12
- * adapter. :sqlite is assumed by default.
13
- * host. localhost is assumed by default.
14
- * username or user, default is an empty string
15
- * database, default is "hey_dude_configure_your_database". This should be
16
- either :memory: or file path for SQLite.
17
- * encoding or charset, default is utf8.
18
- * password. WARNING: default password is an empty string.
19
- * db_type: default is nil. Use "mssql" to connect to MSSQL using ODBC.
20
-
21
-
22
- = Generators
23
-
24
- After you install the plugin, merb-gen can generate Sequel models for you:
25
-
26
- merb-gen model --orm=sequel Article
27
-
28
- same with resources
29
-
30
- merb-gen resource --orm=sequel Article
31
-
32
-
33
- Note that if you have specified that you use Sequel in init.rb or environment
34
- specific init file (for instance, environments/development.rb)
35
- via use_orm :sequel, you need no specify --orm option explicitly when
36
- using merb-gen.
37
-
38
-
39
- = Contributors
40
-
41
- Originally written by Duane Johnson (canadaduane@gmail.com).
42
-
43
- Contributions by:
44
- * Wayne E. Seguin
45
- * Lance Carlson
46
- * Jacob Dunphy
47
- * Lori Holden
48
-
49
- Maintained by Michael S. Klishin (michael at novemberain.com)
@@ -1,7 +0,0 @@
1
- module Sequel
2
- class Model
3
- def new_record?
4
- self.new?
5
- end
6
- end
7
- end