Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 171 lines (164 sloc) 5.285 kB
2e7af48 @jferris Step definitions for testing integration
jferris authored
1 Feature: integration testing
b32d376 @mike-burns Tests are passing again in master.
mike-burns authored
2 @slow
2e7af48 @jferris Step definitions for testing integration
jferris authored
3 Scenario: test integration of a diesel engine with a generated application
4 Given a directory named "testengine"
5 When I cd to "testengine"
6 And I write to "testengine.gemspec" with:
7 """
8 Gem::Specification.new do |s|
9 s.name = %q{testengine}
10 s.version = '1.0'
11 s.files = Dir['**/*']
12 s.require_path = 'lib'
13 s.add_dependency 'diesel'
14 end
15 """
16 When I write to "Gemfile" with:
17 """
9048d9a @sikachu Add `rails` gem as dependency to stop it from complain
sikachu authored
18 gem "rails"
2e7af48 @jferris Step definitions for testing integration
jferris authored
19 gem "cucumber"
20 gem "aruba"
7247235 @sikachu Remove specific Gem versioning, and always use latest version that Bu…
sikachu authored
21 gem "rspec"
2e7af48 @jferris Step definitions for testing integration
jferris authored
22 """
23 When I add this library as a dependency
24 And I write to "db/migrate/create_examples.rb" with:
25 """
26 class CreateExamples < ActiveRecord::Migration
27 def self.up
28 create_table :examples do |table|
29 table.string :title
30 end
31 end
32 end
33 """
34 When I write to "app/models/example.rb" with:
35 """
36 class Example < ActiveRecord::Base
911ce49 @mjankowski rails 3.2.3 defaults to whitelist attributes and we do mass assignmen…
mjankowski authored
37 attr_accessible :title
2e7af48 @jferris Step definitions for testing integration
jferris authored
38 end
39 """
40 When I write to "app/controllers/examples_controller.rb" with:
41 """
42 class ExamplesController < ActionController::Base
43 def index
44 Example.create!(:title => "Hello there")
45 @examples = Example.all
46 render
47 end
48 end
49 """
50 When I write to "app/views/examples/index.html.erb" with:
51 """
52 <% @examples.each do |example| -%>
53 <p><%= example.title %></p>
54 <% end -%>
55 """
56 When I write to "config/routes.rb" with:
57 """
58 Rails.application.routes.draw do
59 match "/examples", :to => 'examples#index'
60 end
61 """
62 When I write to "lib/testengine.rb" with:
63 """
64 require 'rails'
65 module Testengine
66 class Engine < Rails::Engine
67 end
68 end
69 """
70 When I write to "features/engine/examples.feature" with:
71 """
72 Feature: view examples
73 Scenario: go to the examples page
74 When I go to the examples page
75 Then I should receive a warm greeting
76 """
77 When I write to "features/step_definitions/engine/example_steps.rb" with:
78 """
79 Then %{I should receive a warm greeting} do
821e1cd @gabebw Update dependencies.
gabebw authored
80 page.should have_content "Hello there"
81 end
82
83 When "I go to the examples page" do
84 visit examples_path
2e7af48 @jferris Step definitions for testing integration
jferris authored
85 end
86 """
87 When I write to "lib/generators/testengine/install/install_generator.rb" with:
88 """
89 require 'diesel/generators/install_base'
90
91 module Testengine
92 module Generators
93 class InstallGenerator < Diesel::Generators::InstallBase
94 end
95 end
96 end
97 """
98 When I write to "lib/generators/testengine/features/features_generator.rb" with:
99 """
100 require 'diesel/generators/features_base'
101
102 module Testengine
103 module Generators
104 class FeaturesGenerator < Diesel::Generators::FeaturesBase
105 end
106 end
107 end
108 """
109 When I write to "features/integration.feature" with:
110 """
3213ec9 @sikachu Apparently we need Bundler for these specs, but need to clean up thei…
sikachu authored
111 @puts @announce
2e7af48 @jferris Step definitions for testing integration
jferris authored
112 Feature: integrate with application
113 Scenario: generate a Rails app, run the generates, and run the tests
2dc7427 @sikachu No more turn in the test application
sikachu authored
114 When I successfully run `bundle exec rails new testapp --skip-test-unit --skip-bundle`
2e7af48 @jferris Step definitions for testing integration
jferris authored
115 And I cd to "testapp"
2dc7427 @sikachu No more turn in the test application
sikachu authored
116 And I comment out gem "turn" from my Gemfile
2e7af48 @jferris Step definitions for testing integration
jferris authored
117 And I add the "cucumber-rails" gem
118 And I add the "capybara" gem
119 And I add the "rspec-rails" gem
0ee8575 @sikachu Hardcoded database_cleaner because new cucumber-rails requires it.
sikachu authored
120 And I add the "database_cleaner" gem
2e7af48 @jferris Step definitions for testing integration
jferris authored
121 And I add the "testengine" gem from this project
122 And I add the "diesel" gem from the diesel project
3213ec9 @sikachu Apparently we need Bundler for these specs, but need to clean up thei…
sikachu authored
123 And I reset the Bundler environment variable
124 And I run `bundle install --local`
b32d376 @mike-burns Tests are passing again in master.
mike-burns authored
125 And I successfully run `bundle exec rails generate cucumber:install`
126 And I successfully run `bundle exec rails generate testengine:install`
127 And I successfully run `bundle exec rails generate testengine:features`
128 And I successfully run `bundle exec rake db:migrate --trace`
6e8ce55 @gabebw WIP: trying to get away from the minitest 1.6.0 error on 1.9.2
gabebw authored
129 And I successfully run `bundle exec rake cucumber --trace`
2e7af48 @jferris Step definitions for testing integration
jferris authored
130 Then the output should contain "1 scenario (1 passed)"
131 And the output should not contain "Could not find generator"
132 """
133 When I write to "features/support/env.rb" with:
134 """
135 require "diesel/testing/integration"
b32d376 @mike-burns Tests are passing again in master.
mike-burns authored
136 Before do
137 @aruba_timeout_seconds = 120
138 end
2e7af48 @jferris Step definitions for testing integration
jferris authored
139 """
140 When I write to "features/step_definitions/dependency_steps.rb" with:
141 """
142 # Make sure we use the local diesel
143 When /^I add the "([^"]*)" gem from the diesel project$/ do |gem_name|
144 append_to_file('Gemfile', %{\ngem "#{gem_name}", :path => "../../../../../.."\n})
145 end
3213ec9 @sikachu Apparently we need Bundler for these specs, but need to clean up thei…
sikachu authored
146
147 When /^I reset the Bundler environment variable$/ do
148 %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).each do |key|
149 ENV[key] = nil
150 end
151 end
2dc7427 @sikachu No more turn in the test application
sikachu authored
152
153 When /^I comment out gem "([^"]*)" from my Gemfile$/ do |gem_name|
6481f8f @sikachu File.read must perform in the test app directory
sikachu authored
154 in_current_dir do
155 content = File.read('Gemfile')
156 File.open('Gemfile', 'w') do |f|
157 f.write content.sub(/gem ['"]#{gem_name}/, '#\1')
158 end
2dc7427 @sikachu No more turn in the test application
sikachu authored
159 end
160 end
2e7af48 @jferris Step definitions for testing integration
jferris authored
161 """
3213ec9 @sikachu Apparently we need Bundler for these specs, but need to clean up thei…
sikachu authored
162 When I reset Bundler environment variable
163 When I run `bundle install --local`
b32d376 @mike-burns Tests are passing again in master.
mike-burns authored
164 And I successfully run `bundle exec cucumber features/integration.feature`
2e7af48 @jferris Step definitions for testing integration
jferris authored
165 Then it should pass with:
166 """
167 1 scenario (1 passed)
168 """
169 Then the output should not contain "undefined"
170
Something went wrong with that request. Please try again.