activerecord-tablefree 3.1.7 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +139 -0
- data/LICENSE.md +16 -0
- data/README.md +438 -129
- data/lib/activerecord/tablefree/cast_type.rb +16 -1
- data/lib/activerecord/tablefree/connection.rb +30 -13
- data/lib/activerecord/tablefree/connection_pool.rb +28 -0
- data/lib/activerecord/tablefree/version.rb +7 -1
- data/lib/activerecord/tablefree.rb +75 -36
- data/lib/activerecord-tablefree.rb +7 -1
- data/sig/activerecord/tablefree.rbs +21 -0
- data.tar.gz.sig +0 -0
- metadata +180 -119
- metadata.gz.sig +0 -0
- data/.gitignore +0 -21
- data/.rspec +0 -1
- data/.travis.yml +0 -67
- data/Appraisals +0 -16
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -25
- data/Rakefile +0 -48
- data/activerecord-tablefree.gemspec +0 -50
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/features/basic_integration.feature +0 -16
- data/features/step_definitions/rails_steps.rb +0 -138
- data/features/step_definitions/tablefree.rb +0 -37
- data/features/step_definitions/web_steps.rb +0 -139
- data/features/support/env.rb +0 -15
- data/features/support/paths.rb +0 -28
- data/features/support/rails.rb +0 -51
- data/features/support/selectors.rb +0 -19
- data/gemfiles/rails50.gemfile +0 -9
- data/gemfiles/rails51.gemfile +0 -9
- data/gemfiles/rails52.gemfile +0 -9
- data/init.rb +0 -4
- data/spec/activerecord/tablefree/version_spec.rb +0 -5
- data/spec/activerecord/tablefree_spec.rb +0 -352
- data/spec/spec_helper.rb +0 -10
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
LICENSE
|
|
3
|
-
|
|
4
|
-
The MIT License
|
|
5
|
-
|
|
6
|
-
Copyright (c) 2008 Jarl Friis. (released as activerecord-tableless)
|
|
7
|
-
Copyright (c) 2017 Peter Boling, Bolt Threads.
|
|
8
|
-
|
|
9
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
in the Software without restriction, including without limitation the rights
|
|
12
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
furnished to do so, subject to the following conditions:
|
|
15
|
-
|
|
16
|
-
The above copyright notice and this permission notice shall be included in
|
|
17
|
-
all copies or substantial portions of the Software.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
25
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'bundler/gem_tasks'
|
|
2
|
-
require 'appraisal'
|
|
3
|
-
require 'rake/testtask'
|
|
4
|
-
require 'rspec/core/rake_task'
|
|
5
|
-
require 'cucumber/rake/task'
|
|
6
|
-
|
|
7
|
-
desc 'Default: clean, all.'
|
|
8
|
-
task default: %i[clean all]
|
|
9
|
-
|
|
10
|
-
desc 'Test the activerecord-tablefree on all supported Rails versions.'
|
|
11
|
-
task :all do |_t|
|
|
12
|
-
# TODO: cucumber feature specs appear to be written for Rails 2, and will need an overhaul for Rails 5.
|
|
13
|
-
if ENV['BUNDLE_GEMFILE']
|
|
14
|
-
exec('rake test spec')
|
|
15
|
-
# exec('rake test spec cucumber')
|
|
16
|
-
else
|
|
17
|
-
Rake::Task['appraisal:install'].execute
|
|
18
|
-
exec('rake appraisal test spec')
|
|
19
|
-
# exec('rake appraisal test spec cucumber')
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
desc 'Test the activerecord-tablefree plugin.'
|
|
24
|
-
Rake::TestTask.new(:test) do |t|
|
|
25
|
-
t.libs << 'lib' << 'profile'
|
|
26
|
-
t.pattern = 'test/**/*_test.rb'
|
|
27
|
-
t.verbose = true
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
desc 'Run specs'
|
|
31
|
-
RSpec::Core::RakeTask.new do |t|
|
|
32
|
-
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
|
|
33
|
-
# Put spec opts in a file named .rspec in root
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
desc 'Run integration test'
|
|
37
|
-
Cucumber::Rake::Task.new do |t|
|
|
38
|
-
t.cucumber_opts = %w[--format progress]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
desc 'Clean up files.'
|
|
42
|
-
task :clean do |_t|
|
|
43
|
-
FileUtils.rm_rf 'doc'
|
|
44
|
-
FileUtils.rm_rf 'tmp'
|
|
45
|
-
FileUtils.rm_rf 'pkg'
|
|
46
|
-
FileUtils.rm_rf 'public'
|
|
47
|
-
Dir.glob('activerecord-tablefree-*.gem').each { |f| FileUtils.rm f }
|
|
48
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# -*- ruby -*-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
|
|
5
|
-
require 'activerecord/tablefree/version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |gem|
|
|
8
|
-
gem.name = 'activerecord-tablefree'
|
|
9
|
-
gem.version = ActiveRecord::Tablefree::VERSION
|
|
10
|
-
gem.platform = Gem::Platform::RUBY
|
|
11
|
-
gem.authors = ['Jarl Friis', 'Kenneth Kalmer', 'Michal Zima', 'Peter Boling']
|
|
12
|
-
gem.email = ['jarl@softace.dk', 'peter.boling@gmail.com']
|
|
13
|
-
gem.homepage = 'https://github.com/boltthreads/activerecord-tablefree'
|
|
14
|
-
gem.summary = 'A library for implementing tablefree ActiveRecord models in Rails 5+'
|
|
15
|
-
gem.description = 'ActiveRecord Tablefree Models provides a simple mixin for creating models that are not bound to the database. This approach is useful for taking advantage of the features of ActiveRecord such as validation, relationships, nested_attributes, etc.'
|
|
16
|
-
gem.license = 'MIT'
|
|
17
|
-
|
|
18
|
-
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
|
19
|
-
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
20
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
21
|
-
|
|
22
|
-
gem.require_paths = ['lib']
|
|
23
|
-
|
|
24
|
-
gem.required_ruby_version = '>= 2.2.2' # Requirement for Rails 5
|
|
25
|
-
|
|
26
|
-
gem.add_runtime_dependency('activerecord', '~> 5.0', '>= 5.0.0')
|
|
27
|
-
|
|
28
|
-
gem.add_development_dependency('bundler', '~> 1')
|
|
29
|
-
gem.add_development_dependency('rake', '~> 12', '> 0')
|
|
30
|
-
|
|
31
|
-
# gem.add_development_dependency("rails") # This is in the appraisal gemfiles
|
|
32
|
-
gem.add_development_dependency('sqlite3', '~> 1')
|
|
33
|
-
|
|
34
|
-
gem.add_development_dependency('appraisal', '~> 1')
|
|
35
|
-
gem.add_development_dependency('aruba', '~> 0')
|
|
36
|
-
gem.add_development_dependency('cucumber', '~> 3')
|
|
37
|
-
gem.add_development_dependency('rspec', '~> 3')
|
|
38
|
-
gem.add_development_dependency('rspec-collection_matchers', '~> 1')
|
|
39
|
-
|
|
40
|
-
gem.add_development_dependency('capybara', '~> 2')
|
|
41
|
-
gem.add_development_dependency('coveralls', '~> 0')
|
|
42
|
-
gem.add_development_dependency('gem-release', '~> 2')
|
|
43
|
-
gem.add_development_dependency('listen', '~> 3')
|
|
44
|
-
gem.add_development_dependency('nokogiri', '~> 1.0')
|
|
45
|
-
gem.add_development_dependency('rails', '~> 5')
|
|
46
|
-
gem.add_development_dependency('wwtd', '~> 1')
|
|
47
|
-
|
|
48
|
-
# gem.add_development_dependency('launchy', '~> 2.1')
|
|
49
|
-
# gem.add_development_dependency('debugger')
|
|
50
|
-
end
|
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
require 'activerecord/tablefree'
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require 'irb'
|
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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 tablefree
|
|
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
|
-
|
|
@@ -1,138 +0,0 @@
|
|
|
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 fix the application.rb for 3.0.12
|
|
7
|
-
And I write to "Gemfile" with:
|
|
8
|
-
"""
|
|
9
|
-
source "http://rubygems.org"
|
|
10
|
-
gem "rails", "#{framework_version}"
|
|
11
|
-
gem "sqlite3"
|
|
12
|
-
gem "capybara"
|
|
13
|
-
gem "gherkin"
|
|
14
|
-
"""
|
|
15
|
-
And I configure the application to use "activerecord-tablefree" 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 fix the application.rb for 3.0.12' do
|
|
22
|
-
# #See https://github.com/rails/rails/issues/9619
|
|
23
|
-
in_current_dir do
|
|
24
|
-
File.open('config/application.rb', 'a') do |f|
|
|
25
|
-
f << "ActionController::Base.config.relative_url_root = ''"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Given /^I run a "(.*?)" generator to generate a "(.*?)" scaffold with "(.*?)"$/ do |generator_name, model_name, attributes|
|
|
31
|
-
step %(I successfully run `bundle exec #{generator_command} #{generator_name} #{model_name} #{attributes}`)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
Given /^I start the rails application$/ do
|
|
35
|
-
in_current_dir do
|
|
36
|
-
require './config/environment'
|
|
37
|
-
require 'capybara/rails'
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
Given /^I reload my application$/ do
|
|
42
|
-
Rails::Application.reload!
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
When /I turn off class caching/ do
|
|
46
|
-
in_current_dir do
|
|
47
|
-
file = 'config/environments/test.rb'
|
|
48
|
-
config = IO.read(file)
|
|
49
|
-
config.gsub!(/^\s*config.cache_classes.*$/,
|
|
50
|
-
'config.cache_classes = false')
|
|
51
|
-
File.open(file, 'w') { |f| f.write(config) }
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
Given /^I update my application to use Bundler$/ do
|
|
56
|
-
if framework_version?('2')
|
|
57
|
-
boot_config_template = File.read('features/support/fixtures/boot_config.txt')
|
|
58
|
-
preinitializer_template = File.read('features/support/fixtures/preinitializer.txt')
|
|
59
|
-
gemfile_template = File.read('features/support/fixtures/gemfile.txt')
|
|
60
|
-
in_current_dir do
|
|
61
|
-
content = File.read('config/boot.rb').sub(/Rails\.boot!/, boot_config_template)
|
|
62
|
-
File.open('config/boot.rb', 'w') { |file| file.write(content) }
|
|
63
|
-
File.open('config/preinitializer.rb', 'w') { |file| file.write(preinitializer_template) }
|
|
64
|
-
File.open('Gemfile', 'w') { |file| file.write(gemfile_template.sub(/RAILS_VERSION/, framework_version)) }
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
|
|
70
|
-
expected = IO.binread(path)
|
|
71
|
-
actual = if web_file =~ %r{^https?://}
|
|
72
|
-
Net::HTTP.get(URI.parse(web_file))
|
|
73
|
-
else
|
|
74
|
-
visit(web_file)
|
|
75
|
-
page.source
|
|
76
|
-
end
|
|
77
|
-
actual.should == expected
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
|
|
81
|
-
append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
|
|
82
|
-
steps %(And I run `bundle install --local`)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
|
|
86
|
-
append_to_gemfile "gem '#{gem_name}'"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
When /^I append gems from Appraisal Gemfile$/ do
|
|
90
|
-
File.read(ENV['BUNDLE_GEMFILE']).split(/\n/).each do |line|
|
|
91
|
-
append_to_gemfile line.strip if line =~ /^gem "(?!rails|appraisal)/
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
When /^I comment out the gem "(.*?)" from the Gemfile$/ do |gemname|
|
|
96
|
-
comment_out_gem_in_gemfile gemname
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
Then /^the result of "(.*?)" should be the same as "(.*?)"$/ do |rails_expr, path|
|
|
100
|
-
expected = IO.binread(path)
|
|
101
|
-
actual = eval rails_expr.to_s
|
|
102
|
-
actual.should == expected
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
module FileHelpers
|
|
106
|
-
def append_to(path, contents)
|
|
107
|
-
in_current_dir do
|
|
108
|
-
File.open(path, 'a') do |file|
|
|
109
|
-
file.puts
|
|
110
|
-
file.puts contents
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def append_to_gemfile(contents)
|
|
116
|
-
append_to('Gemfile', contents)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def comment_out_gem_in_gemfile(gemname)
|
|
120
|
-
in_current_dir do
|
|
121
|
-
gemfile = File.read('Gemfile')
|
|
122
|
-
gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, '\\1# \\2')
|
|
123
|
-
File.open('Gemfile', 'w') { |file| file.write(gemfile) }
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def transform_file(filename)
|
|
128
|
-
if File.exist?(filename)
|
|
129
|
-
content = File.read(filename)
|
|
130
|
-
File.open(filename, 'w') do |f|
|
|
131
|
-
content = yield(content)
|
|
132
|
-
f.write(content)
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
World(FileHelpers)
|
|
@@ -1,37 +0,0 @@
|
|
|
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 tablefree$/ 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-tablefree'\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
|
-
transform_file('app/controllers/users_controller.rb') do |content|
|
|
28
|
-
# #Changes in #create method
|
|
29
|
-
content.gsub!(/@user = User.new\((.*?)\)/,
|
|
30
|
-
'@user = User.new(\1); @user.id = 1')
|
|
31
|
-
content.gsub!('if @user.save',
|
|
32
|
-
'if @user.valid?')
|
|
33
|
-
content.gsub!(/redirect_to([\( ])@user, .*?([\)]| \}|$)/,
|
|
34
|
-
"render\\1:action => 'show'\\2")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,139 +0,0 @@
|
|
|
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
|
-
require 'uri'
|
|
22
|
-
require 'cgi'
|
|
23
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'support', 'paths'))
|
|
24
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'support', 'selectors'))
|
|
25
|
-
|
|
26
|
-
module WithinHelpers
|
|
27
|
-
def with_scope(locator)
|
|
28
|
-
locator ? within(*selector_for(locator)) { yield } : yield
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
World(WithinHelpers)
|
|
32
|
-
|
|
33
|
-
# Single-line step scoper
|
|
34
|
-
When /^(.*) within (.*[^:])$/ do |step, parent|
|
|
35
|
-
with_scope(parent) { When step }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Multi-line step scoper
|
|
39
|
-
When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
|
|
40
|
-
with_scope(parent) { When "#{step}:", table_or_string }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
Given /^(?:|I )am on (.+)$/ do |page_name|
|
|
44
|
-
visit path_to(page_name)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
When /^(?:|I )go to (.+)$/ do |page_name|
|
|
48
|
-
visit path_to(page_name)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
When /^(?:|I )press "([^"]*)"$/ do |button|
|
|
52
|
-
click_button(button)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
56
|
-
click_link(link)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
|
60
|
-
fill_in(field, with: value)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
|
64
|
-
fill_in(field, with: value)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Use this to fill in an entire form with data from a table. Example:
|
|
68
|
-
#
|
|
69
|
-
# When I fill in the following:
|
|
70
|
-
# | Account Number | 5002 |
|
|
71
|
-
# | Expiry date | 2009-11-01 |
|
|
72
|
-
# | Note | Nice guy |
|
|
73
|
-
# | Wants Email? | |
|
|
74
|
-
#
|
|
75
|
-
# TODO: Add support for checkbox, select og option
|
|
76
|
-
# based on naming conventions.
|
|
77
|
-
#
|
|
78
|
-
When /^(?:|I )fill in the following:$/ do |fields|
|
|
79
|
-
fields.rows_hash.each do |name, value|
|
|
80
|
-
When %(I fill in "#{name}" with "#{value}")
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
|
85
|
-
select(value, from: field)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
When /^(?:|I )check "([^"]*)"$/ do |field|
|
|
89
|
-
check(field)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
|
93
|
-
uncheck(field)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
When /^(?:|I )choose "([^"]*)"$/ do |field|
|
|
97
|
-
choose(field)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
|
101
|
-
attach_file(field, File.expand_path(path))
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
Then /^(?:|I )should (not )?see "([^"]*)"$/ do |negate, text|
|
|
105
|
-
should_name = negate ? :should_not : :should
|
|
106
|
-
if page.respond_to? should_name
|
|
107
|
-
page.send should_name, have_content(text)
|
|
108
|
-
else
|
|
109
|
-
assert(negate ? page.has_no_content?(text) : page.has_content?(text))
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
Then /^(?:|I )should (not )?see \/([^\/]*)\/$/ do |negate, regexp|
|
|
114
|
-
regexp = Regexp.new(regexp)
|
|
115
|
-
should_name = negate ? :should_not : :should
|
|
116
|
-
if page.respond_to? should_name
|
|
117
|
-
page.send should_name, have_xpath('//*', text: regexp)
|
|
118
|
-
else
|
|
119
|
-
assert(negate ? page.has_no_xpath?('//*', text: regexp) : page.has_xpath?('//*', text: regexp))
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
|
124
|
-
current_path = URI.parse(current_url).path
|
|
125
|
-
expect(current_path).to eq path_to(page_name)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
|
129
|
-
query = URI.parse(current_url).query
|
|
130
|
-
actual_params = query ? CGI.parse(query) : {}
|
|
131
|
-
expected_params = {}
|
|
132
|
-
expected_pairs.rows_hash.each_pair { |k, v| expected_params[k] = v.split(',') }
|
|
133
|
-
|
|
134
|
-
expect(actual_params).to eq expected_params
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
Then /^show me the page$/ do
|
|
138
|
-
save_and_open_page
|
|
139
|
-
end
|
data/features/support/env.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# require 'bundler'
|
|
2
|
-
begin
|
|
3
|
-
Bundler.setup(:default, :development)
|
|
4
|
-
rescue Bundler::BundlerError => e
|
|
5
|
-
warn e.message
|
|
6
|
-
warn '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
|
data/features/support/paths.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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 = Regexp.last_match(1).split(/\s+/)
|
|
19
|
-
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)
|
data/features/support/rails.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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].freeze
|
|
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 framework_major_version
|
|
35
|
-
framework_version.split('.').first.to_i
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def new_application_command(app_name)
|
|
39
|
-
framework_major_version >= 3 ? "rails new #{app_name} --skip-sprockets --skip-javascript --skip-bundle" : "rails #{app_name}"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def generator_command
|
|
43
|
-
framework_major_version >= 3 ? 'rails generate' : 'script/generate'
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def runner_command
|
|
47
|
-
framework_major_version >= 3 ? 'rails runner' : 'script/runner'
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
World(RailsCommandHelpers)
|
|
@@ -1,19 +0,0 @@
|
|
|
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)
|
data/gemfiles/rails50.gemfile
DELETED
data/gemfiles/rails51.gemfile
DELETED
data/gemfiles/rails52.gemfile
DELETED
data/init.rb
DELETED