Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: readme
Fetching contributors…

Cannot retrieve contributors at this time

file 115 lines (109 sloc) 3.356 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
@disable-bundler
Feature: reusable install generator

Background:
Given a directory named "testengine"
When I cd to "testengine"
And I write to "testengine.gemspec" with:
"""
Gem::Specification.new do |s|
s.name = %q{testengine}
s.version = '1.0'
s.files = Dir['**/*']
s.require_path = 'lib'
s.add_dependency 'diesel'
end
"""
When I write to "db/migrate/001_create_examples.rb" with:
"""
class CreateExamples < ActiveRecord::Migration
def self.up
create_table :examples do |table|
table.string :title
end
end
end
"""
When I write to "app/models/example.rb" with:
"""
class Example < ActiveRecord::Base
end
"""
When I write to "app/controllers/examples_controller.rb" with:
"""
class ExamplesController < ActionController::Base
def index
Example.create!(:title => "Hello there")
@examples = Example.all
render
end
end
"""
When I write to "config/routes.rb" with:
"""
Rails.application.routes.draw do
match "/examples", :to => 'examples#index'
end
"""
When I write to "lib/testengine.rb" with:
"""
require 'rails'
module Testengine
class Engine < Rails::Engine
end
end
"""
When I write to "lib/generators/testengine/install/install_generator.rb" with:
"""
require 'diesel/generators/install_base'

module Testengine
module Generators
class InstallGenerator < Diesel::Generators::InstallBase
def copy_view
copy_file "index.html.erb", "app/views/examples/index.html.erb"
end
end
end
end
"""
When I write to "lib/generators/testengine/install/templates/index.html.erb" with:
"""
<% @examples.each do |example| -%>
<p><%= example.title %></p>
<% end -%>
"""
When I cd to ".."
And I successfully run "rails new testapp"
And I cd to "testapp"
And I append to "Gemfile" with:
"""
gem "cucumber-rails", "~> 0.3.2"
gem "capybara", "~> 0.4.0"
gem "rspec", "~> 1.3.0"

"""
When I add the "testengine" as a diesel engine
And I run "bundle install --local"
And I successfully run "rails generate cucumber:install --trace"
And I successfully run "rails generate testengine:install --trace"
And I successfully run "rake db:migrate db:schema:dump db:test:prepare --trace"

Scenario: test a generated app with a diesel engine
When I write to "features/examples.feature" with:
"""
Feature: view examples
Scenario: go to the examples page
When I go to the examples page
Then I should see "Hello there"
"""
When I run "bundle exec cucumber features/examples.feature"
Then it should pass with:
"""
1 scenario (1 passed)
"""

Scenario: view generator descriptions from an app with a diesel engine
When I successfully run "rails generate testengine:install -h"
Then the output should contain:
"""
Generate configuration, migration, and other essential files.
"""

Scenario: run the install generator twice
When I successfully run "rails generate testengine:install --trace"
Then the output should not contain "Another migration is already named"
Something went wrong with that request. Please try again.