Permalink
Browse files

Added combustion to the project so that we can run specs inside the e…

…ngine itself. I've removed refinerycms-generators dependency from the project which means the generators aren't working right now but will be fixed later on.
  • Loading branch information...
1 parent a1e975a commit 1cdb7d44f2377452cdd0ba47eb7760b0fa224203 @parndt committed Aug 31, 2011
Showing with 293 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +3 −0 Gemfile
  3. +113 −0 Gemfile.lock
  4. +2 −0 lib/seo_meta.rb
  5. +4 −1 seo_meta.gemspec
  6. +18 −0 spec/internal/config/database.yml
  7. +22 −0 spec/internal/db/schema.rb
  8. +73 −0 spec/models/seo_meta_spec.rb
  9. +56 −0 spec/spec_helper.rb
View
2 .gitignore
@@ -0,0 +1,2 @@
+spec/internal/db/*.sqlite3
+spec/internal/log/*.log
View
3 Gemfile
@@ -0,0 +1,3 @@
+source 'http://rubygems.org'
+
+gemspec
View
113 Gemfile.lock
@@ -0,0 +1,113 @@
+PATH
+ remote: .
+ specs:
+ seo_meta (1.2.0.rc1)
+ rails (>= 3.0.0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.0)
+ actionpack (= 3.1.0)
+ mail (~> 2.3.0)
+ actionpack (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.0.3)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.0)
+ activemodel (3.1.0)
+ activesupport (= 3.1.0)
+ bcrypt-ruby (~> 3.0.0)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.0)
+ activemodel (= 3.1.0)
+ activesupport (= 3.1.0)
+ activesupport (3.1.0)
+ multi_json (~> 1.0)
+ arel (2.2.1)
+ bcrypt-ruby (3.0.0)
+ builder (3.0.0)
+ combustion (0.2.0)
+ rails (>= 3.1.0.rc5)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ polyglot (0.3.2)
+ rack (1.3.2)
+ rack-cache (1.0.3)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.0)
+ actionmailer (= 3.1.0)
+ actionpack (= 3.1.0)
+ activerecord (= 3.1.0)
+ activeresource (= 3.1.0)
+ activesupport (= 3.1.0)
+ bundler (~> 1.0)
+ railties (= 3.1.0)
+ railties (3.1.0)
+ actionpack (= 3.1.0)
+ activesupport (= 3.1.0)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
+ sprockets (2.0.0)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (!= 1.3.0, ~> 1.1)
+ sqlite3 (1.3.4)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.29)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ combustion
+ rspec-rails
+ seo_meta!
+ sqlite3
View
2 lib/seo_meta.rb
@@ -1,3 +1,5 @@
+require 'rails'
+
module SeoMeta
class << self
View
5 seo_meta.gemspec
@@ -11,5 +11,8 @@ Gem::Specification.new do |s|
s.require_paths = %w(lib)
s.files = Dir['lib/**/*', 'db/**/*', 'app/**/*', 'config/**/*', '*.md']
- s.add_dependency 'refinerycms-generators', '~> 2.0'
+ s.add_development_dependency 'combustion'
+ s.add_development_dependency 'rspec-rails'
+ s.add_development_dependency 'sqlite3'
+ s.add_dependency 'rails', '>= 3.0.0'
end
View
18 spec/internal/config/database.yml
@@ -0,0 +1,18 @@
+# SQLite version 3.x
+development:
+ adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
+ database: db/development.sqlite3
+ timeout: 5000
+
+# Warning: The database defined as 'test' will be erased and
+# re-generated from your development database when you run 'rake'.
+# Do not set this db to the same as development or production.
+test:
+ adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
+ database: db/test.sqlite3
+ timeout: 5000
+
+production:
+ adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
+ database: db/production.sqlite3
+ timeout: 5000
View
22 spec/internal/db/schema.rb
@@ -0,0 +1,22 @@
+# Defined based on the migrations and the dummy spec model.
+
+::ActiveRecord::Schema.define(:version => 20110329222114) do
+
+ create_table 'seo_meta', :force => true do |t|
+ t.integer 'seo_meta_id'
+ t.string 'seo_meta_type'
+
+ t.string 'browser_title'
+ t.string 'meta_keywords'
+ t.text 'meta_description'
+
+ t.timestamps
+ end
+
+ add_index 'seo_meta', 'id'
+ add_index 'seo_meta', ['seo_meta_id', 'seo_meta_type']
+
+ create_table 'seo_meta_dummy_for_specs', :force => true do |t|
+ t.timestamps
+ end
+end
View
73 spec/models/seo_meta_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+module SeoMeta
+ class DummyForSpec < ActiveRecord::Base
+ set_table_name 'seo_meta_dummy_for_specs'
+
+ is_seo_meta
+ end
+end
+
+module SeoMeta
+ describe DummyForSpec do
+ let(:dummy_for_spec) { DummyForSpec.create }
+
+ context 'responds to' do
+ it 'meta_keywords' do
+ dummy_for_spec.respond_to?(:meta_keywords)
+ end
+
+ it 'meta_description' do
+ dummy_for_spec.respond_to?(:meta_description)
+ end
+
+ it 'browser_title' do
+ dummy_for_spec.respond_to?(:browser_title)
+ end
+ end
+
+ context 'allows us to assign to' do
+ it 'meta_keywords' do
+ dummy_for_spec.meta_keywords = 'Some, great, keywords'
+ dummy_for_spec.meta_keywords.should == 'Some, great, keywords'
+ end
+
+ it 'meta_description' do
+ dummy_for_spec.meta_description = 'This is my description of the dummy_for_spec for search results.'
+ dummy_for_spec.meta_description.should == 'This is my description of the dummy_for_spec for search results.'
+ end
+
+ it 'browser_title' do
+ dummy_for_spec.browser_title = 'An awesome browser title for SEO'
+ dummy_for_spec.browser_title.should == 'An awesome browser title for SEO'
+ end
+ end
+
+ context 'allows us to update' do
+ it 'meta_keywords' do
+ dummy_for_spec.meta_keywords = 'Some, great, keywords'
+ dummy_for_spec.save
+
+ dummy_for_spec.reload
+ dummy_for_spec.meta_keywords.should == 'Some, great, keywords'
+ end
+
+ it 'meta_description' do
+ dummy_for_spec.meta_description = 'This is my description of the dummy_for_spec for search results.'
+ dummy_for_spec.save
+
+ dummy_for_spec.reload
+ dummy_for_spec.meta_description.should == 'This is my description of the dummy_for_spec for search results.'
+ end
+
+ it 'browser_title' do
+ dummy_for_spec.browser_title = 'An awesome browser title for SEO'
+ dummy_for_spec.save
+
+ dummy_for_spec.reload
+ dummy_for_spec.browser_title.should == 'An awesome browser title for SEO'
+ end
+ end
+
+ end
+end
View
56 spec/spec_helper.rb
@@ -0,0 +1,56 @@
+require 'rubygems'
+require 'bundler'
+
+def setup_environment
+ # Configure Rails Environment
+ ENV["RAILS_ENV"] ||= 'test'
+
+ Bundler.require(:default, :development)
+
+ Combustion.initialize! :active_record
+
+ require 'rspec/rails'
+
+ Rails.backtrace_cleaner.remove_silencers!
+
+ Dir[File.expand_path('../support/*.rb', __FILE__)].each do |support|
+ require support
+ end
+
+ RSpec.configure do |config|
+ config.mock_with :rspec
+ end
+end
+
+def each_run
+end
+
+# If spork is available in the Gemfile it'll be used but we don't force it.
+unless (begin; require 'spork'; rescue LoadError; nil end).nil?
+ Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+ setup_environment
+ end
+
+ Spork.each_run do
+ # This code will be run each time you run your specs.
+ each_run
+ end
+else
+ setup_environment
+ each_run
+end
+
+def capture_stdout(stdin_str = '')
+ begin
+ require 'stringio'
+ $o_stdin, $o_stdout, $o_stderr = $stdin, $stdout, $stderr
+ $stdin, $stdout, $stderr = StringIO.new(stdin_str), StringIO.new, StringIO.new
+ yield
+ {:stdout => $stdout.string, :stderr => $stderr.string}
+ ensure
+ $stdin, $stdout, $stderr = $o_stdin, $o_stdout, $o_stderr
+ end
+end

0 comments on commit 1cdb7d4

Please sign in to comment.