activerecord-tableless 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,8 @@ nbproject
2
2
  tmp
3
3
  *.gem
4
4
  *emfile.lock
5
+
6
+ # For emacs:
7
+ *~
8
+ #\#*
9
+ #.\#*
data/Appraisals ADDED
@@ -0,0 +1,29 @@
1
+ #-*- ruby -*-
2
+
3
+ appraise "rails23" do
4
+ gem "rails", "~> 2.3.0"
5
+ gem "activerecord-tableless", :path => "../"
6
+ end
7
+
8
+ appraise "rails30" do
9
+ gem "rails", "~> 3.0.0"
10
+ gem "activerecord-tableless", :path => "../"
11
+ end
12
+
13
+ # appraise "rails31" do
14
+ # gem "rails", "~> 3.1.0"
15
+ # gem "activerecord-tableless", :path => "../"
16
+ # end
17
+
18
+ appraise "rails32" do
19
+ gem "rails", "~> 3.2.0"
20
+ 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
+ end
29
+
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ ActiveRecord Tableless
2
+ ======================
3
+
4
+ A single implementation of the ActiveRecord Tableless pattern for any
5
+ Rails project or other Ruby project that uses ActiveRecord.
6
+
7
+ Installation
8
+ ------------
9
+
10
+ ActiveRecord Tableless is distributed as a gem, which is how it should
11
+ be used in your app.
12
+
13
+ Include the gem in your Gemfile:
14
+
15
+ gem "activerecord-tableless", "~> 1.0"
16
+
17
+
18
+ Supported Versions
19
+ ------------------
20
+
21
+ Supported version are ActiveRecord version **2.3.x**, **3.0.x** series
22
+ and **3.2.x** series
23
+
24
+ You may be able to make it work with 3.1.X, but you should expect to
25
+ put some time in it.
26
+
27
+ Usage
28
+ -----
29
+
30
+ Define a model like this:
31
+
32
+ class ContactMessage < ActiveRecord::Base
33
+ has_no_table
34
+ column :name, :string
35
+ column :email, :string
36
+ validates_presence_of :name, :email
37
+ end
38
+
39
+ You can now use the model in a view like this:
40
+
41
+ <%= form_for :message, @message do |f| %>
42
+ Your name: <%= f.text_field :name %>
43
+ Your email: <%= f.text_field :email %>
44
+ <% end %>
45
+
46
+ And in the controller:
47
+
48
+ def message
49
+ @message = ContactMessage.new
50
+ if request.post?
51
+ @message.attributes = params[:message]
52
+ if @message.valid?
53
+ # Process the message...
54
+ end
55
+ end
56
+ end
57
+
58
+ For Rails 2.3.x series you need to add this line in the top of your model file.
59
+
60
+ require 'activerecord-tableless'
61
+
62
+
63
+ Development
64
+ -----------
65
+
66
+ To start develop, please download the source code
67
+
68
+ git clone git://github.com/softace/activerecord-tableless.git
69
+
70
+ When downloaded, you can start issuing the commands like
71
+
72
+ bundle install
73
+ bundle exec rake appraisal:gemfiles
74
+ bundle exec rake appraisal:install
75
+ bundle exec rake appraisal
76
+
77
+ Or you can see what other options are there:
78
+
79
+ bundle exec rake -T
80
+
81
+
82
+ History
83
+ -------
84
+
85
+ Well, take a look at the git log :-)
86
+
87
+
88
+ Copyright
89
+ ---------
90
+
91
+ Copyright (c) Jarl Friis. See LICENSE.txt for
92
+ further details.
93
+
data/Rakefile CHANGED
@@ -1,15 +1,38 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rdoc/task'
2
+ require 'appraisal'
3
+ require 'rake/testtask'
4
+ require 'cucumber/rake/task'
3
5
 
4
- task :default do
5
- puts
6
- puts IO.read(File.join(File.dirname(__FILE__), 'README'))
7
- puts
6
+ desc 'Default: clean, all.'
7
+ task :default => [:clean, :all]
8
+
9
+ desc 'Test the activerecord-tableless on all supported Rails versions.'
10
+ task :all do |t|
11
+ if ENV['BUNDLE_GEMFILE']
12
+ exec('rake test cucumber')
13
+ else
14
+ Rake::Task["appraisal:install"].execute
15
+ exec('rake appraisal test cucumber')
16
+ end
17
+ end
18
+
19
+ desc 'Test the activerecord-tableless plugin.'
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'lib' << 'profile'
22
+ t.pattern = 'test/**/*_test.rb'
23
+ t.verbose = true
24
+ end
25
+
26
+ desc 'Run integration test'
27
+ Cucumber::Rake::Task.new do |t|
28
+ t.cucumber_opts = %w{--format progress}
8
29
  end
9
30
 
10
- Rake::RDocTask.new do |rd|
11
- rd.main = 'README'
12
- rd.rdoc_files.include('README', 'lib/*.rb', 'lib/**/*.rb')
13
- rd.rdoc_dir = 'rdoc'
14
- rd.title = 'ActiveRecord Tableless'
31
+ desc 'Clean up files.'
32
+ task :clean do |t|
33
+ FileUtils.rm_rf "doc"
34
+ FileUtils.rm_rf "tmp"
35
+ FileUtils.rm_rf "pkg"
36
+ FileUtils.rm_rf "public"
37
+ Dir.glob("activerecord-tableless-*.gem").each{|f| FileUtils.rm f }
15
38
  end
@@ -10,16 +10,23 @@ Gem::Specification.new do |gem|
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
- gem.version = "1.0.1"
13
+ gem.version = "1.0.2"
14
14
  gem.has_rdoc = true
15
- gem.extra_rdoc_files = %w( README CHANGELOG )
16
- gem.rdoc_options.concat ['--main', 'README']
17
15
 
18
16
  gem.require_paths = ["lib"]
19
17
  gem.platform = Gem::Platform::RUBY
20
18
 
21
- gem.add_dependency("activerecord", ">=3.2")
19
+ gem.add_dependency("activerecord", ">= 2.3.0")
22
20
 
23
21
  gem.add_development_dependency('bundler')
24
22
  gem.add_development_dependency('rake')
23
+
24
+ # gem.add_development_dependency("rails") # This is in the appraisal gemfiles
25
+ gem.add_development_dependency('sqlite3', '~> 1.3')
26
+
27
+ gem.add_development_dependency('appraisal', '~> 0.4')
28
+ gem.add_development_dependency('cucumber', '~> 1.1')
29
+ gem.add_development_dependency('launchy', '~> 2.1')
30
+ gem.add_development_dependency('aruba', '>= 0.5')
31
+ gem.add_development_dependency('capybara')
25
32
  end
@@ -0,0 +1,16 @@
1
+ Feature: Rails integration
2
+
3
+ Background:
4
+ Given I generate a new rails application
5
+ And I run a "scaffold" generator to generate a "User" scaffold with "name:string"
6
+ And I delete all migrations
7
+ And I update my new user model to be tableless
8
+ And I update my users controller to render instead of redirect
9
+
10
+ Scenario: Work as normal model
11
+ And I start the rails application
12
+ When I go to the new user page
13
+ And I fill in "Name" with "something"
14
+ And I press "Create"
15
+ Then I should see "Name: something"
16
+
@@ -0,0 +1,138 @@
1
+ Given /^I generate a new rails application$/ do
2
+ steps %{
3
+ When I successfully run `bundle exec #{new_application_command} #{APP_NAME}`
4
+ And I cd to "#{APP_NAME}"
5
+ And I turn off class caching
6
+ And I write to "Gemfile" with:
7
+ """
8
+ source "http://rubygems.org"
9
+ gem "rails", "#{framework_version}"
10
+ #{"gem \"jquery-rails\"" if framework_version >= "3.2"}
11
+ gem "sqlite3"
12
+ gem "capybara"
13
+ gem "gherkin"
14
+ """
15
+ And I configure the application to use "activerecord-tableless" from this project
16
+ And I reset Bundler environment variable
17
+ And I successfully run `bundle install --local`
18
+ }
19
+ end
20
+
21
+ Given /^I run a "(.*?)" generator to generate a "(.*?)" scaffold with "(.*?)"$/ do |generator_name, model_name, attributes|
22
+ step %[I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attributes}`]
23
+ end
24
+
25
+ Given /^I add this snippet to the User model:$/ do |snippet|
26
+ file_name = "app/models/user.rb"
27
+ in_current_dir do
28
+ content = File.read(file_name)
29
+ File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
30
+ end
31
+ end
32
+
33
+ Given /^I add this snippet to the "(.*?)" controller:$/ do |controller_name, snippet|
34
+ file_name = "app/controllers/#{controller_name}_controller.rb"
35
+ in_current_dir do
36
+ content = File.read(file_name)
37
+ File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
38
+ end
39
+ end
40
+
41
+ Given /^I start the rails application$/ do
42
+ in_current_dir do
43
+ require "./config/environment"
44
+ require "capybara/rails"
45
+ end
46
+ end
47
+
48
+ Given /^I reload my application$/ do
49
+ Rails::Application.reload!
50
+ end
51
+
52
+ When %r{I turn off class caching} do
53
+ in_current_dir do
54
+ file = "config/environments/test.rb"
55
+ config = IO.read(file)
56
+ config.gsub!(%r{^\s*config.cache_classes.*$},
57
+ "config.cache_classes = false")
58
+ File.open(file, "w"){|f| f.write(config) }
59
+ end
60
+ end
61
+
62
+ Given /^I update my application to use Bundler$/ do
63
+ if framework_version?("2")
64
+ boot_config_template = File.read('features/support/fixtures/boot_config.txt')
65
+ preinitializer_template = File.read('features/support/fixtures/preinitializer.txt')
66
+ gemfile_template = File.read('features/support/fixtures/gemfile.txt')
67
+ in_current_dir do
68
+ content = File.read("config/boot.rb").sub(/Rails\.boot!/, boot_config_template)
69
+ File.open("config/boot.rb", "w") { |file| file.write(content) }
70
+ File.open("config/preinitializer.rb", "w") { |file| file.write(preinitializer_template) }
71
+ File.open("Gemfile", "w") { |file| file.write(gemfile_template.sub(/RAILS_VERSION/, framework_version)) }
72
+ end
73
+ end
74
+ end
75
+
76
+ Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
77
+ expected = IO.binread(path)
78
+ actual = if web_file.match %r{^https?://}
79
+ Net::HTTP.get(URI.parse(web_file))
80
+ else
81
+ visit(web_file)
82
+ page.source
83
+ end
84
+ actual.should == expected
85
+ end
86
+
87
+ When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
88
+ append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
89
+ steps %{And I run `bundle install --local`}
90
+ end
91
+
92
+ When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
93
+ append_to_gemfile "gem '#{gem_name}'"
94
+ end
95
+
96
+ When /^I append gems from Appraisal Gemfile$/ do
97
+ File.read(ENV['BUNDLE_GEMFILE']).split(/\n/).each do |line|
98
+ if line =~ /^gem "(?!rails|appraisal)/
99
+ append_to_gemfile line.strip
100
+ end
101
+ end
102
+ end
103
+
104
+ When /^I comment out the gem "(.*?)" from the Gemfile$/ do |gemname|
105
+ comment_out_gem_in_gemfile gemname
106
+ end
107
+
108
+ Then /^the result of "(.*?)" should be the same as "(.*?)"$/ do |rails_expr, path|
109
+ expected = IO.binread(path)
110
+ actual = eval "#{rails_expr}"
111
+ actual.should == expected
112
+ end
113
+
114
+
115
+ module FileHelpers
116
+ def append_to(path, contents)
117
+ in_current_dir do
118
+ File.open(path, "a") do |file|
119
+ file.puts
120
+ file.puts contents
121
+ end
122
+ end
123
+ end
124
+
125
+ def append_to_gemfile(contents)
126
+ append_to('Gemfile', contents)
127
+ end
128
+
129
+ def comment_out_gem_in_gemfile(gemname)
130
+ in_current_dir do
131
+ gemfile = File.read("Gemfile")
132
+ gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2")
133
+ File.open("Gemfile", 'w'){ |file| file.write(gemfile) }
134
+ end
135
+ end
136
+ end
137
+
138
+ World(FileHelpers)
@@ -0,0 +1,40 @@
1
+ Given /^I delete all migrations$/ do
2
+ steps %{
3
+ When I successfully run `bash -c 'rm db/migrate/*.rb'`
4
+ }
5
+ end
6
+
7
+ Given /^I update my new user model to be tableless$/ do
8
+ in_current_dir do
9
+ file_name = 'app/models/user.rb'
10
+ content = File.read(file_name)
11
+ if framework_version < "3.0"
12
+ content = "require 'activerecord-tableless'\n" + content
13
+ end
14
+
15
+ content.gsub!(/^(class .* < ActiveRecord::Base)$/, "\\1\n" + <<-TABLELESS)
16
+ has_no_table
17
+ column :id, :integer
18
+ column :name, :string
19
+
20
+ TABLELESS
21
+ File.open(file_name, 'w') { |f| f << content }
22
+ end
23
+ end
24
+
25
+ Given /^I update my users controller to render instead of redirect$/ do
26
+ in_current_dir do
27
+ file_name = 'app/controllers/users_controller.rb'
28
+ content = File.read(file_name)
29
+
30
+ content.gsub!("@user = User.new(params[:user])",
31
+ "@user = User.new(params[:user]); @user.id = 1")
32
+
33
+ content.gsub!("if @user.save",
34
+ "if @user.valid?")
35
+
36
+ content.gsub!(/format.html \{ redirect_to[\( ]@user, .*? \}/,
37
+ "format.html { render :action => 'show' }")
38
+ File.open(file_name, 'w') { |f| f << content }
39
+ end
40
+ end
@@ -0,0 +1,209 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
20
+
21
+
22
+ require 'uri'
23
+ require 'cgi'
24
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
+
27
+ module WithinHelpers
28
+ def with_scope(locator)
29
+ locator ? within(*selector_for(locator)) { yield } : yield
30
+ end
31
+ end
32
+ World(WithinHelpers)
33
+
34
+ # Single-line step scoper
35
+ When /^(.*) within (.*[^:])$/ do |step, parent|
36
+ with_scope(parent) { When step }
37
+ end
38
+
39
+ # Multi-line step scoper
40
+ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
41
+ with_scope(parent) { When "#{step}:", table_or_string }
42
+ end
43
+
44
+ Given /^(?:|I )am on (.+)$/ do |page_name|
45
+ visit path_to(page_name)
46
+ end
47
+
48
+ When /^(?:|I )go to (.+)$/ do |page_name|
49
+ visit path_to(page_name)
50
+ end
51
+
52
+ When /^(?:|I )press "([^"]*)"$/ do |button|
53
+ click_button(button)
54
+ end
55
+
56
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
57
+ click_link(link)
58
+ end
59
+
60
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
61
+ fill_in(field, :with => value)
62
+ end
63
+
64
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
65
+ fill_in(field, :with => value)
66
+ end
67
+
68
+ # Use this to fill in an entire form with data from a table. Example:
69
+ #
70
+ # When I fill in the following:
71
+ # | Account Number | 5002 |
72
+ # | Expiry date | 2009-11-01 |
73
+ # | Note | Nice guy |
74
+ # | Wants Email? | |
75
+ #
76
+ # TODO: Add support for checkbox, select og option
77
+ # based on naming conventions.
78
+ #
79
+ When /^(?:|I )fill in the following:$/ do |fields|
80
+ fields.rows_hash.each do |name, value|
81
+ When %{I fill in "#{name}" with "#{value}"}
82
+ end
83
+ end
84
+
85
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
86
+ select(value, :from => field)
87
+ end
88
+
89
+ When /^(?:|I )check "([^"]*)"$/ do |field|
90
+ check(field)
91
+ end
92
+
93
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
94
+ uncheck(field)
95
+ end
96
+
97
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
98
+ choose(field)
99
+ end
100
+
101
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
102
+ attach_file(field, File.expand_path(path))
103
+ end
104
+
105
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
106
+ if page.respond_to? :should
107
+ page.should have_content(text)
108
+ else
109
+ assert page.has_content?(text)
110
+ end
111
+ end
112
+
113
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
114
+ regexp = Regexp.new(regexp)
115
+
116
+ if page.respond_to? :should
117
+ page.should have_xpath('//*', :text => regexp)
118
+ else
119
+ assert page.has_xpath?('//*', :text => regexp)
120
+ end
121
+ end
122
+
123
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
124
+ if page.respond_to? :should
125
+ page.should have_no_content(text)
126
+ else
127
+ assert page.has_no_content?(text)
128
+ end
129
+ end
130
+
131
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
132
+ regexp = Regexp.new(regexp)
133
+
134
+ if page.respond_to? :should
135
+ page.should have_no_xpath('//*', :text => regexp)
136
+ else
137
+ assert page.has_no_xpath?('//*', :text => regexp)
138
+ end
139
+ end
140
+
141
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
142
+ with_scope(parent) do
143
+ field = find_field(field)
144
+ if field.value.respond_to? :should
145
+ field.value.should =~ /#{value}/
146
+ else
147
+ assert_match(/#{value}/, field.value)
148
+ end
149
+ end
150
+ end
151
+
152
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
153
+ with_scope(parent) do
154
+ field = find_field(field)
155
+ if field.value.respond_to? :should_not
156
+ field.value.should_not =~ /#{value}/
157
+ else
158
+ assert_no_match(/#{value}/, field.value)
159
+ end
160
+ end
161
+ end
162
+
163
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
164
+ with_scope(parent) do
165
+ field_checked = find_field(label)['checked']
166
+ if field_checked.respond_to? :should
167
+ field_checked.should be_true
168
+ else
169
+ assert field_checked
170
+ end
171
+ end
172
+ end
173
+
174
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
175
+ with_scope(parent) do
176
+ field_checked = find_field(label)['checked']
177
+ if field_checked.respond_to? :should
178
+ field_checked.should be_false
179
+ else
180
+ assert !field_checked
181
+ end
182
+ end
183
+ end
184
+
185
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
186
+ current_path = URI.parse(current_url).path
187
+ if current_path.respond_to? :should
188
+ current_path.should == path_to(page_name)
189
+ else
190
+ assert_equal path_to(page_name), current_path
191
+ end
192
+ end
193
+
194
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
195
+ query = URI.parse(current_url).query
196
+ actual_params = query ? CGI.parse(query) : {}
197
+ expected_params = {}
198
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
199
+
200
+ if actual_params.respond_to? :should
201
+ actual_params.should == expected_params
202
+ else
203
+ assert_equal expected_params, actual_params
204
+ end
205
+ end
206
+
207
+ Then /^show me the page$/ do
208
+ save_and_open_page
209
+ end
@@ -0,0 +1,15 @@
1
+ #require 'bundler'
2
+ begin
3
+ Bundler.setup(:default, :development)
4
+ rescue Bundler::BundlerError => e
5
+ $stderr.puts e.message
6
+ $stderr.puts "Run `bundle install` to install missing gems"
7
+ exit e.status_code
8
+ end
9
+
10
+ require 'aruba/cucumber'
11
+ require 'capybara/cucumber'
12
+
13
+ Before do
14
+ @aruba_timeout_seconds = 120
15
+ end
@@ -0,0 +1,28 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+ when /the new user page/
14
+ '/users/new'
15
+ else
16
+ begin
17
+ page_name =~ /the (.*) page/
18
+ path_components = $1.split(/\s+/)
19
+ self.send(path_components.push('path').join('_').to_sym)
20
+ rescue Object => e
21
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
22
+ "Now, go and add a mapping in #{__FILE__}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ World(NavigationHelpers)
@@ -0,0 +1,48 @@
1
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
2
+ APP_NAME = 'testapp'.freeze
3
+ BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
4
+ ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]
5
+
6
+ ENV['RAILS_ENV'] = 'test'
7
+
8
+ Before do
9
+ ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE']) unless ENV['BUNDLE_GEMFILE'].start_with?(Dir.pwd)
10
+ @framework_version = nil
11
+ end
12
+
13
+ After do
14
+ ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
15
+ ENV[key] = value
16
+ end
17
+ end
18
+
19
+ When /^I reset Bundler environment variable$/ do
20
+ BUNDLE_ENV_VARS.each do |key|
21
+ ENV[key] = nil
22
+ end
23
+ end
24
+
25
+ module RailsCommandHelpers
26
+ def framework_version?(version_string)
27
+ framework_version =~ /^#{version_string}/
28
+ end
29
+
30
+ def framework_version
31
+ @framework_version ||= `rails -v`[/^Rails (.+)$/, 1]
32
+ end
33
+
34
+ def new_application_command
35
+ framework_version?("3") ? "rails new" : "rails"
36
+ end
37
+
38
+ def generator_command
39
+ framework_version?("3") ? "script/rails generate" : "script/generate"
40
+ end
41
+
42
+ def runner_command
43
+ framework_version?("3") ? "script/rails runner" : "script/runner"
44
+ end
45
+
46
+ end
47
+
48
+ World(RailsCommandHelpers)
@@ -0,0 +1,19 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+ when "the page"
11
+ "html > body"
12
+ else
13
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
14
+ "Now, go and add a mapping in #{__FILE__}"
15
+ end
16
+ end
17
+ end
18
+
19
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 2.3.0"
6
+ gem "activerecord-tableless", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.0.0"
6
+ gem "activerecord-tableless", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2.0"
6
+ gem "jquery-rails"
7
+ gem "activerecord-tableless", :path=>"../"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.0"
6
+ gem "jquery-rails"
7
+ gem "activerecord-tableless", :path=>"../"
8
+
9
+ gemspec :path=>"../"
@@ -39,8 +39,16 @@ module ActiveRecord
39
39
  # it.
40
40
  def has_no_table
41
41
  # keep our options handy
42
- class_attribute :tableless_options
43
- self.tableless_options = {:columns => []}
42
+ if Rails::VERSION::STRING < "3.1.0"
43
+ write_inheritable_attribute(
44
+ :tableless_options,
45
+ :columns => []
46
+ )
47
+ class_inheritable_reader :tableless_options
48
+ else
49
+ class_attribute :tableless_options
50
+ self.tableless_options = {:columns => []}
51
+ end
44
52
 
45
53
  # extend
46
54
  extend ActiveRecord::Tableless::SingletonMethods
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: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-07 00:00:00.000000000 Z
14
+ date: 2013-01-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: '3.2'
23
+ version: 2.3.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ! '>='
30
30
  - !ruby/object:Gem::Version
31
- version: '3.2'
31
+ version: 2.3.0
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +61,102 @@ dependencies:
61
61
  - - ! '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: sqlite3
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '1.3'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '1.3'
80
+ - !ruby/object:Gem::Dependency
81
+ name: appraisal
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.4'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '0.4'
96
+ - !ruby/object:Gem::Dependency
97
+ name: cucumber
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: '1.1'
112
+ - !ruby/object:Gem::Dependency
113
+ name: launchy
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ~>
118
+ - !ruby/object:Gem::Version
119
+ version: '2.1'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ version: '2.1'
128
+ - !ruby/object:Gem::Dependency
129
+ name: aruba
130
+ requirement: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0.5'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0.5'
144
+ - !ruby/object:Gem::Dependency
145
+ name: capybara
146
+ requirement: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
64
160
  description: ActiveRecord Tableless Models provides a simple mixin for creating models
65
161
  that are not bound to the database. This approach is mostly useful for capitalizing
66
162
  on the features ActiveRecord::Validation
@@ -68,24 +164,32 @@ email:
68
164
  - jarl@softace.dk
69
165
  executables: []
70
166
  extensions: []
71
- extra_rdoc_files:
72
- - README
73
- - CHANGELOG
167
+ extra_rdoc_files: []
74
168
  files:
75
169
  - .gitignore
76
- - CHANGELOG
170
+ - Appraisals
77
171
  - Gemfile
78
- - README
172
+ - README.md
79
173
  - Rakefile
80
174
  - activerecord-tableless.gemspec
175
+ - features/basic_integration.feature
176
+ - features/step_definitions/rails_steps.rb
177
+ - features/step_definitions/tableless.rb
178
+ - features/step_definitions/web_steps.rb
179
+ - features/support/env.rb
180
+ - features/support/paths.rb
181
+ - features/support/rails.rb
182
+ - features/support/selectors.rb
183
+ - gemfiles/rails23.gemfile
184
+ - gemfiles/rails30.gemfile
185
+ - gemfiles/rails32.gemfile
186
+ - gemfiles/rails3x.gemfile
81
187
  - init.rb
82
188
  - lib/activerecord-tableless.rb
83
189
  homepage: https://github.com/softace/activerecord-tableless
84
190
  licenses: []
85
191
  post_install_message:
86
- rdoc_options:
87
- - --main
88
- - README
192
+ rdoc_options: []
89
193
  require_paths:
90
194
  - lib
91
195
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -96,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
200
  version: '0'
97
201
  segments:
98
202
  - 0
99
- hash: 193372649810044937
203
+ hash: -1781231480361877678
100
204
  required_rubygems_version: !ruby/object:Gem::Requirement
101
205
  none: false
102
206
  requirements:
@@ -105,11 +209,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
209
  version: '0'
106
210
  segments:
107
211
  - 0
108
- hash: 193372649810044937
212
+ hash: -1781231480361877678
109
213
  requirements: []
110
214
  rubyforge_project:
111
215
  rubygems_version: 1.8.24
112
216
  signing_key:
113
217
  specification_version: 3
114
218
  summary: A library for implementing tableless ActiveRecord models
115
- test_files: []
219
+ test_files:
220
+ - features/basic_integration.feature
221
+ - features/step_definitions/rails_steps.rb
222
+ - features/step_definitions/tableless.rb
223
+ - features/step_definitions/web_steps.rb
224
+ - features/support/env.rb
225
+ - features/support/paths.rb
226
+ - features/support/rails.rb
227
+ - features/support/selectors.rb
data/CHANGELOG DELETED
@@ -1,7 +0,0 @@
1
- 0.1.1 - Jul 21th 2009
2
- * Method for bulk adding of columns
3
- * Code cleaning
4
- * Rename of the project
5
-
6
- 0.1.0 - May 1st 2008
7
- * Initial code, rough around the edges.
data/README DELETED
@@ -1,34 +0,0 @@
1
- ActiveRecord Tableless
2
- ----------------------
3
-
4
- A single implementation of the ActiveRecord Tableless pattern for any Rails
5
- project or other Ruby project that uses ActiveRecord.
6
-
7
- Define a model like this:
8
-
9
- class ContactMessage < ActiveRecord::Base
10
- has_no_table
11
- column :name, :string
12
- column :email, :string
13
- validates_presence_of :name, :email
14
- end
15
-
16
- You can now use the model in a view like this:
17
-
18
- <%= form_for :message, @message do |f| %>
19
- Your name: <%= f.text_field :name %>
20
- Your email: <%= f.text_field :email %>
21
- <% end %>
22
-
23
- And in the controller:
24
-
25
- def message
26
- @message = ContactMessage.new
27
- if request.post?
28
- @message.attributes = params[:message]
29
- if @message.valid?
30
- # Process the message...
31
- end
32
- end
33
- end
34
-