Skip to content

Commit

Permalink
simple specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Pravosud committed Feb 26, 2012
1 parent c597616 commit 403cda4
Show file tree
Hide file tree
Showing 24 changed files with 258 additions and 78 deletions.
144 changes: 88 additions & 56 deletions 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
14 changes: 4 additions & 10 deletions 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|
Expand Down
7 changes: 7 additions & 0 deletions config.ru
@@ -0,0 +1,7 @@
require 'rubygems'
require 'bundler'

Bundler.require :default, :development

Combustion.initialize!
run Combustion::Application
5 changes: 4 additions & 1 deletion nestive.gemspec
Expand Up @@ -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
76 changes: 76 additions & 0 deletions 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
2 changes: 2 additions & 0 deletions spec/internal/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
9 changes: 9 additions & 0 deletions 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
7 changes: 7 additions & 0 deletions 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 %>
6 changes: 6 additions & 0 deletions 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 %>
15 changes: 15 additions & 0 deletions 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>
6 changes: 6 additions & 0 deletions 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 %>
1 change: 1 addition & 0 deletions spec/internal/app/views/nestive/extended_one.html.erb
@@ -0,0 +1 @@
<p>extended: one</p>
1 change: 1 addition & 0 deletions spec/internal/app/views/nestive/extended_two.html.erb
@@ -0,0 +1 @@
<p>extended: two</p>
1 change: 1 addition & 0 deletions spec/internal/app/views/nestive/index.html.erb
@@ -0,0 +1 @@
<h1>Hello World</h1>
6 changes: 6 additions & 0 deletions 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 %>
7 changes: 7 additions & 0 deletions 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 %>
3 changes: 3 additions & 0 deletions spec/internal/config/database.yml
@@ -0,0 +1,3 @@
test:
adapter: sqlite3
database: db/combustion_test.sqlite
3 changes: 3 additions & 0 deletions spec/internal/config/routes.rb
@@ -0,0 +1,3 @@
Rails.application.routes.draw do
match ':controller/:action'
end
2 changes: 2 additions & 0 deletions spec/internal/db/schema.rb
@@ -0,0 +1,2 @@
# ActiveRecord::Schema.define do
# end
1 change: 1 addition & 0 deletions spec/internal/log/.gitignore
@@ -0,0 +1 @@
*.log
Empty file.
9 changes: 9 additions & 0 deletions 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'

0 comments on commit 403cda4

Please sign in to comment.