Create dummy rails app with combustion and first tests

master
Guillaume DOTT 2013-11-27 14:58:21 +01:00
parent 66fb7733b4
commit 6257d03e45
11 changed files with 72 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.gem
*.rbc
*.sqlite
.bundle
.config
.yardoc

2
.rspec 100644
View File

@ -0,0 +1,2 @@
--color
--format progress

View File

@ -0,0 +1,3 @@
class Moderation < ActiveRecord::Base
include TheModerator::ModerationModel
end

View File

@ -0,0 +1,2 @@
class Page < ActiveRecord::Base
end

View File

@ -0,0 +1,3 @@
test:
adapter: sqlite3
database: db/combustion_test.sqlite

View File

@ -0,0 +1,3 @@
Rails.application.routes.draw do
#
end

View File

@ -0,0 +1,14 @@
ActiveRecord::Schema.define do
create_table :pages, :force => true do |t|
t.string :name
t.text :content
t.timestamps
end
create_table :moderations, :force => true do |t|
t.integer :moderatable_id
t.string :moderatable_type
t.text :data
t.timestamps
end
end

1
spec/internal/log/.gitignore vendored 100644
View File

@ -0,0 +1 @@
*.log

View File

@ -0,0 +1,14 @@
require 'bundler/setup'
require 'combustion'
require 'the_moderator'
Combustion.initialize! :active_record, :active_model
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'
end

View File

@ -0,0 +1,24 @@
require 'spec_helper'
describe TheModerator::Model do
subject { Page.new(name: 'Name', content: 'Content') }
describe '#moderate' do
it 'moderates simple field' do
subject.moderate(:name)
expect(subject.moderations).to have(1).moderation
expect(subject.name).to eq(nil)
expect(subject.content).to eq('Content')
end
end
describe '#moderated?' do
it 'detects moderated field' do
subject.moderate(:name)
expect(subject.moderated?(:name)).to be_true
expect(subject.moderated?(:content)).to be_false
end
end
end

View File

@ -23,4 +23,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 2.14.0"
spec.add_development_dependency "combustion", "~> 0.5.0"
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "pry"
end