From b88c721c92be3596ab75acfde4ee058b33f32fae Mon Sep 17 00:00:00 2001 From: Piotr Solnica Date: Mon, 29 Nov 2010 12:16:11 +0100 Subject: [PATCH 1/9] Depend on railties, activesupport and actionpack instead of monolithic rails gem - Closes #275. --- rspec-rails.gemspec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index b26d1eab1d..20101b8bc6 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -57,7 +57,9 @@ Gem::Specification.new do |s| ************************************************** } - s.add_runtime_dependency "rails", "~> 3.0.0" + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].join('.')}" end From db88d252c7c9e9238461d701627f342194efd4bc Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Mon, 29 Nov 2010 09:09:21 -0600 Subject: [PATCH 2/9] history --- History.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/History.md b/History.md index 17fa581871..1e4f14cf67 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,13 @@ ## rspec-rails-2 release history (incomplete) +### 2.3.0 / in development + +[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...master) + +* Bug fixes + * Depend on railties, activesupport, and actionpack instead of rails (Piotr + Solnica) + ### 2.2.0 / 2010-11-28 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.1.0...v2.2.0) From e700858137b0f0ea09903eff9cd9707da0c302bb Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Mon, 29 Nov 2010 09:10:44 -0600 Subject: [PATCH 3/9] Update deps - rspec ~> M.m.0 (3 digits instead of 2) - rails gems >= 3.0.0 (not ~> 3.0.0) --- rspec-rails.gemspec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index 20101b8bc6..84fcbe1942 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -57,9 +57,9 @@ Gem::Specification.new do |s| ************************************************** } - s.add_runtime_dependency(%q, ["~> 3.0.0"]) - s.add_runtime_dependency(%q, ["~> 3.0.0"]) - s.add_runtime_dependency(%q, ["~> 3.0.0"]) - s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].join('.')}" + s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}" end From 1a881dde1f61cb1fbd9382be66ab85ad49673f3c Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Mon, 29 Nov 2010 18:55:08 -0600 Subject: [PATCH 4/9] links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 50688d38be..25a1fae714 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2. ## Documentation -The [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-1) are the +The [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-2) are the most comprehensive and up-to-date docs for end-users. -The [RDoc](http://rubydoc.info/gems/rspec-rails/2.1/frames) provides additional +The [RDoc](http://rubydoc.info/gems/rspec-rails/2.2.0/frames) provides additional information for contributors and/or extenders. All of the documentation is open source and a work in progress. If you find it From 4b79a8787313c9f479c6d60dc4da3d68c97973c3 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Mon, 29 Nov 2010 19:37:15 -0600 Subject: [PATCH 5/9] Point cucumber dev dependency to my fork which depends on builder. - filed pull request with cucumber project - can revert this if/when that is merged/released. --- Gemfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index f623038fcb..a9b02cb31d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,16 @@ source "http://rubygems.org/" gem "rack", :git => "git://github.com/rack/rack.git" -gem 'rails', :path => File.expand_path("../vendor/rails", __FILE__) + +%w[activesupport actionpack railties activemodel].each do |lib| + gem lib, :path => File.expand_path("../vendor/rails/#{lib}", __FILE__) +end %w[rspec-rails rspec rspec-core rspec-expectations rspec-mocks].each do |lib| gem lib, :path => File.expand_path("../../#{lib}", __FILE__) end -gem "cucumber", "0.9.4" +gem "cucumber", :git => "git://github.com/dchelimsky/cucumber", :branch => "update-gemspec" gem "aruba", "0.2.2" gem 'webrat', "0.7.2" gem 'sqlite3-ruby', :require => 'sqlite3' From 6eb2b25909bc93b0e9c96039c155a538020ae91d Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Mon, 29 Nov 2010 19:57:54 -0600 Subject: [PATCH 6/9] Gemfile can still depend on rails for development --- Gemfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index a9b02cb31d..e867e4b696 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,8 @@ source "http://rubygems.org/" +gem "rails", :path => File.expand_path("../vendor/rails", __FILE__) gem "rack", :git => "git://github.com/rack/rack.git" -%w[activesupport actionpack railties activemodel].each do |lib| - gem lib, :path => File.expand_path("../vendor/rails/#{lib}", __FILE__) -end - %w[rspec-rails rspec rspec-core rspec-expectations rspec-mocks].each do |lib| gem lib, :path => File.expand_path("../../#{lib}", __FILE__) end From 617d675dca7e233fa142ffef14e465a099517df9 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Wed, 1 Dec 2010 07:43:06 -0600 Subject: [PATCH 7/9] Got webrat working across request and controller specs - added --webrat flag for request controller generator - deprecated --webrat-matchers flag across generators - Closes #277. --- History.md | 4 ++++ .../integration/integration_generator.rb | 12 ++++++++++- .../integration/templates/request_spec.rb | 6 ++++++ .../rspec/scaffold/scaffold_generator.rb | 6 ++++-- .../rspec/scaffold/templates/edit_spec.rb | 2 +- .../rspec/scaffold/templates/index_spec.rb | 2 +- .../rspec/scaffold/templates/new_spec.rb | 2 +- .../rspec/scaffold/templates/show_spec.rb | 2 +- .../rails/example/controller_example_group.rb | 10 ++++++++- .../rails/example/helper_example_group.rb | 1 + .../rails/example/request_example_group.rb | 21 +++++++++++++++++-- 11 files changed, 58 insertions(+), 10 deletions(-) diff --git a/History.md b/History.md index 1e4f14cf67..d5a4b5587b 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,10 @@ * Bug fixes * Depend on railties, activesupport, and actionpack instead of rails (Piotr Solnica) + * Got webrat integration working properly across different types of specs + +* Deprecations + * --webrat-matchers flag for generators is deprecated. use --webrat instead. ### 2.2.0 / 2010-11-28 diff --git a/lib/generators/rspec/integration/integration_generator.rb b/lib/generators/rspec/integration/integration_generator.rb index aca6d0d98e..9554039ac8 100644 --- a/lib/generators/rspec/integration/integration_generator.rb +++ b/lib/generators/rspec/integration/integration_generator.rb @@ -3,7 +3,9 @@ module Rspec module Generators class IntegrationGenerator < Base - class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs" + class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs" + class_option :webrat, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers" + class_option :webrat_matchers, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers (deprecated - use --webrat)" def generate_request_spec return unless options[:request_specs] @@ -11,6 +13,14 @@ def generate_request_spec template 'request_spec.rb', File.join('spec/requests', class_path, "#{table_name}_spec.rb") end + + protected + + def webrat? + RSpec.deprecate("the --webrat-matchers option", "--webrat") if options[:webrat_matchers] + options[:webrat] || options[:webrat_matchers] + end + end end end diff --git a/lib/generators/rspec/integration/templates/request_spec.rb b/lib/generators/rspec/integration/templates/request_spec.rb index ba20323e4b..9c2930b17e 100644 --- a/lib/generators/rspec/integration/templates/request_spec.rb +++ b/lib/generators/rspec/integration/templates/request_spec.rb @@ -3,7 +3,13 @@ describe "<%= class_name.pluralize %>" do describe "GET /<%= table_name %>" do it "works! (now write some real specs)" do +<% if webrat? -%> + visit <%= table_name %>_path +<% else -%> + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers get <%= table_name %>_path +<% end -%> + response.status.should be(200) end end end diff --git a/lib/generators/rspec/scaffold/scaffold_generator.rb b/lib/generators/rspec/scaffold/scaffold_generator.rb index 15cf2787c8..011a31fe7d 100644 --- a/lib/generators/rspec/scaffold/scaffold_generator.rb +++ b/lib/generators/rspec/scaffold/scaffold_generator.rb @@ -14,7 +14,8 @@ class ScaffoldGenerator < Base class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs" class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs" - class_option :webrat_matchers, :type => :boolean, :default => false, :desc => "Use webrat matchers in view specs" + class_option :webrat, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers" + class_option :webrat_matchers, :type => :boolean, :default => false, :desc => "Use webrat methods/matchers (deprecated - use --webrat)" class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs" class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs" @@ -51,7 +52,8 @@ def generate_routing_spec protected def webrat? - options[:webrat_matchers] || @webrat_matchers_requested + RSpec.deprecate("--webrat-matchers", "--webrat") if options[:webrat_matchers] + options[:webrat] || options[:webrat_matchers] end def copy_view(view) diff --git a/lib/generators/rspec/scaffold/templates/edit_spec.rb b/lib/generators/rspec/scaffold/templates/edit_spec.rb index b133ac2f0f..49259754f2 100644 --- a/lib/generators/rspec/scaffold/templates/edit_spec.rb +++ b/lib/generators/rspec/scaffold/templates/edit_spec.rb @@ -20,7 +20,7 @@ <% end -%> end <% else -%> - # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers + # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form", :action => <%= file_name %>_path(@<%= file_name %>), :method => "post" do <% for attribute in output_attributes -%> assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]" diff --git a/lib/generators/rspec/scaffold/templates/index_spec.rb b/lib/generators/rspec/scaffold/templates/index_spec.rb index e94d3327fe..19b0e9173f 100644 --- a/lib/generators/rspec/scaffold/templates/index_spec.rb +++ b/lib/generators/rspec/scaffold/templates/index_spec.rb @@ -22,7 +22,7 @@ <% if webrat? -%> rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2) <% else -%> - # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers + # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2 <% end -%> <% end -%> diff --git a/lib/generators/rspec/scaffold/templates/new_spec.rb b/lib/generators/rspec/scaffold/templates/new_spec.rb index 30c25a116d..2bb51b50c6 100644 --- a/lib/generators/rspec/scaffold/templates/new_spec.rb +++ b/lib/generators/rspec/scaffold/templates/new_spec.rb @@ -19,7 +19,7 @@ <% end -%> end <% else -%> - # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers + # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form", :action => <%= table_name %>_path, :method => "post" do <% for attribute in output_attributes -%> assert_select "<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>", :name => "<%= file_name %>[<%= attribute.name %>]" diff --git a/lib/generators/rspec/scaffold/templates/show_spec.rb b/lib/generators/rspec/scaffold/templates/show_spec.rb index 36547222a6..c6a7158eee 100644 --- a/lib/generators/rspec/scaffold/templates/show_spec.rb +++ b/lib/generators/rspec/scaffold/templates/show_spec.rb @@ -18,7 +18,7 @@ <% if webrat? -%> rendered.should contain(<%= value_for(attribute) %>.to_s) <% else -%> - # Run the generator again with the --webrat-matchers flag if you want to use webrat matchers + # Run the generator again with the --webrat flag if you want to use webrat matchers rendered.should match(/<%= eval(value_for(attribute)) %>/) <% end -%> <% end -%> diff --git a/lib/rspec/rails/example/controller_example_group.rb b/lib/rspec/rails/example/controller_example_group.rb index f78442ae8b..e877c81a21 100644 --- a/lib/rspec/rails/example/controller_example_group.rb +++ b/lib/rspec/rails/example/controller_example_group.rb @@ -157,12 +157,20 @@ module InstanceMethods end included do + subject { controller } + metadata[:type] = :controller + before do @routes = ::Rails.application.routes ActionController::Base.allow_forgery_protection = false end - subject { controller } + + webrat do + before do + Webrat.configure {|c| c.mode = :rails} + end + end end RSpec.configure &include_self_when_dir_matches('spec','controllers') diff --git a/lib/rspec/rails/example/helper_example_group.rb b/lib/rspec/rails/example/helper_example_group.rb index 2deb519b03..ef382cc8ee 100644 --- a/lib/rspec/rails/example/helper_example_group.rb +++ b/lib/rspec/rails/example/helper_example_group.rb @@ -61,6 +61,7 @@ def _controller_path included do metadata[:type] = :helper + before do controller.controller_path = _controller_path end diff --git a/lib/rspec/rails/example/request_example_group.rb b/lib/rspec/rails/example/request_example_group.rb index 23f940236c..34c2459be0 100644 --- a/lib/rspec/rails/example/request_example_group.rb +++ b/lib/rspec/rails/example/request_example_group.rb @@ -21,12 +21,21 @@ module RequestExampleGroup include ActionDispatch::Assertions include RSpec::Rails::BrowserSimulators + module InstanceMethods + def app + ::Rails.application + end + end + webrat do include Webrat::Matchers include Webrat::Methods - def app - ::Rails.application + module InstanceMethods + + def last_response + @response + end end end @@ -44,6 +53,14 @@ def app before do @router = ::Rails.application.routes end + + webrat do + before do + Webrat.configure do |c| + c.mode = :rack + end + end + end end RSpec.configure &include_self_when_dir_matches('spec','requests') From eb7c5dc85b045c49e8c0261a2adceee60a4f1932 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Wed, 1 Dec 2010 07:58:32 -0600 Subject: [PATCH 8/9] bump version to 2.2.1 --- History.md | 6 +++--- README.md | 2 +- lib/rspec/rails/version.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/History.md b/History.md index d5a4b5587b..3b6b1399c4 100644 --- a/History.md +++ b/History.md @@ -1,8 +1,8 @@ -## rspec-rails-2 release history (incomplete) +## rspec-rails-2 release history -### 2.3.0 / in development +### 2.2.1 / 2010-12-01 -[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...master) +[full changelog](http://github.com/rspec/rspec-rails/compare/v2.2.0...v2.2.1) * Bug fixes * Depend on railties, activesupport, and actionpack instead of rails (Piotr diff --git a/README.md b/README.md index 25a1fae714..bf2a2c8e79 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ NOTE: rspec-2 does _not_ support rails-2. Use rspec-rails-1.3.x for rails-2. The [Cucumber features](http://relishapp.com/rspec/rspec-rails/v/2-2) are the most comprehensive and up-to-date docs for end-users. -The [RDoc](http://rubydoc.info/gems/rspec-rails/2.2.0/frames) provides additional +The [RDoc](http://rubydoc.info/gems/rspec-rails/2.2.1/frames) provides additional information for contributors and/or extenders. All of the documentation is open source and a work in progress. If you find it diff --git a/lib/rspec/rails/version.rb b/lib/rspec/rails/version.rb index 81400e4597..f10c8a48b4 100644 --- a/lib/rspec/rails/version.rb +++ b/lib/rspec/rails/version.rb @@ -1,7 +1,7 @@ module RSpec # :nodoc: module Rails # :nodoc: module Version # :nodoc: - STRING = '2.2.0' + STRING = '2.2.1' end end end From c89a5acb8b05522f257acfda7c03bc26ad8c089d Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Wed, 1 Dec 2010 08:03:28 -0600 Subject: [PATCH 9/9] Make rails gem deps work for anything < 4.0 --- rspec-rails.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index 84fcbe1942..c8642b7434 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -57,9 +57,9 @@ Gem::Specification.new do |s| ************************************************** } - s.add_runtime_dependency(%q, [">= 3.0.0"]) - s.add_runtime_dependency(%q, [">= 3.0.0"]) - s.add_runtime_dependency(%q, [">= 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0"]) + s.add_runtime_dependency(%q, ["~> 3.0"]) + s.add_runtime_dependency(%q, ["~> 3.0"]) s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}" end