hashrocket-terraformation 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE CHANGED
@@ -1 +1,20 @@
1
- All rights reserved (for now).
1
+ Copyright (c) 2009 Hashrocket
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
 
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "terraformation"
7
- s.version = '0.0.0'
7
+ s.version = "0.1.0"
8
8
  s.summary = "Terraform your app with style"
9
9
  s.email = "info@hashrocket.com"
10
10
  s.homepage = "http://github.com/hashrocket/terraformation"
data/bin/terrarails CHANGED
@@ -71,9 +71,9 @@ end
71
71
  gsub_file 'app/helpers/application_helper.rb', /\A# Methods added to this .*\n/, ''
72
72
  gsub_file 'config/environment.rb', /(?:^\s*# config\.gem .*\n)+/, <<-EOS
73
73
  config.gem "haml", :version => ">= 2.0.7"
74
- config.gem "rspec-rails", :version => ">= 1.1.12", :lib => false
75
- config.gem "cucumber", :version => ">= 0.1.16", :lib => false
76
- config.gem "webrat", :version => ">= 0.4.1", :lib => false
74
+ config.gem "rspec-rails", :version => ">= 1.2.1", :lib => false
75
+ config.gem "cucumber", :version => ">= 0.2.0", :lib => false
76
+ config.gem "webrat", :version => ">= 0.4.3", :lib => false
77
77
  EOS
78
78
  gsub_file 'config/routes.rb', /^(ActionController::Routing::Routes\.draw do \|map\|\n)(?:^\s*\n|^\s*#.*\n)*/, '\\1'
79
79
 
@@ -2,19 +2,18 @@ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_dep
2
2
 
3
3
  describe <%= class_name %>Controller do
4
4
  <% unless actions.empty? -%>
5
- <% for action in actions -%>
6
5
 
7
- describe "GET '<%= action %>'" do
8
- def do_request
6
+ <% for action in actions -%>
7
+ describe "on GET to <%= action %>" do
8
+ subject do
9
9
  get :<%= action %>
10
10
  end
11
- protected :do_request
12
11
 
13
12
  it "should be successful" do
14
- do_request
15
- response.should be_success
13
+ should be_success
16
14
  end
17
15
  end
16
+
18
17
  <% end -%>
19
18
  <% end -%>
20
19
  end
@@ -1,15 +1,16 @@
1
- require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_name.scan('::').size %>/../../spec_helper')
2
2
 
3
3
  describe "/<%= class_name.underscore %>/<%= name %>.<%= format %>" do
4
- before do
4
+ subject do
5
5
  <% if format == "html" -%>
6
6
  render '<%= class_name.underscore %>/<%= name %>.<%= format %>'
7
7
  <% else -%>
8
8
  render '<%= class_name.underscore %>/<%= name %>.<%= format %>.<%= engine %>'
9
9
  <% end -%>
10
+ response
10
11
  end
11
12
 
12
13
  it "should render" do
13
- response.body.should be
14
+ should be
14
15
  end
15
16
  end
@@ -5,6 +5,10 @@ class TerraformationGenerator < Rails::Generator::Base
5
5
  Config::CONFIG['ruby_install_name'])
6
6
  include Terraforming
7
7
 
8
+ def framework # for cucumber templates
9
+ :rspec
10
+ end
11
+
8
12
  def option?(key)
9
13
  options.fetch(key, options[:full])
10
14
  end
@@ -55,9 +59,9 @@ class TerraformationGenerator < Rails::Generator::Base
55
59
  m.directory 'features/support'
56
60
  m.directory 'features/step_definitions'
57
61
 
58
- m.file 'cucumber:env.rb', 'features/support/env.rb'
62
+ m.template 'cucumber:env.rb', 'features/support/env.rb'
59
63
  m.file 'paths.rb', 'features/support/paths.rb'
60
- m.file 'cucumber:webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
64
+ m.template 'cucumber:webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
61
65
  end
62
66
 
63
67
  if option?(:gitignore)
@@ -27,12 +27,12 @@ module Terraforming
27
27
  haml = defined?(Haml) ? "haml" : "erb"
28
28
  args.delete_if do |arg|
29
29
  @views << case arg
30
- when /^\w+\.\w+\.\w+$/ then arg
31
- when /^\w+$/ then "#{arg}.html.#{haml}"
32
- when /^\w+\.(?:html|fbml)$/ then "#{arg}.#{haml}"
33
- when /^\w+\.(?:xml|rss|atom)$/ then "#{arg}.builder"
34
- when /^\w+\.js$/ then "#{arg}.rjs"
35
- when /^\w+\.\w+$/ then "#{arg}.erb"
30
+ when /^[\w\/]+\.\w+\.\w+$/ then arg
31
+ when /^[\w\/]+$/ then "#{arg}.html.#{haml}"
32
+ when /^[\w\/]+\.(?:html|fbml)$/ then "#{arg}.#{haml}"
33
+ when /^[\w\/]+\.(?:xml|rss|atom)$/ then "#{arg}.builder"
34
+ when /^[\w\/]+\.js$/ then "#{arg}.rjs"
35
+ when /^[\w\/]+\.\w+$/ then "#{arg}.erb"
36
36
  else next
37
37
  end
38
38
  end
@@ -5,7 +5,7 @@ Description:
5
5
  Example:
6
6
  ./script/generate terramodel Spaceship fuel_capacity:decimal
7
7
  ...
8
- create app/models/space_colony.rb
8
+ create app/models/spaceship.rb
9
9
  create spec/models/spaceship_spec.rb
10
10
  create spec/exemplars/spaceship_exemplar.rb
11
11
  create db/migrate/20090121225002_create_spaceships.rb
@@ -1,17 +1,17 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
2
2
 
3
3
  describe <%= class_name %> do
4
- before do
4
+ subject do
5
5
  <% if factory? -%>
6
- @<%= singular_name %> = Factory.build(<%= full_name.to_sym.inspect %>)
6
+ Factory.build(<%= full_name.to_sym.inspect %>)
7
7
  <% elsif exemplar? -%>
8
- @<%= singular_name %> = <%= class_name %>.spawn
8
+ <%= class_name %>.spawn
9
9
  <% else -%>
10
- @<%= singular_name %> = <%= class_name %>.new
10
+ <%= class_name %>.new
11
11
  <% end -%>
12
12
  end
13
13
 
14
14
  it "should be valid" do
15
- @<%= singular_name %>.should be_valid
15
+ should be_valid
16
16
  end
17
17
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
2
 
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
4
  describe "/<%= plural_name %>/edit.html" do
5
5
  before do
6
6
  assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
@@ -11,10 +11,13 @@ describe "/<%= plural_name %>/edit.html" do
11
11
  )
12
12
  end
13
13
 
14
- it "should render edit form" do
14
+ subject do
15
15
  render "<%= plural_name %>/edit.html"
16
+ response
17
+ end
16
18
 
17
- response.should have_tag("form[action=?][method=post]", <%= file_name %>_path(@<%= file_name %>)) do
19
+ it "should render edit form" do
20
+ should have_tag("form[action=?][method=post]", <%= file_name %>_path(@<%= file_name %>)) do
18
21
  <% for attribute in output_attributes -%>
19
22
  with_tag('#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
20
23
  <% end -%>
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
2
 
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
4
  describe "/<%= plural_name %>/index.html" do
5
5
  before do
6
6
  assigns[:<%= plural_name %>] = [
@@ -16,10 +16,14 @@ describe "/<%= plural_name %>/index.html" do
16
16
  ]
17
17
  end
18
18
 
19
- it "should render list of <%= plural_name %>" do
19
+ subject do
20
20
  render "<%= plural_name %>/index.html"
21
+ response
22
+ end
23
+
24
+ it "should render list of <%= plural_name %>" do
21
25
  <% for attribute in output_attributes -%>
22
- response.should have_tag("tr>td", <%= attribute.default.inspect %>.to_s, 2)
26
+ should have_tag("tr>td", <%= attribute.default.inspect %>.to_s, 2)
23
27
  <% end -%>
24
28
  end
25
29
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
2
 
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
4
  describe "/<%= plural_name %>/new.html" do
5
5
  before do
6
6
  assigns[:<%= file_name %>] = stub_model(<%= class_name %>,
@@ -11,10 +11,13 @@ describe "/<%= plural_name %>/new.html" do
11
11
  )
12
12
  end
13
13
 
14
- it "should render new form" do
14
+ subject do
15
15
  render "<%= plural_name %>/new.html"
16
+ response
17
+ end
16
18
 
17
- response.should have_tag("form[action=?][method=post]", <%= plural_name %>_path) do
19
+ it "should render new form" do
20
+ should have_tag("form[action=?][method=post]", <%= plural_name %>_path) do
18
21
  <% for attribute in output_attributes -%>
19
22
  with_tag("#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
20
23
  <% end -%>
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
2
 
3
- <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
4
  describe "/<%= plural_name %>/show.html" do
5
5
  before do
6
6
  assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %>
@@ -12,10 +12,14 @@ describe "/<%= plural_name %>/show.html" do
12
12
  <% end -%>
13
13
  end
14
14
 
15
- it "should render attributes in <p>" do
15
+ subject do
16
16
  render "<%= plural_name %>/show.html"
17
+ response
18
+ end
19
+
20
+ it "should render attributes in <p>" do
17
21
  <% for attribute in output_attributes -%>
18
- response.should have_text(/<%= Regexp.escape(attribute.default.inspect).gsub(/^"|"$/, '')%>/)
22
+ should have_text(/<%= Regexp.escape(attribute.default.inspect).gsub(/^"|"$/, '')%>/)
19
23
  <% end -%>
20
24
  end
21
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashrocket-terraformation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - a team of ravenous rocketeers