Skip to content

Commit

Permalink
Configure webrat in full rack mode and use as a gem (not plugin). Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
cavalle committed May 3, 2010
1 parent 3b309c2 commit 00e3639
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
17 changes: 16 additions & 1 deletion lib/generators/steak/templates/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
Webrat.configure do |config|
config.mode = :rack
end
module AppHelper
def app
Rails.application
end
end
Rspec.configure do |config|
config.include Rack::Test::Methods
config.include Webrat::Methods
config.include Webrat::Matchers
config.include AppHelper
end
<%- else -%>
require 'capybara/rails'
include Capybara
Rspec.configure do |config|
config.include Capybara
end
<%- end -%>

# Put your acceptance spec helpers inside /spec/acceptance/support
Expand Down
8 changes: 2 additions & 6 deletions spec/acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ def create_rails_app(options = {})
"gem 'capybara'\n"
end

if options[:plugin]
FileUtils.cp_r File.dirname(__FILE__) + "/../../", path + "/vendor/plugins/steak"
else
File.open(File.join(path, "Gemfile"), "a") do |file|
file.write "\ngem 'steak', :path => '#{File.expand_path(File.dirname(__FILE__) + '/../..')}'\n"
end
File.open(File.join(path, "Gemfile"), "a") do |file|
file.write "\ngem 'steak', :path => '#{File.expand_path(File.dirname(__FILE__) + '/../..')}'\n"
end

Dir.chdir path do
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/steak_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
end

scenario "Running generator with webrat" do
rails_app = create_rails_app(:setup_steak => false, :scaffold => :users, :plugin => true)
rails_app = create_rails_app(:setup_steak => false, :scaffold => :users)

Dir.chdir rails_app do
`rails generate steak --webrat`
Expand All @@ -55,7 +55,7 @@
feature "Webrat spec" do
scenario "First scenario" do
visit "/users"
response.should contain('Listing users')
response_body.should contain('Listing users')
end
end
SPEC
Expand Down

0 comments on commit 00e3639

Please sign in to comment.