steak 0.4.0.beta.1 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.rdoc +94 -48
  2. data/Rakefile +1 -1
  3. data/lib/rspec-1/rails/generators/acceptance_spec/USAGE +1 -0
  4. data/lib/rspec-1/rails/generators/acceptance_spec/acceptance_spec_generator.rb +9 -0
  5. data/lib/{generators → rspec-1/rails/generators}/acceptance_spec/templates/acceptance_spec.rb +2 -3
  6. data/lib/{generators → rspec-1/rails/generators}/steak/USAGE +4 -4
  7. data/lib/rspec-1/rails/generators/steak/steak_generator.rb +26 -0
  8. data/lib/rspec-1/rails/generators/steak/templates/acceptance_helper.rb +18 -0
  9. data/lib/rspec-1/rails/generators/steak/templates/helpers.rb +5 -0
  10. data/lib/rspec-1/rails/generators/steak/templates/paths.rb +9 -0
  11. data/lib/rspec-1/rails/generators/steak/templates/steak.rake +19 -0
  12. data/lib/rspec-1/steak.rb +23 -0
  13. data/lib/rspec-2/rails/generators/install_generator.rb +39 -0
  14. data/lib/rspec-2/rails/generators/spec_generator.rb +33 -0
  15. data/lib/{generators/steak → rspec-2/rails/generators}/templates/acceptance_helper.rb +8 -10
  16. data/lib/rspec-2/rails/generators/templates/acceptance_spec.rb +12 -0
  17. data/lib/rspec-2/rails/generators/templates/helpers.rb +5 -0
  18. data/lib/rspec-2/rails/generators/templates/paths.rb +9 -0
  19. data/lib/rspec-2/rails/railtie.rb +14 -0
  20. data/lib/{generators/steak/templates → rspec-2/rails/tasks}/steak.rake +2 -2
  21. data/lib/rspec-2/steak.rb +22 -0
  22. data/lib/steak.rb +8 -10
  23. data/spec/acceptance/rspec-1/acceptance_helper.rb +95 -0
  24. data/spec/acceptance/{acceptance_spec_generator_spec.rb → rspec-1/acceptance_spec_generator_spec.rb} +14 -15
  25. data/spec/acceptance/{basic_spec.rb → rspec-1/basic_spec.rb} +7 -8
  26. data/spec/acceptance/{rails_spec.rb → rspec-1/rails_spec.rb} +10 -12
  27. data/spec/acceptance/{steak_generator_spec.rb → rspec-1/steak_generator_spec.rb} +22 -26
  28. data/spec/acceptance/rspec-2/acceptance_helper.rb +87 -0
  29. data/spec/acceptance/rspec-2/basic_spec.rb +78 -0
  30. data/spec/acceptance/rspec-2/rails_spec.rb +89 -0
  31. data/spec/acceptance/rspec-2/steak_install_generator_spec.rb +66 -0
  32. data/spec/acceptance/rspec-2/steak_spec_generator_spec.rb +63 -0
  33. metadata +112 -26
  34. data/init.rb +0 -8
  35. data/lib/generators/acceptance_spec/USAGE +0 -0
  36. data/lib/generators/acceptance_spec/acceptance_spec_generator.rb +0 -13
  37. data/lib/generators/steak/steak_generator.rb +0 -29
  38. data/lib/generators/steak/templates/helpers.rb +0 -6
  39. data/lib/generators/steak/templates/paths.rb +0 -9
  40. data/spec/acceptance/acceptance_helper.rb +0 -76
data/init.rb DELETED
@@ -1,8 +0,0 @@
1
- # Placeholder to satisfy Rails.
2
- #
3
- # Do NOT add any require statements to this file. Doing
4
- # so will cause Rails to load this plugin all of the time.
5
- #
6
- # spec/acceptance/acceptance_helper.rb should include the necessary
7
- # require statements and configuration. This file should
8
- # be required by all of your acceptance specs.
File without changes
@@ -1,13 +0,0 @@
1
- require 'rails/generators'
2
-
3
- class AcceptanceSpecGenerator < Rails::Generators::NamedBase
4
- def manifest
5
- empty_directory File.join('spec/acceptance', class_path)
6
- file_name.gsub!(/_spec$/,"")
7
- template 'acceptance_spec.rb', File.join('spec/acceptance', class_path, "#{file_name}_spec.rb")
8
- end
9
-
10
- def self.source_root
11
- File.join(File.dirname(__FILE__), 'templates')
12
- end
13
- end
@@ -1,29 +0,0 @@
1
- require 'rails/generators'
2
-
3
- class SteakGenerator < Rails::Generators::Base
4
- class_option :webrat, :desc => 'Use Webrat.', :type => :boolean
5
- class_option :capybara, :desc => 'Use Capybara.', :type => :boolean
6
-
7
- def initialize(args=[], options={}, config={})
8
- puts "Defaulting to Capybara..." if options.empty?
9
- super
10
- end
11
-
12
- def manifest
13
- empty_directory 'spec/controllers'
14
- empty_directory 'spec/acceptance/support'
15
- empty_directory 'lib/tasks'
16
- template "acceptance_helper.rb", "spec/acceptance/acceptance_helper.rb"
17
- copy_file "helpers.rb", "spec/acceptance/support/helpers.rb"
18
- copy_file "paths.rb", "spec/acceptance/support/paths.rb"
19
- copy_file "steak.rake", "lib/tasks/steak.rake"
20
- end
21
-
22
- def driver
23
- @driver = options.webrat? ? 'webrat' : 'capybara'
24
- end
25
-
26
- def self.source_root
27
- File.join(File.dirname(__FILE__), 'templates')
28
- end
29
- end
@@ -1,6 +0,0 @@
1
- module HelperMethods
2
- # Put here any helper method you need to be available in all your acceptance tests
3
-
4
- end
5
-
6
- Rspec.configuration.include(HelperMethods)
@@ -1,9 +0,0 @@
1
- module NavigationHelpers
2
- # Put here the helper methods related to the paths of your applications
3
-
4
- def homepage
5
- "/"
6
- end
7
- end
8
-
9
- Rspec.configuration.include(NavigationHelpers)
@@ -1,76 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require File.dirname(__FILE__) + "/../../lib/steak"
4
- require 'tempfile'
5
-
6
- module Factories
7
- def create_spec(options)
8
- options = {:content => options} unless options.is_a?(Hash)
9
- path = (options[:path] || Dir.tmpdir) + "/#{String.random}_spec.rb"
10
- File.open(path, "w") do |file|
11
- file.write options[:content]
12
- end
13
- path
14
- end
15
-
16
- def create_rails_app(options = {})
17
- path = File.join(Dir.tmpdir, String.random, "rails_app")
18
- FileUtils.rm_rf path
19
- `rails #{path}`
20
- FileUtils.rm_rf path + '/public/index.html'
21
- File.open(File.join(path, "Gemfile"), "a") do |file|
22
- file.write "\ngem 'rspec-rails', '>= 2.0.0.a9'\n" <<
23
- "gem 'capybara'\n"
24
- end
25
-
26
- File.open(File.join(path, "Gemfile"), "a") do |file|
27
- file.write "\ngem 'steak', :path => '#{File.expand_path(File.dirname(__FILE__) + '/../..')}'\n"
28
- end
29
-
30
- Dir.chdir path do
31
- `rails generate rspec:install`
32
- if options[:scaffold]
33
- `rails generate scaffold #{options[:scaffold]}`
34
- `rake db:create db:migrate db:test:prepare`
35
- end
36
- end
37
-
38
- unless options[:setup_steak] == false
39
- Dir.chdir path do
40
- `rails generate steak`
41
- end
42
- end
43
-
44
- path
45
- end
46
-
47
- end
48
-
49
- module HelperMethods
50
- def run_spec(file_path, app_base=nil)
51
- if app_base
52
- current_dir = Dir.pwd
53
- Dir.chdir app_base
54
- end
55
-
56
- output = `rspec #{file_path} 2>&1`
57
-
58
- Dir.chdir current_dir if app_base
59
- output
60
- end
61
- end
62
-
63
- class String
64
- unless const_defined?("CHARS")
65
- CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
66
- end
67
-
68
- def self.random(size = 8)
69
- (0..size).map{ CHARS[rand(CHARS.length)] }.join
70
- end
71
- end
72
-
73
- Rspec.configure do |config|
74
- config.include(Factories)
75
- config.include(HelperMethods)
76
- end