Skip to content

Commit

Permalink
Use ammeter instead of aruba to test generators
Browse files Browse the repository at this point in the history
* Tests are much faster
* Failures are improved
* Don't generate a Rails app inside each test
* Don't boot up Rails several times
  • Loading branch information
jferris committed Apr 30, 2013
1 parent 223dae6 commit 366ad35
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 62 deletions.
1 change: 1 addition & 0 deletions effigy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'nokogiri', '>= 1.3'

s.add_development_dependency 'ammeter'
s.add_development_dependency 'aruba'
s.add_development_dependency 'cucumber'
s.add_development_dependency 'rails', '>= 3.2'
Expand Down
62 changes: 0 additions & 62 deletions features/rails_generators.feature

This file was deleted.

39 changes: 39 additions & 0 deletions spec/generators/effigy/view/view_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper'
require 'generators/effigy/view/view_generator'

describe Effigy::Generators::ViewGenerator do
destination File.join(PROJECT_ROOT, 'tmp')
before { prepare_destination }

it 'generates an action view and template with the given name' do
run_generator %w(users create)

view = file('app/views/users/create.html.effigy')
view.should exist
view.should contain('class UsersCreateView < Effigy::Rails::View')
view.should contain('app/templates/users/create.html')

template = file('app/templates/users/create.html')
template.should exist
template.should contain('UsersCreateView')
template.should contain('Edit me at app/templates/users/create.html')
template.
should contain('Edit my view at app/views/users/create.html.effigy')
end

it 'generates a layout view and template' do
run_generator %w(layouts narrow)

view = file('app/views/layouts/narrow.html.effigy')
view.should exist
view.should contain('class NarrowLayout < Effigy::Rails::View')
view.should contain('app/templates/layouts/narrow.html')

template = file('app/templates/layouts/narrow.html')
template.should exist
template.should contain('NarrowLayout')
template.should contain('Edit me at app/templates/layouts/narrow.html')
template.
should contain('Edit my view at app/views/layouts/narrow.html.effigy')
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'rspec'
require 'rails/all'
require 'ammeter/init'

PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
RAILS_ROOT = File.join(PROJECT_ROOT, 'tmp', 'rails_root')
Expand Down

0 comments on commit 366ad35

Please sign in to comment.