steak 1.1.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/{MIT-LICENSE → LICENSE} +1 -1
  2. data/README.md +110 -0
  3. data/lib/generators/steak/install_generator.rb +12 -0
  4. data/lib/generators/steak/spec_generator.rb +11 -0
  5. data/lib/generators/steak/templates/acceptance_spec.rb +13 -0
  6. data/lib/generators/steak/templates/spec/acceptance/acceptance_helper.rb +4 -0
  7. data/lib/generators/steak/templates/spec/acceptance/support/helpers.rb +6 -0
  8. data/lib/{rspec-2/rails/generators/templates → generators/steak/templates/spec/acceptance/support}/paths.rb +1 -1
  9. data/lib/steak.rb +4 -10
  10. data/lib/steak/acceptance_example_group.rb +12 -0
  11. data/lib/steak/railtie.rb +7 -0
  12. data/lib/steak/version.rb +3 -0
  13. data/lib/tasks/steak_tasks.rake +14 -0
  14. data/spec/acceptance/creating_specs_spec.rb +75 -0
  15. data/spec/acceptance/getting_started_spec.rb +33 -0
  16. data/spec/acceptance/rake_support_spec.rb +40 -0
  17. data/spec/fixtures/rails_project/.gitignore +5 -0
  18. data/spec/fixtures/rails_project/Gemfile +55 -0
  19. data/spec/fixtures/rails_project/README +261 -0
  20. data/spec/fixtures/rails_project/Rakefile +7 -0
  21. data/spec/fixtures/rails_project/app/assets/images/rails.png +0 -0
  22. data/spec/fixtures/rails_project/app/assets/javascripts/application.js +9 -0
  23. data/spec/fixtures/rails_project/app/assets/stylesheets/application.css +7 -0
  24. data/spec/fixtures/rails_project/app/controllers/application_controller.rb +3 -0
  25. data/spec/fixtures/rails_project/app/helpers/application_helper.rb +2 -0
  26. data/spec/fixtures/rails_project/app/mailers/.gitkeep +0 -0
  27. data/spec/fixtures/rails_project/app/models/.gitkeep +0 -0
  28. data/spec/fixtures/rails_project/app/views/layouts/application.html.erb +14 -0
  29. data/spec/fixtures/rails_project/config.ru +4 -0
  30. data/spec/fixtures/rails_project/config/application.rb +49 -0
  31. data/spec/fixtures/rails_project/config/boot.rb +6 -0
  32. data/spec/fixtures/rails_project/config/database.yml +48 -0
  33. data/spec/fixtures/rails_project/config/environment.rb +5 -0
  34. data/spec/fixtures/rails_project/config/environments/development.rb +24 -0
  35. data/spec/fixtures/rails_project/config/environments/production.rb +52 -0
  36. data/spec/fixtures/rails_project/config/environments/test.rb +39 -0
  37. data/spec/fixtures/rails_project/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/fixtures/rails_project/config/initializers/inflections.rb +10 -0
  39. data/spec/fixtures/rails_project/config/initializers/mime_types.rb +5 -0
  40. data/spec/fixtures/rails_project/config/initializers/secret_token.rb +7 -0
  41. data/spec/fixtures/rails_project/config/initializers/session_store.rb +8 -0
  42. data/spec/fixtures/rails_project/config/initializers/wrap_parameters.rb +12 -0
  43. data/spec/fixtures/rails_project/config/locales/en.yml +5 -0
  44. data/spec/fixtures/rails_project/config/routes.rb +58 -0
  45. data/spec/fixtures/rails_project/db/seeds.rb +7 -0
  46. data/spec/fixtures/rails_project/doc/README_FOR_APP +2 -0
  47. data/spec/fixtures/rails_project/lib/tasks/.gitkeep +0 -0
  48. data/spec/fixtures/rails_project/log/.gitkeep +0 -0
  49. data/spec/fixtures/rails_project/public/404.html +26 -0
  50. data/spec/fixtures/rails_project/public/422.html +26 -0
  51. data/spec/fixtures/rails_project/public/500.html +26 -0
  52. data/spec/fixtures/rails_project/public/favicon.ico +0 -0
  53. data/spec/fixtures/rails_project/public/index.html +241 -0
  54. data/spec/fixtures/rails_project/public/robots.txt +5 -0
  55. data/spec/fixtures/rails_project/script/rails +6 -0
  56. data/spec/fixtures/rails_project/test/fixtures/.gitkeep +0 -0
  57. data/spec/fixtures/rails_project/test/functional/.gitkeep +0 -0
  58. data/spec/fixtures/rails_project/test/integration/.gitkeep +0 -0
  59. data/spec/fixtures/rails_project/test/performance/browsing_test.rb +12 -0
  60. data/spec/fixtures/rails_project/test/test_helper.rb +13 -0
  61. data/spec/fixtures/rails_project/test/unit/.gitkeep +0 -0
  62. data/spec/fixtures/rails_project/vendor/assets/stylesheets/.gitkeep +0 -0
  63. data/spec/fixtures/rails_project/vendor/plugins/.gitkeep +0 -0
  64. data/spec/fixtures/rails_project_with_steak/.gitignore +5 -0
  65. data/spec/fixtures/rails_project_with_steak/.rspec +1 -0
  66. data/spec/fixtures/rails_project_with_steak/Gemfile +58 -0
  67. data/spec/fixtures/rails_project_with_steak/README +261 -0
  68. data/spec/fixtures/rails_project_with_steak/Rakefile +7 -0
  69. data/spec/fixtures/rails_project_with_steak/app/assets/images/rails.png +0 -0
  70. data/spec/fixtures/rails_project_with_steak/app/assets/javascripts/application.js +9 -0
  71. data/spec/fixtures/rails_project_with_steak/app/assets/stylesheets/application.css +7 -0
  72. data/spec/fixtures/rails_project_with_steak/app/controllers/application_controller.rb +3 -0
  73. data/spec/fixtures/rails_project_with_steak/app/helpers/application_helper.rb +2 -0
  74. data/spec/fixtures/rails_project_with_steak/app/mailers/.gitkeep +0 -0
  75. data/spec/fixtures/rails_project_with_steak/app/models/.gitkeep +0 -0
  76. data/spec/fixtures/rails_project_with_steak/app/views/layouts/application.html.erb +14 -0
  77. data/spec/fixtures/rails_project_with_steak/config.ru +4 -0
  78. data/spec/fixtures/rails_project_with_steak/config/application.rb +49 -0
  79. data/spec/fixtures/rails_project_with_steak/config/boot.rb +6 -0
  80. data/spec/fixtures/rails_project_with_steak/config/database.yml +48 -0
  81. data/spec/fixtures/rails_project_with_steak/config/environment.rb +5 -0
  82. data/spec/fixtures/rails_project_with_steak/config/environments/development.rb +24 -0
  83. data/spec/fixtures/rails_project_with_steak/config/environments/production.rb +52 -0
  84. data/spec/fixtures/rails_project_with_steak/config/environments/test.rb +39 -0
  85. data/spec/fixtures/rails_project_with_steak/config/initializers/backtrace_silencers.rb +7 -0
  86. data/spec/fixtures/rails_project_with_steak/config/initializers/inflections.rb +10 -0
  87. data/spec/fixtures/rails_project_with_steak/config/initializers/mime_types.rb +5 -0
  88. data/spec/fixtures/rails_project_with_steak/config/initializers/secret_token.rb +7 -0
  89. data/spec/fixtures/rails_project_with_steak/config/initializers/session_store.rb +8 -0
  90. data/spec/fixtures/rails_project_with_steak/config/initializers/wrap_parameters.rb +12 -0
  91. data/spec/fixtures/rails_project_with_steak/config/locales/en.yml +5 -0
  92. data/spec/fixtures/rails_project_with_steak/config/routes.rb +58 -0
  93. data/spec/fixtures/rails_project_with_steak/db/schema.rb +15 -0
  94. data/spec/fixtures/rails_project_with_steak/db/seeds.rb +7 -0
  95. data/spec/fixtures/rails_project_with_steak/doc/README_FOR_APP +2 -0
  96. data/spec/fixtures/rails_project_with_steak/lib/tasks/.gitkeep +0 -0
  97. data/spec/fixtures/rails_project_with_steak/log/.gitkeep +0 -0
  98. data/spec/fixtures/rails_project_with_steak/public/404.html +26 -0
  99. data/spec/fixtures/rails_project_with_steak/public/422.html +26 -0
  100. data/spec/fixtures/rails_project_with_steak/public/500.html +26 -0
  101. data/spec/fixtures/rails_project_with_steak/public/favicon.ico +0 -0
  102. data/spec/fixtures/rails_project_with_steak/public/index.html +241 -0
  103. data/spec/fixtures/rails_project_with_steak/public/robots.txt +5 -0
  104. data/spec/fixtures/rails_project_with_steak/script/rails +6 -0
  105. data/spec/fixtures/rails_project_with_steak/spec/acceptance/acceptance_helper.rb +4 -0
  106. data/spec/fixtures/rails_project_with_steak/spec/acceptance/support/.gitignore +0 -0
  107. data/spec/fixtures/rails_project_with_steak/spec/acceptance/support/helpers.rb +6 -0
  108. data/{generators/steak/templates → spec/fixtures/rails_project_with_steak/spec/acceptance/support}/paths.rb +1 -1
  109. data/spec/fixtures/rails_project_with_steak/spec/spec_helper.rb +27 -0
  110. data/spec/fixtures/rails_project_with_steak/test/fixtures/.gitkeep +0 -0
  111. data/spec/fixtures/rails_project_with_steak/test/functional/.gitkeep +0 -0
  112. data/spec/fixtures/rails_project_with_steak/test/integration/.gitkeep +0 -0
  113. data/spec/fixtures/rails_project_with_steak/test/performance/browsing_test.rb +12 -0
  114. data/spec/fixtures/rails_project_with_steak/test/test_helper.rb +13 -0
  115. data/spec/fixtures/rails_project_with_steak/test/unit/.gitkeep +0 -0
  116. data/spec/fixtures/rails_project_with_steak/vendor/assets/stylesheets/.gitkeep +0 -0
  117. data/spec/fixtures/rails_project_with_steak/vendor/plugins/.gitkeep +0 -0
  118. data/spec/support/helpers.rb +73 -0
  119. data/spec/support/refresh_fixtures_task.rb +30 -0
  120. metadata +255 -117
  121. data/README.rdoc +0 -193
  122. data/Rakefile +0 -23
  123. data/generators/acceptance_spec/USAGE +0 -1
  124. data/generators/acceptance_spec/acceptance_spec_generator.rb +0 -9
  125. data/generators/acceptance_spec/templates/acceptance_spec.rb +0 -12
  126. data/generators/steak/USAGE +0 -8
  127. data/generators/steak/steak_generator.rb +0 -26
  128. data/generators/steak/templates/acceptance_helper.rb +0 -18
  129. data/generators/steak/templates/helpers.rb +0 -5
  130. data/generators/steak/templates/steak.rake +0 -44
  131. data/lib/rspec-1/steak.rb +0 -17
  132. data/lib/rspec-2/rails/generators/install_generator.rb +0 -31
  133. data/lib/rspec-2/rails/generators/spec_generator.rb +0 -36
  134. data/lib/rspec-2/rails/generators/templates/acceptance_helper.rb +0 -5
  135. data/lib/rspec-2/rails/generators/templates/acceptance_spec.rb +0 -12
  136. data/lib/rspec-2/rails/generators/templates/helpers.rb +0 -5
  137. data/lib/rspec-2/rails/railtie.rb +0 -14
  138. data/lib/rspec-2/rails/tasks/steak.rake +0 -14
  139. data/lib/rspec-2/steak.rb +0 -31
  140. data/spec/acceptance/rspec-1/acceptance_helper.rb +0 -98
  141. data/spec/acceptance/rspec-1/acceptance_spec_generator_spec.rb +0 -44
  142. data/spec/acceptance/rspec-1/basic_spec.rb +0 -76
  143. data/spec/acceptance/rspec-1/rails_spec.rb +0 -39
  144. data/spec/acceptance/rspec-1/steak_generator_spec.rb +0 -96
  145. data/spec/acceptance/rspec-2/acceptance_helper.rb +0 -81
  146. data/spec/acceptance/rspec-2/basic_spec.rb +0 -121
  147. data/spec/acceptance/rspec-2/rails_spec.rb +0 -88
  148. data/spec/acceptance/rspec-2/steak_install_generator_spec.rb +0 -62
  149. data/spec/acceptance/rspec-2/steak_spec_generator_spec.rb +0 -77
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/<%= @relative_path %>acceptance_helper')
2
-
3
- feature "<%= @feature_name %>", %q{
4
- In order to ...
5
- As a ...
6
- I want to ...
7
- } do
8
-
9
- scenario "Scenario name" do
10
- true.should == true
11
- end
12
- end
@@ -1,5 +0,0 @@
1
- module HelperMethods
2
- # Put helper methods you need to be available in all tests here.
3
- end
4
-
5
- RSpec.configuration.include HelperMethods, :type => :acceptance
@@ -1,14 +0,0 @@
1
- require 'steak'
2
- require 'rails'
3
-
4
- module Steak
5
- class Railtie < ::Rails::Railtie
6
- rake_tasks do
7
- load File.dirname(__FILE__) + "/tasks/steak.rake"
8
- end
9
- generators do
10
- require File.dirname(__FILE__) + "/generators/install_generator"
11
- require File.dirname(__FILE__) + "/generators/spec_generator"
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- namespace :spec do
4
- desc "Run the code examples in spec/acceptance"
5
- RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t|
6
- t.pattern = "spec/acceptance/**/*_spec.rb"
7
- end
8
-
9
- task :statsetup do
10
- require 'rails/code_statistics'
11
- ::STATS_DIRECTORIES << %w(Acceptance\ specs spec/acceptance) if File.exist?('spec/acceptance')
12
- ::CodeStatistics::TEST_TYPES << "Acceptance specs" if File.exist?('spec/acceptance')
13
- end
14
- end
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/rails/railtie' if defined?(Rails)
2
-
3
- module Steak
4
- module AcceptanceExampleGroup
5
- def self.included(base)
6
- base.instance_eval do
7
- alias scenario example
8
- alias background before
9
-
10
- if defined?(RSpec::Rails)
11
- include RSpec::Rails::RequestExampleGroup
12
- include Rack::Test::Methods
13
- metadata[:type] = :acceptance
14
- end
15
- end
16
- end
17
- end
18
-
19
- module DSL
20
- def feature(*args, &block)
21
- args << {} unless args.last.is_a?(Hash)
22
- args.last.update :type => :acceptance, :steak => true, :caller => caller
23
- describe(*args, &block)
24
- end
25
- end
26
- end
27
-
28
- extend Steak::DSL
29
-
30
- RSpec.configuration.include Steak::AcceptanceExampleGroup, :type => :acceptance
31
-
@@ -1,98 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require File.dirname(__FILE__) + "/../../../lib/steak"
4
- require 'tempfile'
5
- require 'shellwords'
6
-
7
- module RSpec_1
8
- module Factories
9
- def create_spec(options)
10
- options = {:content => options} unless options.is_a?(Hash)
11
- path = (options[:path] || current_dir) + "/#{String.random}_spec.rb"
12
- File.open(path, "w") do |file|
13
- file.write options[:content]
14
- end
15
- path
16
- end
17
-
18
- def create_rails_app(options = {})
19
- path = current_dir + "/rails_app_#{String.random}"
20
- FileUtils.rm_rf path
21
- run "rails #{path}"
22
- FileUtils.rm path + '/public/index.html'
23
- File.open(path + "/config/environments/test.rb", "a") do |file|
24
- file.write <<-CONFIG
25
- config.gem 'rspec-rails', :lib => false
26
- CONFIG
27
- end
28
- FileUtils.cp_r steak_dir, path + "/vendor/plugins/steak"
29
-
30
- Dir.chdir path do
31
- run "script/generate rspec"
32
- end
33
-
34
- unless options[:setup_steak] == false
35
- Dir.chdir path do
36
- run "script/generate steak"
37
- end
38
- end
39
-
40
- path
41
- end
42
-
43
- end
44
-
45
- module HelperMethods
46
- def run(cmd)
47
- puts cmd if trace?
48
- `rvm @steak-rspec-1 exec #{cmd} 2>&1`.tap do |o|
49
- puts o if trace? and o
50
- end
51
- end
52
-
53
- def trace?
54
- ENV['TRACE']
55
- end
56
-
57
- def run_spec(file_path)
58
- run "spec #{file_path}"
59
- end
60
-
61
- def current_dir
62
- Dir.tmpdir + "/steak_rspec_1"
63
- end
64
-
65
- def steak_dir
66
- File.expand_path(File.dirname(__FILE__) + "/../../../")
67
- end
68
- end
69
-
70
- def self.gemset_create(gemset, *gems)
71
- `rvm gemset create #{gemset}`
72
- gems.each do |name|
73
- name = Shellwords.escape(name)
74
- `rvm @#{gemset} gem search #{name} -i || rvm @#{gemset} gem install #{name}`
75
- end
76
- end
77
-
78
- RSpec.configure do |config|
79
- config.include Factories, :example_group => { :file_path => /rspec-1/}
80
- config.include HelperMethods, :example_group => { :file_path => /rspec-1/}
81
- config.before :suite do
82
- gemset_create "steak-rspec-1", "rspec-rails -v '~> 1'",
83
- "rails -v '~> 2'",
84
- "webrat",
85
- "capybara",
86
- "sqlite3-ruby",
87
- "rake",
88
- "test-unit -v '1.2.3'"
89
- end
90
- end
91
- end
92
-
93
- class String
94
- CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
95
- def self.random(size = 8)
96
- (0..size).map{ CHARS[rand(CHARS.length)] }.join
97
- end
98
- end
@@ -1,44 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec generator for rails", %q{
4
- In order to quickly add a new acceptance spec
5
- As a developer
6
- I want to run a generator that creates it for me
7
- } do
8
-
9
- background do
10
- @rails_app = create_rails_app
11
- end
12
-
13
- scenario "Adding new acceptance spec" do
14
- Dir.chdir @rails_app do
15
- run "script/generate acceptance_spec document_creation"
16
- end
17
-
18
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
19
- end
20
-
21
- scenario "Adding new acceptance spec (plural name)" do
22
- Dir.chdir @rails_app do
23
- run "script/generate acceptance_spec creating_documents"
24
- end
25
-
26
- File.exist?(@rails_app + "/spec/acceptance/creating_documents_spec.rb").should be_true
27
- end
28
-
29
- scenario "Adding new acceptance spec (pascalized name)" do
30
- Dir.chdir @rails_app do
31
- run "script/generate acceptance_spec DocumentCreation"
32
- end
33
-
34
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
35
- end
36
-
37
- scenario "Adding new acceptance spec (name ending with _spec)" do
38
- Dir.chdir @rails_app do
39
- run "script/generate acceptance_spec document_creation_spec"
40
- end
41
-
42
- File.exist?(@rails_app + "/spec/acceptance/document_creation_spec.rb").should be_true
43
- end
44
- end
@@ -1,76 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec execution", %q{
4
- In order to write better software
5
- As a ruby developer
6
- I want to execute acceptance specs
7
- } do
8
-
9
- scenario "Minimal acceptance spec" do
10
- spec_file = create_spec <<-SPEC
11
- require '#{File.dirname(__FILE__) + "/../../../lib/steak"}'
12
- feature "Minimal spec" do
13
- scenario "First scenario" do
14
- true.should be_true
15
- end
16
- end
17
- SPEC
18
- output = run_spec spec_file
19
- output.should =~ /1 example, 0 failures/
20
- end
21
-
22
- scenario "Minimal acceptance spec that fails" do
23
- spec_file = create_spec <<-SPEC
24
- require '#{File.dirname(__FILE__) + "/../../../lib/steak"}'
25
- feature "Minimal spec" do
26
- scenario "First scenario" do
27
- true.should be_false
28
- end
29
- end
30
- SPEC
31
- output = run_spec spec_file
32
- output.should =~ /1 example, 1 failure/
33
- end
34
-
35
- scenario "Acceptance spec with background" do
36
- spec_file = create_spec <<-SPEC
37
- require '#{File.dirname(__FILE__) + "/../../../lib/steak"}'
38
- feature "Minimal spec" do
39
- background do
40
- @value = 17
41
- end
42
- scenario "First scenario" do
43
- @value.should == 17
44
- end
45
- end
46
- SPEC
47
- output = run_spec spec_file
48
- output.should =~ /1 example, 0 failures/
49
- end
50
-
51
- scenario "Steak should not pollute Object methods namespace" do
52
- spec_file = create_spec <<-SPEC
53
- require '#{File.dirname(__FILE__) + "/../../../lib/steak"}'
54
-
55
- class Wadus
56
- def call_feature
57
- feature
58
- end
59
-
60
- def method_missing(meth, *args, &blk)
61
- return "Hello!"
62
- end
63
- end
64
-
65
- feature "Wadus class" do
66
- scenario "should not be polluted by Steak" do
67
- w = Wadus.new
68
- w.should_not respond_to(:feature)
69
- w.call_feature.should == "Hello!"
70
- end
71
- end
72
- SPEC
73
- output = run_spec spec_file
74
- output.should =~ /1 example, 0 failures/
75
- end
76
- end
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Acceptance spec execution", %q{
4
- In order to write better web apps
5
- As a rails developer
6
- I want to execute acceptance specs
7
- } do
8
-
9
- scenario "Minimal acceptance spec" do
10
- rails_app = create_rails_app
11
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
12
- :content => <<-SPEC
13
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
14
- feature "Minimal spec" do
15
- scenario "First scenario" do
16
- Rails.env.should be_test
17
- end
18
- end
19
- SPEC
20
- output = run_spec spec_file
21
- output.should =~ /1 example, 0 failures/
22
- end
23
-
24
- scenario "Integration stuff" do
25
- rails_app = create_rails_app
26
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
27
- :content => <<-SPEC
28
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
29
- feature "Minimal spec" do
30
- scenario "First scenario" do
31
- get "/"
32
- response.should have_text(/No route matches/)
33
- end
34
- end
35
- SPEC
36
- output = run_spec spec_file
37
- output.should =~ /1 example, 0 failures/
38
- end
39
- end
@@ -1,96 +0,0 @@
1
- require File.dirname(__FILE__) + "/acceptance_helper.rb"
2
-
3
- feature "Steak generator for rails", %q{
4
- In order to quickly start to hack my rails project with steak
5
- As a developer
6
- I want to run a generator that sets everything up for me
7
- } do
8
-
9
- scenario "Running generator in an empty project" do
10
- rails_app = create_rails_app(:setup_steak => false)
11
-
12
- Dir.chdir rails_app do
13
- run "script/generate steak"
14
- end
15
-
16
- File.exist?(rails_app + "/spec/acceptance/acceptance_helper.rb").should be_true
17
- File.exist?(rails_app + "/spec/acceptance/support/helpers.rb").should be_true
18
- File.exist?(rails_app + "/spec/acceptance/support/paths.rb").should be_true
19
- File.exist?(rails_app + "/lib/tasks/steak.rake").should be_true
20
- end
21
-
22
- scenario "Running generator with capybara by default" do
23
- rails_app = create_rails_app(:setup_steak => false)
24
-
25
- Dir.chdir rails_app do
26
- run "script/generate steak"
27
- end
28
-
29
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
30
- :content => <<-SPEC
31
- require File.expand_path(File.dirname(__FILE__) + "/acceptance_helper.rb")
32
- feature "Capybara spec" do
33
- scenario "First scenario" do
34
- visit "/"
35
- page.should have_content('No route matches')
36
- end
37
- end
38
- SPEC
39
- output = run_spec spec_file
40
- output.should =~ /1 example, 0 failures/
41
- end
42
-
43
- scenario "Running generator with webrat" do
44
- rails_app = create_rails_app(:setup_steak => false)
45
-
46
- Dir.chdir rails_app do
47
- run "script/generate steak --webrat"
48
- end
49
-
50
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
51
- :content => <<-SPEC
52
- require File.expand_path(File.dirname(__FILE__) + "/acceptance_helper.rb")
53
- feature "Capybara spec" do
54
- scenario "First scenario" do
55
- visit "/"
56
- response.should contain('No route matches')
57
- end
58
- end
59
- SPEC
60
- output = run_spec spec_file
61
- output.should =~ /1 example, 0 failures/
62
- end
63
-
64
- scenario "Running rake stats" do
65
- rails_app = create_rails_app
66
-
67
- Dir.chdir rails_app do
68
- run "script/generate steak"
69
- run("rake stats").should =~ /Acceptance specs/
70
- end
71
- end
72
-
73
- scenario "Running specs with rake" do
74
- rails_app = create_rails_app(:setup_steak => true)
75
-
76
- spec_file = create_spec :path => rails_app + "/spec/acceptance",
77
- :content => <<-SPEC
78
- require File.expand_path(File.dirname(__FILE__) + "/acceptance_helper.rb")
79
- feature "Basic spec" do
80
- scenario "First scenario" do
81
- true.should == true
82
- end
83
- end
84
- SPEC
85
-
86
- Dir.chdir rails_app do
87
- run "rake db:migrate db:test:prepare"
88
-
89
- output = run "rake spec:acceptance"
90
- output.should =~ /1 example, 0 failures/
91
-
92
- output = run "rake"
93
- output.should =~ /1 example, 0 failures/
94
- end
95
- end
96
- end
@@ -1,81 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require File.dirname(__FILE__) + "/../../../lib/steak"
4
- require 'tempfile'
5
-
6
- module RSpec_2
7
- module Factories
8
- def create_spec(options)
9
- options = {:content => options} unless options.is_a?(Hash)
10
- path = (options[:path] || Dir.tmpdir) + "/#{String.random}_spec.rb"
11
- File.open(path, "w") do |file|
12
- file.write options[:content]
13
- end
14
- path
15
- end
16
-
17
- def create_rails_app(options = {})
18
- options[:browser_simulator] ||= "capybara"
19
-
20
- path = File.join(Dir.tmpdir, String.random, "rails_app")
21
- FileUtils.rm_rf path
22
- run "rails new #{path}"
23
- FileUtils.rm_rf path + '/public/index.html'
24
- File.open(File.join(path, "Gemfile"), "a") do |file|
25
- file.write %{
26
- gem 'rspec-rails', '>= 2.0.0.a9'
27
- gem '#{options[:browser_simulator]}'
28
- gem 'steak', :path => '#{File.expand_path(File.dirname(__FILE__) + '/../../..')}'
29
- }
30
- end
31
-
32
- run "bundle install"
33
-
34
- Dir.chdir path do
35
- run "rails generate rspec:install"
36
- if options[:scaffold]
37
- run "rails generate scaffold #{options[:scaffold]}"
38
- run "rake db:migrate db:test:prepare"
39
- end
40
- end
41
-
42
- unless options[:setup_steak] == false
43
- Dir.chdir path do
44
- run "rails generate steak:install"
45
- end
46
- end
47
-
48
- path
49
- end
50
-
51
- end
52
-
53
- module HelperMethods
54
- def run(cmd)
55
- `#{cmd} 2>&1`.tap do |o|
56
- puts o if ENV['TRACE']
57
- end
58
- end
59
-
60
- def run_spec(file_path, app_base=Dir.pwd)
61
- Dir.chdir app_base do
62
- run("rspec #{file_path}")
63
- end
64
- end
65
- end
66
-
67
- RSpec.configure do |config|
68
- config.include Factories, :example_group => {:file_path => /rspec-2/}
69
- config.include HelperMethods, :example_group => {:file_path => /rspec-2/}
70
- end
71
- end
72
-
73
- class String
74
- unless const_defined?("CHARS")
75
- CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
76
- end
77
-
78
- def self.random(size = 8)
79
- (0..size).map{ CHARS[rand(CHARS.length)] }.join
80
- end
81
- end