Create dummy rails app with combustion and first tests
This commit is contained in:
		
							parent
							
								
									66fb7733b4
								
							
						
					
					
						commit
						6257d03e45
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,5 +1,6 @@
 | 
			
		||||
*.gem
 | 
			
		||||
*.rbc
 | 
			
		||||
*.sqlite
 | 
			
		||||
.bundle
 | 
			
		||||
.config
 | 
			
		||||
.yardoc
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								spec/internal/app/models/moderation.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								spec/internal/app/models/moderation.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
class Moderation < ActiveRecord::Base
 | 
			
		||||
  include TheModerator::ModerationModel
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										2
									
								
								spec/internal/app/models/page.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								spec/internal/app/models/page.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
class Page < ActiveRecord::Base
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										3
									
								
								spec/internal/config/database.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								spec/internal/config/database.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
test:
 | 
			
		||||
  adapter:  sqlite3
 | 
			
		||||
  database: db/combustion_test.sqlite
 | 
			
		||||
							
								
								
									
										3
									
								
								spec/internal/config/routes.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								spec/internal/config/routes.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
Rails.application.routes.draw do
 | 
			
		||||
  #
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										14
									
								
								spec/internal/db/schema.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								spec/internal/db/schema.rb
									
									
									
									
									
										Normal 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
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								spec/internal/log/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
*.log
 | 
			
		||||
							
								
								
									
										14
									
								
								spec/spec_helper.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								spec/spec_helper.rb
									
									
									
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										24
									
								
								spec/the_moderator/model_spec.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								spec/the_moderator/model_spec.rb
									
									
									
									
									
										Normal 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
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user