Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

simple specs

  • Loading branch information...
commit 403cda4c2f0ec6b3ae2e086400b13b2afff3ccd1 1 parent c597616
@rwz authored
Showing with 258 additions and 78 deletions.
  1. +88 −56 Gemfile.lock
  2. +4 −10 Rakefile
  3. +7 −0 config.ru
  4. +4 −1 nestive.gemspec
  5. +76 −0 spec/controllers/nestive_spec.rb
  6. +2 −0  spec/internal/app/controllers/application_controller.rb
  7. +9 −0 spec/internal/app/controllers/nestive_controller.rb
  8. +7 −0 spec/internal/app/views/layouts/extend_one.html.erb
  9. +6 −0 spec/internal/app/views/layouts/extend_two.html.erb
  10. +15 −0 spec/internal/app/views/layouts/nestive.html.erb
  11. +6 −0 spec/internal/app/views/nestive/append.html.erb
  12. +1 −0  spec/internal/app/views/nestive/extended_one.html.erb
  13. +1 −0  spec/internal/app/views/nestive/extended_two.html.erb
  14. +1 −0  spec/internal/app/views/nestive/index.html.erb
  15. +6 −0 spec/internal/app/views/nestive/prepend.html.erb
  16. +7 −0 spec/internal/app/views/nestive/replace.html.erb
  17. +3 −0  spec/internal/config/database.yml
  18. +3 −0  spec/internal/config/routes.rb
  19. +2 −0  spec/internal/db/schema.rb
  20. +1 −0  spec/internal/log/.gitignore
  21. 0  spec/internal/public/favicon.ico
  22. +9 −0 spec/spec_helper.rb
  23. +0 −8 test/nestive_test.rb
  24. +0 −3  test/test_helper.rb
View
144 Gemfile.lock
@@ -1,78 +1,110 @@
PATH
remote: .
specs:
- nestive (0.0.1.pre)
+ nestive (0.1.0)
rails (~> 3.0)
GEM
remote: http://rubygems.org/
specs:
- abstract (1.0.0)
- actionmailer (3.0.7)
- actionpack (= 3.0.7)
- mail (~> 2.2.15)
- actionpack (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.5.0)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.14)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.7)
- activesupport (= 3.0.7)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activeresource (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- activesupport (3.0.7)
- arel (2.0.10)
- builder (2.1.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- i18n (0.5.0)
- mail (2.2.19)
- activesupport (>= 2.3.6)
+ actionmailer (3.2.1)
+ actionpack (= 3.2.1)
+ mail (~> 2.4.0)
+ actionpack (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ activerecord (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ arel (~> 3.0.0)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.0)
+ combustion (0.3.1)
+ rails (>= 3.1.0)
+ thor (>= 0.14.6)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.3)
+ json (1.6.5)
+ mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
- polyglot (0.3.1)
- rack (1.2.3)
- rack-mount (0.6.14)
- rack (>= 1.0.0)
- rack-test (0.5.7)
+ mime-types (1.17.2)
+ multi_json (1.1.0)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
rack (>= 1.0)
- rails (3.0.7)
- actionmailer (= 3.0.7)
- actionpack (= 3.0.7)
- activerecord (= 3.0.7)
- activeresource (= 3.0.7)
- activesupport (= 3.0.7)
+ rails (3.2.1)
+ actionmailer (= 3.2.1)
+ actionpack (= 3.2.1)
+ activerecord (= 3.2.1)
+ activeresource (= 3.2.1)
+ activesupport (= 3.2.1)
bundler (~> 1.0)
- railties (= 3.0.7)
- railties (3.0.7)
- actionpack (= 3.0.7)
- activesupport (= 3.0.7)
+ railties (= 3.2.1)
+ railties (3.2.1)
+ actionpack (= 3.2.1)
+ activesupport (= 3.2.1)
+ rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
- thor (~> 0.14.4)
- rake (0.9.0)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
- treetop (1.4.9)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.27)
+ tzinfo (0.3.31)
PLATFORMS
ruby
DEPENDENCIES
+ combustion
nestive!
- rails (~> 3.0)
+ rspec-rails
View
14 Rakefile
@@ -1,21 +1,15 @@
#!/usr/bin/env rake
-require 'rake/testtask'
+require 'rspec/core/rake_task'
require 'rdoc/task'
require 'bundler'
Bundler::GemHelper.install_tasks
-desc 'Default: run unit tests.'
-task :default => :test
+task :default => :spec
-desc 'Test the nestive plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
+desc 'Run specs'
+RSpec::Core::RakeTask.new
desc 'Generate documentation for the nestive plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
View
7 config.ru
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require :default, :development
+
+Combustion.initialize!
+run Combustion::Application
View
5 nestive.gemspec
@@ -19,5 +19,8 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency(%q<rails>, ["~> 3.0"])
+ s.add_dependency 'rails', '~> 3.0'
+ s.add_development_dependency 'combustion'
+ s.add_development_dependency 'rspec-rails'
+
end
View
76 spec/controllers/nestive_spec.rb
@@ -0,0 +1,76 @@
+require 'spec_helper'
+
+describe NestiveController do
+ render_views
+
+ context '#area' do
+ it 'is empty by default' do
+ get :index
+ assert_select '#empty-area', ''
+ end
+
+ it 'shows initial value if any' do
+ get :index
+ assert_select 'title', 'Nestive'
+ end
+
+ it 'can accept blocks as initial value' do
+ get :index
+ assert_select '#some-area', 'Some content'
+ end
+ end
+
+ context '#append' do
+ it 'appends content to area as a string' do
+ get :append
+ assert_select 'title', 'Nestive is awesome'
+ end
+
+ it 'appends content to area as a block' do
+ get :append
+ assert_select '#some-area', "Some content\n Another content"
+ end
+ end
+
+ context '#prepend' do
+ it 'prepends content to area as a string' do
+ get :prepend
+ assert_select 'title', 'Awesome Nestive'
+ end
+
+ it 'prepends content to area as a block' do
+ get :prepend
+ assert_select '#some-area', "Prepended\n Some content"
+ end
+ end
+
+ context '#replace' do
+ it 'replaces area content with string' do
+ get :replace
+ assert_select 'title', 'Lolwut'
+ end
+
+ it 'replaces area content with block' do
+ get :replace
+ assert_select '#some-area', 'replaced'
+ end
+ end
+
+ context '#extends' do
+ it 'extends layouts' do
+ get :extended_one
+ assert_select 'p', 'extended: one'
+ assert_select 'title', 'extended: one'
+ assert_select 'h2', 'extended: one'
+ end
+
+ it 'can extend already extended layouts' do
+ get :extended_two
+ assert_select 'p', 'extended: two'
+ assert_select 'title', 'extended: one'
+ assert_select '#some-area', 'extended: two'
+ assert_select 'h2', 'extended: one'
+ end
+ end
+
+end
View
2  spec/internal/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
View
9 spec/internal/app/controllers/nestive_controller.rb
@@ -0,0 +1,9 @@
+class NestiveController < ApplicationController
+ def extended_one
+ render layout: 'extend_one'
+ end
+
+ def extended_two
+ render layout: 'extend_two'
+ end
+end
View
7 spec/internal/app/views/layouts/extend_one.html.erb
@@ -0,0 +1,7 @@
+<%= extends :nestive do %>
+ <% replace :title, 'extended: one' %>
+
+ <h2>extended: one</h2>
+
+ <%= yield %>
+<% end %>
View
6 spec/internal/app/views/layouts/extend_two.html.erb
@@ -0,0 +1,6 @@
+<%= extends :extend_one do %>
+ <%= replace :some_area do %>
+ extended: two
+ <% end %>
+ <%= yield %>
+<% end %>
View
15 spec/internal/app/views/layouts/nestive.html.erb
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title><%= area :title, 'Nestive' %></title>
+ </head>
+ <body>
+ <%= yield %>
+ <div id="some-area">
+ <%= area :some_area do -%>
+ Some content
+ <%- end -%>
+ </div>
+ <div id="empty-area"><%= area :empty_area %></div>
+ </body>
+</html>
View
6 spec/internal/app/views/nestive/append.html.erb
@@ -0,0 +1,6 @@
+<h1>here we'll be appending to areas</h1>
+
+<% append :title, ' is awesome' %>
+<% append :some_area do %>
+ Another content
+<% end %>
View
1  spec/internal/app/views/nestive/extended_one.html.erb
@@ -0,0 +1 @@
+<p>extended: one</p>
View
1  spec/internal/app/views/nestive/extended_two.html.erb
@@ -0,0 +1 @@
+<p>extended: two</p>
View
1  spec/internal/app/views/nestive/index.html.erb
@@ -0,0 +1 @@
+<h1>Hello World</h1>
View
6 spec/internal/app/views/nestive/prepend.html.erb
@@ -0,0 +1,6 @@
+<h1>here we'll be prepending stuff to areas</h1>
+
+<% prepend :title, 'Awesome ' %>
+<% prepend :some_area do %>
+Prepended
+<% end %>
View
7 spec/internal/app/views/nestive/replace.html.erb
@@ -0,0 +1,7 @@
+<h1>replacing areas</h1>
+
+<% replace :title, 'Lolwut' %>
+
+<%= replace :some_area do %>
+ replaced
+<% end %>
View
3  spec/internal/config/database.yml
@@ -0,0 +1,3 @@
+test:
+ adapter: sqlite3
+ database: db/combustion_test.sqlite
View
3  spec/internal/config/routes.rb
@@ -0,0 +1,3 @@
+Rails.application.routes.draw do
+ match ':controller/:action'
+end
View
2  spec/internal/db/schema.rb
@@ -0,0 +1,2 @@
+# ActiveRecord::Schema.define do
+# end
View
1  spec/internal/log/.gitignore
@@ -0,0 +1 @@
+*.log
View
0  spec/internal/public/favicon.ico
No changes.
View
9 spec/spec_helper.rb
@@ -0,0 +1,9 @@
+require 'bundler/setup'
+require 'rails'
+require 'combustion'
+
+require File.expand_path('../../lib/nestive', __FILE__)
+
+Combustion.initialize! :action_controller
+
+require 'rspec/rails'
View
8 test/nestive_test.rb
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class NestiveTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
View
3  test/test_helper.rb
@@ -1,3 +0,0 @@
-require 'rubygems'
-require 'test/unit'
-require 'active_support'
Please sign in to comment.
Something went wrong with that request. Please try again.