activerecord-tableless 1.3.4 → 2.0.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -17
- data/Appraisals +5 -16
- data/README.md +36 -11
- data/activerecord-tableless.gemspec +13 -10
- data/features/step_definitions/web_steps.rb +2 -10
- data/gemfiles/rails30.gemfile +3 -4
- data/gemfiles/rails32.gemfile +3 -4
- data/gemfiles/rails40.gemfile +3 -4
- data/gemfiles/rails41.gemfile +3 -4
- data/gemfiles/rails42.gemfile +10 -0
- data/lib/activerecord-tableless.rb +13 -27
- data/lib/activerecord-tableless/version.rb +7 -0
- data/spec/lib/activerecord-tableless_spec.rb +37 -59
- data/spec/spec_helper.rb +1 -0
- metadata +73 -25
- data/gemfiles/rails23.gemfile +0 -10
- data/gemfiles/rails3x.gemfile +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a386946c0359158d3bebc3991b73f5bf9cfac73a
|
4
|
+
data.tar.gz: 6d178d797e00287165c065e1cb2734ad5aa809bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123299ca256f15623ec7af22d0147fb29761e7921f0ee0b0c046f8184d2b7771902491c0fc973b365f267af77ba38d29944e1cc7d37537c1258f202d39615802
|
7
|
+
data.tar.gz: 9509820d8e8a36f3c478257518679d5d9194ef07db6572e2b9d03cf71b4f74a3ac274a3ed06344185839aaac893da7567a283f76f1e4b52d10b5c9be0d3fce1a
|
data/.travis.yml
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
language: ruby
|
2
2
|
#bundler_args: --without development
|
3
|
-
before_install:
|
3
|
+
before_install:
|
4
|
+
- rvm @global do gem uninstall bundler --all --executables
|
5
|
+
- rvm @global do gem install bundler -v '~> 1.12.0'
|
6
|
+
- bundle --version
|
4
7
|
rvm:
|
5
|
-
-
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.1.1
|
8
|
+
- 2.2.2
|
9
|
+
- 2.2.7
|
10
|
+
- 2.3.0
|
11
|
+
- 2.3.4
|
10
12
|
gemfile:
|
11
|
-
- gemfiles/rails23.gemfile
|
12
13
|
- gemfiles/rails30.gemfile
|
13
14
|
- gemfiles/rails32.gemfile
|
14
|
-
- gemfiles/rails3x.gemfile
|
15
15
|
- gemfiles/rails40.gemfile
|
16
16
|
- gemfiles/rails41.gemfile
|
17
|
+
- gemfiles/rails42.gemfile
|
17
18
|
matrix:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
- rvm: 2.1.0
|
24
|
-
gemfile: gemfiles/rails23.gemfile
|
25
|
-
- rvm: 2.1.1
|
26
|
-
gemfile: gemfiles/rails23.gemfile
|
19
|
+
include:
|
20
|
+
- rvm: 2.4.0
|
21
|
+
gemfile: gemfiles/rails42.gemfile
|
22
|
+
- rvm: 2.4.1
|
23
|
+
gemfile: gemfiles/rails42.gemfile
|
data/Appraisals
CHANGED
@@ -1,40 +1,29 @@
|
|
1
1
|
#-*- ruby -*-
|
2
2
|
|
3
|
-
appraise "rails23" do
|
4
|
-
gem "rails", "~> 2.3.0"
|
5
|
-
gem "activerecord-tableless", :path => "../"
|
6
|
-
end
|
7
|
-
|
8
3
|
appraise "rails30" do
|
9
4
|
gem "rails", "~> 3.0.0"
|
10
|
-
gem "activerecord-tableless", :path => "../"
|
11
5
|
end
|
12
6
|
|
13
7
|
# appraise "rails31" do
|
14
8
|
# gem "rails", "~> 3.1.0"
|
15
|
-
# gem "activerecord-tableless", :path => "../"
|
16
9
|
# end
|
17
10
|
|
18
11
|
appraise "rails32" do
|
19
12
|
gem "rails", "~> 3.2.0"
|
20
13
|
gem "jquery-rails"
|
21
|
-
gem "activerecord-tableless", :path => "../"
|
22
|
-
end
|
23
|
-
|
24
|
-
appraise "rails3x" do
|
25
|
-
gem "rails", "~> 3.0"
|
26
|
-
gem "jquery-rails"
|
27
|
-
gem "activerecord-tableless", :path => "../"
|
28
14
|
end
|
29
15
|
|
30
16
|
appraise "rails40" do
|
31
17
|
gem "rails", "~> 4.0.0"
|
32
18
|
gem "jquery-rails"
|
33
|
-
gem "activerecord-tableless", :path => "../"
|
34
19
|
end
|
35
20
|
|
36
21
|
appraise "rails41" do
|
37
22
|
gem "rails", "~> 4.1.0"
|
38
23
|
gem "jquery-rails"
|
39
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
appraise "rails42" do
|
27
|
+
gem "rails", "~> 4.2.0"
|
28
|
+
gem "jquery-rails"
|
40
29
|
end
|
data/README.md
CHANGED
@@ -13,8 +13,7 @@ Why, why, why
|
|
13
13
|
|
14
14
|
Why would you ever consider this gem as opposed to ActiveModel.
|
15
15
|
|
16
|
-
|
17
|
-
see Hitosry section)
|
16
|
+
It all started in Rails 2 (see History section). In rails 2 ActiveModel did not exists. Nowadays rails 2.x series is no longer supported.
|
18
17
|
|
19
18
|
In Rails 3 there is an Active Model API, where you can use some
|
20
19
|
features of Active Record in other classes. Yehuda Katz has written
|
@@ -44,12 +43,36 @@ Include the gem in your Gemfile:
|
|
44
43
|
Supported Versions
|
45
44
|
------------------
|
46
45
|
|
47
|
-
Supported version are
|
48
|
-
|
46
|
+
Supported ruby version are
|
47
|
+
|
48
|
+
* **2.2.x** series higher than 2.2.2
|
49
|
+
* **2.3.x** series
|
50
|
+
|
51
|
+
If you are using Ruby version < 2.2.2 you can use the gem version <
|
52
|
+
2.0 like this
|
53
|
+
|
54
|
+
gem "activerecord-tableless", "~> 1.0.0"
|
55
|
+
|
56
|
+
Supported ActiveRecord versions are
|
57
|
+
|
58
|
+
* **3.0.x** series
|
59
|
+
* **3.2.x** series
|
60
|
+
* **4.1.x** series
|
61
|
+
* **4.2.x** series
|
62
|
+
|
63
|
+
If you are using ActiveRecord 2.3.x series you can use the gem version <
|
64
|
+
2.0 like this
|
65
|
+
|
66
|
+
gem "activerecord-tableless", "~> 1.0.0"
|
49
67
|
|
50
68
|
You may be able to make it work with 3.1.x, but you should expect to
|
51
69
|
put some time in it.
|
52
70
|
|
71
|
+
TODO
|
72
|
+
----
|
73
|
+
|
74
|
+
* Support Rails 5.x series
|
75
|
+
|
53
76
|
Usage
|
54
77
|
-----
|
55
78
|
|
@@ -81,10 +104,6 @@ And in the controller:
|
|
81
104
|
end
|
82
105
|
end
|
83
106
|
|
84
|
-
For Rails 2.3.x series you need to add this line in the top of your model file.
|
85
|
-
|
86
|
-
require 'activerecord-tableless'
|
87
|
-
|
88
107
|
If you wish (this is not recommended), you can pretend you have a succeeding database by using
|
89
108
|
|
90
109
|
has_no_table :database => :pretend_success
|
@@ -97,12 +116,18 @@ To start develop, please download the source code
|
|
97
116
|
|
98
117
|
git clone git://github.com/softace/activerecord-tableless.git
|
99
118
|
|
119
|
+
Install development libraries
|
120
|
+
|
121
|
+
sudo apt-get install -y libsqlite3-dev libxml2-dev libxslt-dev
|
122
|
+
|
100
123
|
When downloaded, you can start issuing the commands like
|
101
124
|
|
125
|
+
gem install bundler -v '~> 1.12.0'
|
102
126
|
bundle install
|
103
|
-
bundle
|
104
|
-
bundle exec
|
105
|
-
bundle exec
|
127
|
+
bundle update
|
128
|
+
bundle exec appraisal generate
|
129
|
+
bundle exec appraisal install
|
130
|
+
bundle exec appraisal rake all
|
106
131
|
|
107
132
|
Or you can see what other options are there:
|
108
133
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'activerecord-tableless/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |gem|
|
4
6
|
gem.name = 'activerecord-tableless'
|
5
|
-
gem.version =
|
7
|
+
gem.version = ActiveRecord::Tableless::VERSION
|
6
8
|
gem.platform = Gem::Platform::RUBY
|
7
9
|
gem.authors = ["Jarl Friis", "Kenneth Kalmer", "Michal Zima"]
|
8
10
|
gem.email = ["jarl@softace.dk"]
|
@@ -18,22 +20,23 @@ Gem::Specification.new do |gem|
|
|
18
20
|
|
19
21
|
gem.require_paths = ["lib"]
|
20
22
|
|
21
|
-
gem.add_runtime_dependency("activerecord", ">=
|
23
|
+
gem.add_runtime_dependency("activerecord", ">= 3.0.0", '< 5.0.0')
|
22
24
|
|
23
|
-
gem.add_development_dependency('bundler', '> 0')
|
24
|
-
gem.add_development_dependency('rake', '> 0')
|
25
|
+
gem.add_development_dependency('bundler', '> 0', '< 1.13.0')
|
26
|
+
gem.add_development_dependency('rake', '~> 0', '> 0')
|
25
27
|
|
26
28
|
# gem.add_development_dependency("rails") # This is in the appraisal gemfiles
|
27
29
|
gem.add_development_dependency('sqlite3', '~> 1.3')
|
28
30
|
|
29
|
-
gem.add_development_dependency('appraisal', '~> 0
|
31
|
+
gem.add_development_dependency('appraisal', '~> 1.0')
|
30
32
|
gem.add_development_dependency('cucumber', '~> 1.1')
|
31
|
-
gem.add_development_dependency("rspec", '
|
32
|
-
gem.add_development_dependency(
|
33
|
+
gem.add_development_dependency("rspec", '~> 3.1')
|
34
|
+
gem.add_development_dependency("rspec-collection_matchers", '~> 1.0')
|
35
|
+
gem.add_development_dependency('aruba', '~> 0.5')
|
33
36
|
|
34
|
-
|
35
|
-
gem.add_development_dependency('
|
36
|
-
gem.add_development_dependency('
|
37
|
+
gem.add_development_dependency('nokogiri', '~> 1.0')
|
38
|
+
gem.add_development_dependency('capybara', '~> 0.0')
|
39
|
+
gem.add_development_dependency('gem-release', '~> 0.7.4')
|
37
40
|
|
38
41
|
# gem.add_development_dependency('launchy', '~> 2.1')
|
39
42
|
# gem.add_development_dependency('debugger')
|
@@ -123,11 +123,7 @@ end
|
|
123
123
|
|
124
124
|
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
125
125
|
current_path = URI.parse(current_url).path
|
126
|
-
|
127
|
-
current_path.should == path_to(page_name)
|
128
|
-
else
|
129
|
-
assert_equal path_to(page_name), current_path
|
130
|
-
end
|
126
|
+
expect(current_path).to eq path_to(page_name)
|
131
127
|
end
|
132
128
|
|
133
129
|
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
@@ -136,11 +132,7 @@ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
136
132
|
expected_params = {}
|
137
133
|
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
138
134
|
|
139
|
-
|
140
|
-
actual_params.should == expected_params
|
141
|
-
else
|
142
|
-
assert_equal expected_params, actual_params
|
143
|
-
end
|
135
|
+
expect(actual_params).to eq expected_params
|
144
136
|
end
|
145
137
|
|
146
138
|
Then /^show me the page$/ do
|
data/gemfiles/rails30.gemfile
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "mime-types", "< 2.0", :platform
|
6
|
-
gem "rubyzip", "< 1.0", :platform
|
5
|
+
gem "mime-types", "< 2.0", :platform => :ruby_18
|
6
|
+
gem "rubyzip", "< 1.0", :platform => :ruby_18
|
7
7
|
gem "rails", "~> 3.0.0"
|
8
|
-
gem "activerecord-tableless", :path=>"../"
|
9
8
|
|
10
|
-
gemspec :path=>"../"
|
9
|
+
gemspec :path => "../"
|
data/gemfiles/rails32.gemfile
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "mime-types", "< 2.0", :platform
|
6
|
-
gem "rubyzip", "< 1.0", :platform
|
5
|
+
gem "mime-types", "< 2.0", :platform => :ruby_18
|
6
|
+
gem "rubyzip", "< 1.0", :platform => :ruby_18
|
7
7
|
gem "rails", "~> 3.2.0"
|
8
8
|
gem "jquery-rails"
|
9
|
-
gem "activerecord-tableless", :path=>"../"
|
10
9
|
|
11
|
-
gemspec :path=>"../"
|
10
|
+
gemspec :path => "../"
|
data/gemfiles/rails40.gemfile
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "mime-types", "< 2.0", :platform
|
6
|
-
gem "rubyzip", "< 1.0", :platform
|
5
|
+
gem "mime-types", "< 2.0", :platform => :ruby_18
|
6
|
+
gem "rubyzip", "< 1.0", :platform => :ruby_18
|
7
7
|
gem "rails", "~> 4.0.0"
|
8
8
|
gem "jquery-rails"
|
9
|
-
gem "activerecord-tableless", :path=>"../"
|
10
9
|
|
11
|
-
gemspec :path=>"../"
|
10
|
+
gemspec :path => "../"
|
data/gemfiles/rails41.gemfile
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "mime-types", "< 2.0", :platform
|
6
|
-
gem "rubyzip", "< 1.0", :platform
|
5
|
+
gem "mime-types", "< 2.0", :platform => :ruby_18
|
6
|
+
gem "rubyzip", "< 1.0", :platform => :ruby_18
|
7
7
|
gem "rails", "~> 4.1.0"
|
8
8
|
gem "jquery-rails"
|
9
|
-
gem "activerecord-tableless", :path=>"../"
|
10
9
|
|
11
|
-
gemspec :path=>"../"
|
10
|
+
gemspec :path => "../"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# See #ActiveRecord::Tableless
|
2
|
+
require 'activerecord-tableless/version'
|
2
3
|
|
3
4
|
module ActiveRecord
|
4
5
|
|
@@ -85,11 +86,18 @@ module ActiveRecord
|
|
85
86
|
end
|
86
87
|
|
87
88
|
# Register a new column.
|
88
|
-
|
89
|
-
|
89
|
+
|
90
|
+
if ActiveRecord::VERSION::STRING >= "4.2.0"
|
91
|
+
def column(name, sql_type = nil, default = nil, null = true)
|
92
|
+
tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, Type::Value.new, sql_type.to_s, null)
|
93
|
+
end
|
94
|
+
else
|
95
|
+
def column(name, sql_type = nil, default = nil, null = true)
|
96
|
+
tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
97
|
+
end
|
90
98
|
end
|
91
99
|
|
92
|
-
# Register a set of
|
100
|
+
# Register a set of columns with the same SQL type
|
93
101
|
def add_columns(sql_type, *args)
|
94
102
|
args.each do |col|
|
95
103
|
column col, sql_type
|
@@ -115,25 +123,6 @@ module ActiveRecord
|
|
115
123
|
end
|
116
124
|
|
117
125
|
case ActiveRecord::VERSION::MAJOR
|
118
|
-
when 2
|
119
|
-
def find_from_ids(*args)
|
120
|
-
case tableless_options[:database]
|
121
|
-
when :pretend_success
|
122
|
-
raise ActiveRecord::RecordNotFound.new("Couldn't find #{self} with ID=#{args[0].to_s}")
|
123
|
-
|
124
|
-
when :fail_fast
|
125
|
-
raise NoDatabase.new("Can't #find_from_ids on Tableless class")
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def find_every(*args)
|
130
|
-
case tableless_options[:database]
|
131
|
-
when :pretend_success
|
132
|
-
[]
|
133
|
-
when :fail_fast
|
134
|
-
raise NoDatabase.new("Can't #find_every on Tableless class")
|
135
|
-
end
|
136
|
-
end
|
137
126
|
when 3
|
138
127
|
def all(*args)
|
139
128
|
case tableless_options[:database]
|
@@ -172,11 +161,8 @@ module ActiveRecord
|
|
172
161
|
true
|
173
162
|
end
|
174
163
|
|
175
|
-
|
176
|
-
|
177
|
-
def table_exists?
|
178
|
-
false
|
179
|
-
end
|
164
|
+
def table_exists?
|
165
|
+
false
|
180
166
|
end
|
181
167
|
end
|
182
168
|
|
@@ -2,6 +2,7 @@ require 'sqlite3'
|
|
2
2
|
require 'active_record'
|
3
3
|
require 'activerecord-tableless'
|
4
4
|
require 'logger'
|
5
|
+
require 'spec_helper'
|
5
6
|
|
6
7
|
def make_tableless_model(database = nil, nested = nil)
|
7
8
|
eval <<EOCLASS
|
@@ -45,9 +46,9 @@ shared_examples_for "an active record instance" do
|
|
45
46
|
it { should respond_to :name= }
|
46
47
|
it { should respond_to :update_attributes }
|
47
48
|
describe "#attributes=" do
|
48
|
-
before(:
|
49
|
+
before(:example){ subject.attributes=({:name => 'Jarl Friis'}) }
|
49
50
|
it "assign attributes" do
|
50
|
-
subject.name.
|
51
|
+
expect(subject.name).to eq 'Jarl Friis'
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -55,54 +56,43 @@ end
|
|
55
56
|
shared_examples_for "a nested active record" do
|
56
57
|
describe "conllection#build" do
|
57
58
|
specify do
|
58
|
-
subject.arm_rests.build({:name => 'nice arm_rest'}).
|
59
|
+
expect(subject.arm_rests.build({:name => 'nice arm_rest'})).to be_an_instance_of(ArmRest)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
describe "conllection#<<" do
|
62
63
|
specify do
|
63
|
-
(subject.arm_rests << ArmRest.new({:name => 'nice arm_rest'})).
|
64
|
+
expect(subject.arm_rests << ArmRest.new({:name => 'nice arm_rest'})).to have(1).items
|
64
65
|
end
|
65
|
-
describe
|
66
|
-
before(:
|
66
|
+
describe 'appending two children' do
|
67
|
+
before(:example) do
|
67
68
|
subject.arm_rests << [ArmRest.new({:name => 'left'}),
|
68
69
|
ArmRest.new({:name => 'right'})]
|
69
70
|
end
|
70
71
|
it "assigns nested attributes" do
|
71
|
-
subject.arm_rests[0].name.
|
72
|
-
subject.arm_rests[1].name.
|
72
|
+
expect(subject.arm_rests[0].name).to eq 'left'
|
73
|
+
expect(subject.arm_rests[1].name).to eq 'right'
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
76
77
|
describe "#attributes=" do
|
77
|
-
before(:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
before(:example){ subject.attributes=({ :name => 'Jarl Friis',
|
79
|
+
:arm_rests_attributes => [
|
80
|
+
{:name => 'left'},
|
81
|
+
{:name => 'right'}
|
82
|
+
]
|
83
|
+
}) }
|
83
84
|
it "assigns attributes" do
|
84
|
-
subject.name.
|
85
|
+
expect(subject.name).to eq 'Jarl Friis'
|
85
86
|
end
|
86
87
|
it "assigns nested attributes" do
|
87
|
-
subject.arm_rests[0].name.
|
88
|
-
subject.arm_rests[1].name.
|
88
|
+
expect(subject.arm_rests[0].name).to eq 'left'
|
89
|
+
expect(subject.arm_rests[1].name).to eq 'right'
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
94
|
shared_examples_for "a tableless model with fail_fast" do
|
94
95
|
case ActiveRecord::VERSION::MAJOR
|
95
|
-
when 2
|
96
|
-
describe "#find" do
|
97
|
-
it "raises ActiveRecord::Tableless::NoDatabase" do
|
98
|
-
expect { subject.find(1) }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
describe "#find(:all)" do
|
102
|
-
it "raises ActiveRecord::Tableless::NoDatabase" do
|
103
|
-
expect { subject.find(:all) }.to raise_exception(ActiveRecord::Tableless::NoDatabase)
|
104
|
-
end
|
105
|
-
end
|
106
96
|
when 3
|
107
97
|
describe "#all" do
|
108
98
|
it "raises ActiveRecord::Tableless::NoDatabase" do
|
@@ -163,8 +153,8 @@ shared_examples_for "a tableless model instance with fail_fast" do
|
|
163
153
|
end
|
164
154
|
|
165
155
|
describe "Tableless model with fail_fast" do
|
166
|
-
before(:
|
167
|
-
after(:
|
156
|
+
before(:context) {make_tableless_model(nil, nil)}
|
157
|
+
after(:context){ remove_models }
|
168
158
|
subject { Chair }
|
169
159
|
it_behaves_like "a tableless model with fail_fast"
|
170
160
|
describe "instance" do
|
@@ -174,16 +164,16 @@ describe "Tableless model with fail_fast" do
|
|
174
164
|
end
|
175
165
|
|
176
166
|
describe "Tableless nested with fail_fast" do
|
177
|
-
before(:
|
178
|
-
after(:
|
167
|
+
before(:context) {make_tableless_model(nil, true)}
|
168
|
+
after(:context){ remove_models }
|
179
169
|
subject { Chair }
|
180
170
|
it_behaves_like "a tableless model with fail_fast"
|
181
171
|
describe "#new" do
|
182
172
|
it "accepts attributes" do
|
183
|
-
subject.new(:name => "Jarl").
|
173
|
+
expect(subject.new(:name => "Jarl")).to be_an_instance_of(subject)
|
184
174
|
end
|
185
175
|
it "assign attributes" do
|
186
|
-
subject.new(:name => "Jarl").name.
|
176
|
+
expect(subject.new(:name => "Jarl").name).to eq "Jarl"
|
187
177
|
end
|
188
178
|
end
|
189
179
|
describe "instance" do
|
@@ -226,29 +216,17 @@ end
|
|
226
216
|
## Succeeding database
|
227
217
|
##
|
228
218
|
shared_examples_for "a model with succeeding database" do
|
229
|
-
|
230
|
-
|
231
|
-
describe "#find" do
|
232
|
-
it "raises ActiveRecord::RecordNotFound" do
|
233
|
-
expect { subject.find(314) }.to raise_exception(ActiveRecord::RecordNotFound)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
describe "#find(:all)" do
|
237
|
-
specify { subject.find(:all).should == []}
|
238
|
-
end
|
239
|
-
when 3, 4
|
240
|
-
describe "#all" do
|
241
|
-
specify { subject.all.should == []}
|
242
|
-
end
|
219
|
+
describe "#all" do
|
220
|
+
specify { expect(subject.all).to eq []}
|
243
221
|
end
|
244
222
|
describe "#create" do
|
245
|
-
specify { subject.create(:name => 'Jarl').
|
223
|
+
specify { expect(subject.create(:name => 'Jarl')).to be_an_instance_of(subject) }
|
246
224
|
end
|
247
225
|
describe "#destroy" do
|
248
|
-
specify { subject.destroy(1).
|
226
|
+
specify { expect(subject.destroy(1)).to be_an_instance_of(subject) }
|
249
227
|
end
|
250
228
|
describe "#destroy_all" do
|
251
|
-
specify { subject.destroy_all.
|
229
|
+
specify { expect(subject.destroy_all).to eq [] }
|
252
230
|
end
|
253
231
|
end
|
254
232
|
|
@@ -256,23 +234,23 @@ shared_examples_for "an instance with succeeding database" do
|
|
256
234
|
it_behaves_like "an active record instance"
|
257
235
|
|
258
236
|
describe "#save" do
|
259
|
-
specify { subject.save.
|
237
|
+
specify { expect(subject.save).to eq true }
|
260
238
|
end
|
261
239
|
describe "#save!" do
|
262
|
-
specify { subject.save
|
240
|
+
specify { expect(subject.save!).to eq true }
|
263
241
|
end
|
264
242
|
describe "#reload" do
|
265
243
|
before { subject.save! }
|
266
|
-
specify { subject.reload.
|
244
|
+
specify { expect(subject.reload).to eq subject }
|
267
245
|
end
|
268
246
|
describe "#update_attributes" do
|
269
|
-
specify { subject.update_attributes(:name => 'Jarl Friis').
|
247
|
+
specify { expect(subject.update_attributes(:name => 'Jarl Friis')).to eq true }
|
270
248
|
end
|
271
249
|
end
|
272
250
|
|
273
251
|
describe "ActiveRecord with real database" do
|
274
252
|
##This is only here to ensure that the shared examples are actually behaving like a real database.
|
275
|
-
before(:
|
253
|
+
before(:context) do
|
276
254
|
FileUtils.mkdir_p "tmp"
|
277
255
|
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'tmp/test.db')
|
278
256
|
ActiveRecord::Base.connection.execute("drop table if exists chairs")
|
@@ -281,7 +259,7 @@ describe "ActiveRecord with real database" do
|
|
281
259
|
class Chair < ActiveRecord::Base
|
282
260
|
end
|
283
261
|
end
|
284
|
-
after(:
|
262
|
+
after(:context) do
|
285
263
|
remove_models
|
286
264
|
ActiveRecord::Base.clear_all_connections!
|
287
265
|
end
|
@@ -295,8 +273,8 @@ describe "ActiveRecord with real database" do
|
|
295
273
|
end
|
296
274
|
|
297
275
|
describe "Tableless model with succeeding database" do
|
298
|
-
before(:
|
299
|
-
after(:
|
276
|
+
before(:context) { make_tableless_model(:pretend_success, nil) }
|
277
|
+
after(:context){ remove_models }
|
300
278
|
subject { Chair }
|
301
279
|
it_behaves_like "a model with succeeding database"
|
302
280
|
describe "instance" do
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/collection_matchers'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-tableless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarl Friis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,14 +18,20 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.0.0
|
22
|
+
- - "<"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 5.0.0
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
29
|
- - ">="
|
27
30
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
31
|
+
version: 3.0.0
|
32
|
+
- - "<"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 5.0.0
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: bundler
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,6 +39,9 @@ dependencies:
|
|
33
39
|
- - ">"
|
34
40
|
- !ruby/object:Gem::Version
|
35
41
|
version: '0'
|
42
|
+
- - "<"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.13.0
|
36
45
|
type: :development
|
37
46
|
prerelease: false
|
38
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -40,10 +49,16 @@ dependencies:
|
|
40
49
|
- - ">"
|
41
50
|
- !ruby/object:Gem::Version
|
42
51
|
version: '0'
|
52
|
+
- - "<"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.13.0
|
43
55
|
- !ruby/object:Gem::Dependency
|
44
56
|
name: rake
|
45
57
|
requirement: !ruby/object:Gem::Requirement
|
46
58
|
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- - ">"
|
48
63
|
- !ruby/object:Gem::Version
|
49
64
|
version: '0'
|
@@ -51,6 +66,9 @@ dependencies:
|
|
51
66
|
prerelease: false
|
52
67
|
version_requirements: !ruby/object:Gem::Requirement
|
53
68
|
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
54
72
|
- - ">"
|
55
73
|
- !ruby/object:Gem::Version
|
56
74
|
version: '0'
|
@@ -74,14 +92,14 @@ dependencies:
|
|
74
92
|
requirements:
|
75
93
|
- - "~>"
|
76
94
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
95
|
+
version: '1.0'
|
78
96
|
type: :development
|
79
97
|
prerelease: false
|
80
98
|
version_requirements: !ruby/object:Gem::Requirement
|
81
99
|
requirements:
|
82
100
|
- - "~>"
|
83
101
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0
|
102
|
+
version: '1.0'
|
85
103
|
- !ruby/object:Gem::Dependency
|
86
104
|
name: cucumber
|
87
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,58 +118,86 @@ dependencies:
|
|
100
118
|
name: rspec
|
101
119
|
requirement: !ruby/object:Gem::Requirement
|
102
120
|
requirements:
|
103
|
-
- - "
|
121
|
+
- - "~>"
|
104
122
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
123
|
+
version: '3.1'
|
106
124
|
type: :development
|
107
125
|
prerelease: false
|
108
126
|
version_requirements: !ruby/object:Gem::Requirement
|
109
127
|
requirements:
|
110
|
-
- - "
|
128
|
+
- - "~>"
|
111
129
|
- !ruby/object:Gem::Version
|
112
|
-
version: '
|
130
|
+
version: '3.1'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rspec-collection_matchers
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '1.0'
|
113
145
|
- !ruby/object:Gem::Dependency
|
114
146
|
name: aruba
|
115
147
|
requirement: !ruby/object:Gem::Requirement
|
116
148
|
requirements:
|
117
|
-
- - "
|
149
|
+
- - "~>"
|
118
150
|
- !ruby/object:Gem::Version
|
119
151
|
version: '0.5'
|
120
152
|
type: :development
|
121
153
|
prerelease: false
|
122
154
|
version_requirements: !ruby/object:Gem::Requirement
|
123
155
|
requirements:
|
124
|
-
- - "
|
156
|
+
- - "~>"
|
125
157
|
- !ruby/object:Gem::Version
|
126
158
|
version: '0.5'
|
127
159
|
- !ruby/object:Gem::Dependency
|
128
160
|
name: nokogiri
|
129
161
|
requirement: !ruby/object:Gem::Requirement
|
130
162
|
requirements:
|
131
|
-
- - "
|
163
|
+
- - "~>"
|
132
164
|
- !ruby/object:Gem::Version
|
133
|
-
version: '1.
|
165
|
+
version: '1.0'
|
134
166
|
type: :development
|
135
167
|
prerelease: false
|
136
168
|
version_requirements: !ruby/object:Gem::Requirement
|
137
169
|
requirements:
|
138
|
-
- - "
|
170
|
+
- - "~>"
|
139
171
|
- !ruby/object:Gem::Version
|
140
|
-
version: '1.
|
172
|
+
version: '1.0'
|
141
173
|
- !ruby/object:Gem::Dependency
|
142
174
|
name: capybara
|
143
175
|
requirement: !ruby/object:Gem::Requirement
|
144
176
|
requirements:
|
145
|
-
- - "
|
177
|
+
- - "~>"
|
146
178
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
179
|
+
version: '0.0'
|
148
180
|
type: :development
|
149
181
|
prerelease: false
|
150
182
|
version_requirements: !ruby/object:Gem::Requirement
|
151
183
|
requirements:
|
152
|
-
- - "
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0.0'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: gem-release
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 0.7.4
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
153
199
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
200
|
+
version: 0.7.4
|
155
201
|
description: ActiveRecord Tableless Models provides a simple mixin for creating models
|
156
202
|
that are not bound to the database. This approach is useful for taking advantage
|
157
203
|
of the features of ActiveRecord such as validation, relationships, etc.
|
@@ -178,15 +224,16 @@ files:
|
|
178
224
|
- features/support/paths.rb
|
179
225
|
- features/support/rails.rb
|
180
226
|
- features/support/selectors.rb
|
181
|
-
- gemfiles/rails23.gemfile
|
182
227
|
- gemfiles/rails30.gemfile
|
183
228
|
- gemfiles/rails32.gemfile
|
184
|
-
- gemfiles/rails3x.gemfile
|
185
229
|
- gemfiles/rails40.gemfile
|
186
230
|
- gemfiles/rails41.gemfile
|
231
|
+
- gemfiles/rails42.gemfile
|
187
232
|
- init.rb
|
188
233
|
- lib/activerecord-tableless.rb
|
234
|
+
- lib/activerecord-tableless/version.rb
|
189
235
|
- spec/lib/activerecord-tableless_spec.rb
|
236
|
+
- spec/spec_helper.rb
|
190
237
|
homepage: https://github.com/softace/activerecord-tableless
|
191
238
|
licenses:
|
192
239
|
- MIT
|
@@ -202,12 +249,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
249
|
version: '0'
|
203
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
251
|
requirements:
|
205
|
-
- - "
|
252
|
+
- - ">"
|
206
253
|
- !ruby/object:Gem::Version
|
207
|
-
version:
|
254
|
+
version: 1.3.1
|
208
255
|
requirements: []
|
209
256
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.5.2
|
211
258
|
signing_key:
|
212
259
|
specification_version: 4
|
213
260
|
summary: A library for implementing tableless ActiveRecord models
|
@@ -221,3 +268,4 @@ test_files:
|
|
221
268
|
- features/support/rails.rb
|
222
269
|
- features/support/selectors.rb
|
223
270
|
- spec/lib/activerecord-tableless_spec.rb
|
271
|
+
- spec/spec_helper.rb
|
data/gemfiles/rails23.gemfile
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "mime-types", "< 2.0", :platform=>:ruby_18
|
6
|
-
gem "rubyzip", "< 1.0", :platform=>:ruby_18
|
7
|
-
gem "rails", "~> 2.3.0"
|
8
|
-
gem "activerecord-tableless", :path=>"../"
|
9
|
-
|
10
|
-
gemspec :path=>"../"
|
data/gemfiles/rails3x.gemfile
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "mime-types", "< 2.0", :platform=>:ruby_18
|
6
|
-
gem "rubyzip", "< 1.0", :platform=>:ruby_18
|
7
|
-
gem "rails", "~> 3.0"
|
8
|
-
gem "jquery-rails"
|
9
|
-
gem "activerecord-tableless", :path=>"../"
|
10
|
-
|
11
|
-
gemspec :path=>"../"
|