Skip to content

Commit

Permalink
Appraisals + all the rails gemfiles init
Browse files Browse the repository at this point in the history
  • Loading branch information
pyromaniac committed May 2, 2015
1 parent be11978 commit 69a2125
Show file tree
Hide file tree
Showing 19 changed files with 162 additions and 65 deletions.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--colour
--backtrace
--order random
2 changes: 1 addition & 1 deletion .rvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rvm use --create 2.0.0@active_data
rvm use --create 2.1.5@active_data
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
rvm:
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.0
- rbx

gemfile:
- Gemfile
- gemfiles/Gemfile.rails-3.2
- gemfiles/Gemfile.rails-4.0
- gemfiles/rails.3.2.gemfile
- gemfiles/rails.4.0.gemfile
- gemfiles/rails.4.1.gemfile
- gemfiles/rails.4.2.gemfile

matrix:
exclude:
- rvm: 2.2.0
gemfile: gemfiles/rails.3.2.gemfile
7 changes: 7 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%w(3.2 4.0 4.1 4.2).each do |version|
appraise "rails.#{version}" do
gem 'activesupport', "~> #{version}.0"
gem 'activemodel', "~> #{version}.0"
gem 'activerecord', "~> #{version}.0"
end
end
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in active_data.gemspec
gemspec

group :test do
gem 'guard'
gem 'guard-rspec'
gem 'rb-inotify', require: false
gem 'rb-fsevent', require: false
gem 'rb-fchange', require: false
end
83 changes: 68 additions & 15 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,77 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features)

## Uncomment to clear the screen before every task
# clearing :on

## Guard internally checks for changes in the Guardfile and exits.
## If you want Guard to automatically start up again, run guard in a
## shell loop, e.g.:
##
## $ while bundle exec guard; do echo "Restarting Guard..."; done
##
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(rails.controllers) do |m|
[
rspec.spec.("routing/#{m[1]}_routing"),
rspec.spec.("controllers/#{m[1]}_controller"),
rspec.spec.("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[![Build Status](https://travis-ci.org/pyromaniac/active_data.png?branch=master)](https://travis-ci.org/pyromaniac/active_data)
[![Code Climate](https://codeclimate.com/github/pyromaniac/active_data.png)](https://codeclimate.com/github/pyromaniac/active_data)
[![Coverage Status](https://coveralls.io/repos/pyromaniac/active_data/badge.png?branch=master)](https://coveralls.io/r/pyromaniac/active_data?branch=master)


# ActiveData

Expand Down
5 changes: 3 additions & 2 deletions active_data.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Gem::Specification.new do |gem|
gem.version = ActiveData::VERSION

gem.add_development_dependency 'rake'
gem.add_development_dependency 'appraisal'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'rspec-its'
gem.add_development_dependency 'rubysl', '~> 2.0' if RUBY_ENGINE == 'rbx'
gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'sqlite3', '1.3.8'
gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'database_cleaner'
gem.add_development_dependency 'activerecord', '>= 3.2'
gem.add_development_dependency 'uuidtools'
Expand Down
15 changes: 0 additions & 15 deletions gemfiles/Gemfile.rails-3.2

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/Gemfile.rails-4.0

This file was deleted.

14 changes: 14 additions & 0 deletions gemfiles/rails.3.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 3.2.0"
gem "activemodel", "~> 3.2.0"
gem "activerecord", "~> 3.2.0"

group :test do
gem "guard"
gem "guard-rspec"
end

gemspec :path => "../"
14 changes: 14 additions & 0 deletions gemfiles/rails.4.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 4.0.0"
gem "activemodel", "~> 4.0.0"
gem "activerecord", "~> 4.0.0"

group :test do
gem "guard"
gem "guard-rspec"
end

gemspec :path => "../"
14 changes: 14 additions & 0 deletions gemfiles/rails.4.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 4.1.0"
gem "activemodel", "~> 4.1.0"
gem "activerecord", "~> 4.1.0"

group :test do
gem "guard"
gem "guard-rspec"
end

gemspec :path => "../"
14 changes: 14 additions & 0 deletions gemfiles/rails.4.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activesupport", "~> 4.2.0"
gem "activemodel", "~> 4.2.0"
gem "activerecord", "~> 4.2.0"

group :test do
gem "guard"
gem "guard-rspec"
end

gemspec :path => "../"
3 changes: 2 additions & 1 deletion lib/active_data.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'active_support'
require 'active_support/concern'
require 'active_support/deprecation'
require 'active_support/core_ext'
require 'active_support/concern'
require 'singleton'

require 'active_model'
Expand Down
6 changes: 5 additions & 1 deletion lib/active_data/active_record/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def is_a? klass
}
))
reflection.define_methods self
self.reflections = reflections.merge(reflection.name => reflection)
if ::ActiveRecord::Reflection.respond_to? :add_reflection
::ActiveRecord::Reflection.add_reflection self, reflection.name, reflection
else
self.reflections = reflections.merge(reflection.name => reflection)
end

callback_name = "update_#{reflection.name}_association"
before_save callback_name
Expand Down
5 changes: 5 additions & 0 deletions lib/active_data/model/associations/reflections/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Base
WRITE = ->(reflection, object, value) { object.write_attribute reflection.name, value }

attr_reader :name, :options
attr_accessor :parent_reflection

def initialize name, options = {}
@name, @options = name.to_sym, options
Expand All @@ -24,6 +25,10 @@ def validate?
false
end

def belongs_to?
false
end

def class_name
@class_name ||= (options[:class_name].presence || name.to_s.classify).to_s
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/active_data/model/lifecycle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def append action
specify { expect { subject.destroy }.to raise_error ActiveData::UndestroyableObject }
specify { expect { subject.destroy! }.to raise_error ActiveData::UndestroyableObject }

specify { subject.destroy { true }.should be_true }
specify { subject.destroy! { true }.should be_true }
specify { subject.destroy { true }.should be_a User }
specify { subject.destroy! { true }.should be_a User }

context 'instance performer' do
before { subject.define_save { false } }
Expand Down
5 changes: 2 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require 'bundler'
Bundler.require

require 'coveralls'
Coveralls.wear!

require 'rspec/its'
require 'active_record'
require 'database_cleaner'

Expand All @@ -22,6 +20,7 @@

RSpec.configure do |config|
config.mock_with :rspec
config.order = :random

config.include ModelHelpers

Expand Down

0 comments on commit 69a2125

Please sign in to comment.