Permalink
Browse files

Converted the Rails 2 generator specs into cucumber scenarios

  • Loading branch information...
jferris committed Aug 20, 2010
1 parent 9963445 commit 149ebb63acd7763ebd2ca26d60d18308558dcaa9
@@ -0,0 +1,67 @@
Feature: Generate views in a Rails 2.3 application
Background:
When I generate a new rails 2 application
And I configure the rails 2 preinitializer to use bundler
And I save the following as "Gemfile"
"""
source "http://rubygems.org"
gem 'rails', '2.3.8'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'effigy', :path => '../../', :require => 'effigy/rails'
"""
When I run "bundle lock"
Scenario: generate a controller view and template
When I run "./script/generate effigy_view users create"
Then the following should be saved as "app/views/users/create.html.effigy"
"""
class UsersCreateView < Effigy::Rails::View
private
def transform
# Apply transformations to the template file here:
# text('h1', 'Hello')
# Assigns from the action are available:
# text('h1', @post.title)
# Transformations will be applied to to the template file:
# app/templates/users/create.html
# See the documentation for more information.
end
end
"""
Then the following should be saved as "app/templates/users/create.html"
"""
<h1>UsersCreateView</h1>
<p>Edit me at app/templates/users/create.html</p>
<p>Edit my view at app/views/users/create.html.effigy</p>
"""
Scenario: generate a layout view and template
When I run "./script/generate effigy_view layouts narrow"
Then the following should be saved as "app/views/layouts/narrow.html.effigy"
"""
class NarrowLayout < Effigy::Rails::View
private
def transform
# Apply transformations to the template file here:
# text('h1', 'Hello')
# Assigns from the action are available:
# text('h1', @post.title)
# Transformations will be applied to to the template file:
# app/templates/layouts/narrow.html
# See the documentation for more information.
html('body', content_for(:layout))
end
end
"""
Then the following should be saved as "app/templates/layouts/narrow.html"
"""
<html>
<body>
<h1>NarrowLayout</h1>
<p>Edit me at app/templates/layouts/narrow.html</p>
<p>Edit my view at app/views/layouts/narrow.html.effigy</p>
</body>
</html>
"""
File renamed without changes.
@@ -41,3 +41,8 @@
@terminal.run("ruby script/request #{path}")
end
Then /^the following should be saved as "([^"]*)"$/ do |path, string|
contents = IO.read(File.join(RAILS_ROOT, path))
contents.strip.should == string.strip
end
@@ -3,6 +3,8 @@
File.join(RAILS_ROOT, 'config', 'preinitializer.rb'))
FileUtils.cp(File.join(TEMPLATE_ROOT, 'boot.rb.template'),
File.join(RAILS_ROOT, 'config', 'boot.rb'))
FileUtils.ln_s(File.join(PROJECT_ROOT, 'generators'),
File.join(RAILS_ROOT, 'lib', 'generators'))
end
When /^I generate a new rails 2 application$/ do

This file was deleted.

Oops, something went wrong.

0 comments on commit 149ebb6

Please sign in to comment.