steak 1.0.1 → 1.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.
@@ -101,10 +101,12 @@ You run your acceptance specs just like your regular specs. Individually...
101
101
 
102
102
  === In Rails 2.x
103
103
 
104
- Assuming you have already setup rspec-rails, add this to your project's
104
+ You need to setup rspec-rails before installing Steak. Make sure you use rspec(-rails) 1.x versions and not 2.x which don't work with Rails 2.3. You may want to use bundler and/or rvm to make sure the right versions of the gems are used.
105
+
106
+ Assuming you have already setup rspec-rails 1.x, add this to your project's
105
107
  <tt>config/environments/test.rb</tt>:
106
108
 
107
- config.gem "steak", :version => ">= 1.0.0.rc.1", :lib => false
109
+ config.gem "steak", :lib => false
108
110
 
109
111
  Install the gem from the command line:
110
112
 
@@ -185,5 +187,7 @@ Steak was created by Luismi Cavallé and improved thanks to the love from:
185
187
  - Enable Interactive
186
188
  - Vojto Rinik
187
189
  - Fred Wu
190
+ - Sergio Espeja
191
+ - Joao Carlos
188
192
 
189
193
  Copyright (c) 2009, 2010 Luismi Cavallé, released under the MIT license
@@ -1,6 +1,31 @@
1
1
  unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
2
2
 
3
- require 'spec/rake/spectask'
3
+ begin
4
+ require 'spec/rake/spectask'
5
+ rescue MissingSourceFile
6
+ module Spec
7
+ module Rake
8
+ class SpecTask
9
+ def initialize(name)
10
+ task name do
11
+ # if rspec-rails is a configured gem, this will output helpful material and exit ...
12
+ require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment"))
13
+
14
+ # ... otherwise, do this:
15
+ raise <<-MSG
16
+
17
+ #{"*" * 80}
18
+ * You are trying to run an rspec rake task defined in
19
+ * #{__FILE__},
20
+ * but rspec can not be found in vendor/gems, vendor/plugins or system gems.
21
+ #{"*" * 80}
22
+ MSG
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
4
29
 
5
30
  namespace :spec do
6
31
  desc "Run the code examples in spec/acceptance"
@@ -2,9 +2,6 @@ require 'rails/generators'
2
2
 
3
3
  module Steak
4
4
  class InstallGenerator < Rails::Generators::Base
5
- class_option :webrat, :desc => 'Use Webrat.', :type => :boolean
6
- class_option :capybara, :desc => 'Use Capybara.', :type => :boolean
7
-
8
5
  source_root File.join(File.dirname(__FILE__), 'templates')
9
6
 
10
7
  desc <<-DESC
@@ -30,9 +27,5 @@ DESC
30
27
  copy_file "helpers.rb", "spec/acceptance/support/helpers.rb"
31
28
  copy_file "paths.rb", "spec/acceptance/support/paths.rb"
32
29
  end
33
-
34
- def driver
35
- @driver = options.webrat? ? 'webrat' : 'capybara'
36
- end
37
30
  end
38
31
  end
@@ -18,7 +18,10 @@ Example:
18
18
  DESC
19
19
 
20
20
  def manifest
21
- empty_directory File.join('spec/acceptance', class_path)
21
+ if behavior == :invoke
22
+ empty_directory File.join('spec/acceptance', class_path)
23
+ end
24
+
22
25
  file_name.gsub!(/_spec$/, "")
23
26
 
24
27
  @feature_name = file_name.titleize
@@ -1,38 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
  require "steak"
3
- <%- if driver == 'webrat' %>
4
- require "webrat"
5
-
6
- Webrat.configure do |config|
7
- config.mode = :rack
8
- end
9
-
10
- module Steak::Webrat
11
- include Rack::Test::Methods
12
- include Webrat::Methods
13
- include Webrat::Matchers
14
-
15
- def app
16
- ::Rails.application
17
- end
18
- end
19
-
20
- RSpec.configuration.include Steak::Webrat, :type => :acceptance
21
-
22
- <%- else -%>
23
- require 'capybara/rails'
24
-
25
- module Steak::Capybara
26
- include Rack::Test::Methods
27
- include Capybara
28
-
29
- def app
30
- ::Rails.application
31
- end
32
- end
33
-
34
- RSpec.configuration.include Steak::Capybara, :type => :acceptance
35
- <%- end -%>
36
3
 
37
4
  # Put your acceptance spec helpers inside /spec/acceptance/support
38
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@@ -6,6 +6,12 @@ module Steak
6
6
  base.instance_eval do
7
7
  alias scenario example
8
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
9
15
  end
10
16
  end
11
17
  end
@@ -66,7 +66,7 @@ module RSpec_1
66
66
  File.expand_path(File.dirname(__FILE__) + "/../../../")
67
67
  end
68
68
  end
69
-
69
+
70
70
  def self.gemset_create(gemset, *gems)
71
71
  `rvm gemset create #{gemset}`
72
72
  gems.each do |name|
@@ -15,20 +15,20 @@ module RSpec_2
15
15
  end
16
16
 
17
17
  def create_rails_app(options = {})
18
+ options[:browser_simulator] ||= "capybara"
19
+
18
20
  path = File.join(Dir.tmpdir, String.random, "rails_app")
19
21
  FileUtils.rm_rf path
20
22
  run "rails new #{path}"
21
23
  FileUtils.rm_rf path + '/public/index.html'
22
24
  File.open(File.join(path, "Gemfile"), "a") do |file|
23
- file.write "\ngem 'rspec-rails', '>= 2.0.0.a9'\n" <<
24
- "gem 'capybara'\n" <<
25
- "gem 'webrat'\n"
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
+ }
26
30
  end
27
31
 
28
- File.open(File.join(path, "Gemfile"), "a") do |file|
29
- file.write "\ngem 'steak', :path => '#{File.expand_path(File.dirname(__FILE__) + '/../../..')}'\n"
30
- end
31
-
32
32
  run "bundle install"
33
33
 
34
34
  Dir.chdir path do
@@ -42,11 +42,7 @@ feature "Steak generator for rails", %q{
42
42
  end
43
43
 
44
44
  scenario "Running generator with webrat" do
45
- rails_app = create_rails_app(:setup_steak => false, :scaffold => :users)
46
-
47
- Dir.chdir rails_app do
48
- run "rails generate steak:install --webrat"
49
- end
45
+ rails_app = create_rails_app(:browser_simulator => :webrat, :scaffold => :users)
50
46
 
51
47
  spec_file = create_spec :path => rails_app + "/spec/acceptance",
52
48
  :content => <<-SPEC
@@ -60,4 +60,18 @@ feature "Acceptance spec generator for rails", %q{
60
60
  File.exist?(file_path).should be_true
61
61
  File.read(file_path).should include("/../acceptance_helper")
62
62
  end
63
+
64
+ scenario "Removing an acceptance spec" do
65
+ Dir.chdir @rails_app do
66
+ run "rails generate steak:spec document_creation"
67
+ run "rails destroy steak:spec document_creation"
68
+ end
69
+
70
+ spec_dir = @rails_app + "/spec/acceptance/"
71
+
72
+ File.exist?(spec_dir + "document_creation_spec.rb").should be_false
73
+ File.exist?(spec_dir + "acceptance_helper.rb").should be_true
74
+ File.exist?(spec_dir + "support/helpers.rb").should be_true
75
+ File.exist?(spec_dir + "support/paths.rb").should be_true
76
+ end
63
77
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steak
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Luismi Cavall\xC3\xA9"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-27 00:00:00 +01:00
18
+ date: 2011-01-15 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency