You are viewing a plain text version of this content. The canonical link for it is here.
Posted to olio-commits@incubator.apache.org by ws...@apache.org on 2008/12/11 01:34:30 UTC
svn commit: r725524 [2/14] - in /incubator/olio/webapp/rails/trunk:
app/controllers/ app/models/ app/views/events/ config/ config/environments/
spec/controllers/ spec/models/ vendor/plugins/attachment_fu/
vendor/plugins/attachment_fu/lib/ vendor/plugin...
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/core_image_test.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/core_image_test.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/core_image_test.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/core_image_test.rb Wed Dec 10 17:34:18 2008
@@ -22,6 +22,12 @@
# test geometry string
assert_equal 31, geo.width
assert_equal 41, geo.height
+
+ # This makes sure that we didn't overwrite the original file
+ # and will end up with a thumbnail instead of the original
+ assert_equal 42, attachment.width
+ assert_equal 55, attachment.height
+
end
else
def test_flunk
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb Wed Dec 10 17:34:18 2008
@@ -23,9 +23,81 @@
assert_equal 31, geo.width
assert_equal 40, geo.height
end
+
+ def test_should_crop_image(klass = ImageThumbnailCrop)
+ attachment_model klass
+ attachment = upload_file :filename => '/files/rails.png'
+ assert_valid attachment
+ assert attachment.image?
+ # has_attachment :thumbnails => { :square => "50x50c", :vertical => "30x60c", :horizontal => "60x30c"}
+
+ square = attachment.thumbnails.detect { |t| t.filename =~ /_square/ }
+ vertical = attachment.thumbnails.detect { |t| t.filename =~ /_vertical/ }
+ horizontal = attachment.thumbnails.detect { |t| t.filename =~ /_horizontal/ }
+
+ # test excat resize
+ assert_equal 50, square.width
+ assert_equal 50, square.height
+
+ assert_equal 30, vertical.width
+ assert_equal 60, vertical.height
+
+ assert_equal 60, horizontal.width
+ assert_equal 30, horizontal.height
+ end
+
+ # tests the first step in resize, crop the image in original size to right format
+ def test_should_crop_image_right(klass = ImageThumbnailCrop)
+ @@testcases.collect do |testcase|
+ image_width, image_height, thumb_width, thumb_height = testcase[:data]
+ image_aspect, thumb_aspect = image_width/image_height, thumb_width/thumb_height
+ crop_comand = klass.calculate_offset(image_width, image_height, image_aspect, thumb_width, thumb_height,thumb_aspect)
+ # pattern matching on crop command
+ if testcase.has_key?(:height)
+ assert crop_comand.match(/^#{image_width}x#{testcase[:height]}\+0\+#{testcase[:yoffset]}$/)
+ else
+ assert crop_comand.match(/^#{testcase[:width]}x#{image_height}\+#{testcase[:xoffset]}\+0$/)
+ end
+ end
+ end
+
else
def test_flunk
puts "MiniMagick not loaded, tests not running"
end
end
+
+ @@testcases = [
+ # image_aspect <= 1 && thumb_aspect >= 1
+ {:data => [10.0,40.0,2.0,1.0], :height => 5.0, :yoffset => 17.5}, # 1b
+ {:data => [10.0,40.0,1.0,1.0], :height => 10.0, :yoffset => 15.0}, # 1b
+
+ # image_aspect < 1 && thumb_aspect < 1
+ {:data => [10.0,40.0,1.0,2.0], :height => 20.0, :yoffset => 10.0}, # 1a
+ {:data => [2.0,3.0,1.0,2.0], :width => 1.5, :xoffset => 0.25}, # 1a
+
+ # image_aspect = thumb_aspect
+ {:data => [10.0,10.0,1.0,1.0], :height => 10.0, :yoffset => 0.0}, # QUADRAT 1c
+
+ # image_aspect >= 1 && thumb_aspect > 1 && image_aspect < thumb_aspect
+ {:data => [6.0,3.0,4.0,1.0], :height => 1.5, :yoffset => 0.75}, # 2b
+ {:data => [6.0,6.0,4.0,1.0], :height => 1.5, :yoffset => 2.25}, # 2b
+
+ # image_aspect > 1 && thumb_aspect > 1 && image_aspect > thumb_aspect
+ {:data => [9.0,3.0,2.0,1.0], :width => 6.0, :xoffset => 1.5}, # 2a
+
+ # image_aspect > 1 && thumb_aspect < 1 && image_aspect < thumb_aspect
+ {:data => [10.0,5.0,0.1,2.0], :width => 0.25, :xoffset => 4.875}, # 4
+ {:data => [10.0,5.0,1.0,2.0], :width => 2.5, :xoffset => 3.75}, # 4
+
+ # image_aspect > 1 && thumb_aspect > 1 && image_aspect > thumb_aspect
+ {:data => [9.0,3.0,2.0,1.0], :width => 6.0, :xoffset => 1.5}, # 3a
+ # image_aspect > 1 && thumb_aspect > 1 && image_aspect < thumb_aspect
+ {:data => [9.0,3.0,5.0,1.0], :height => 1.8, :yoffset => 0.6} # 3a
+ ]
+
+
+
+
+
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb Wed Dec 10 17:34:18 2008
@@ -181,7 +181,7 @@
assert_not_created do
use_temp_file "files/rails.png" do |file|
attachment.filename = 'rails2.png'
- attachment.temp_path = File.join(fixture_path, file)
+ attachment.temp_paths.unshift File.join(fixture_path, file)
attachment.save
new_filenames = [attachment.reload.full_filename] + attachment.thumbnails.collect { |t| t.reload.full_filename }
new_filenames.each { |f| assert File.exists?(f), "#{f} does not exist" }
@@ -224,7 +224,7 @@
# #temp_path calls #full_filename, which is not getting mixed into the attachment. Maybe we don't need to
# set temp_path at all?
#
- # attachment.temp_path = File.join(fixture_path, file)
+ # attachment.temp_paths.unshift File.join(fixture_path, file)
attachment.save!
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/test_helper.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/test_helper.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/test_helper.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/attachment_fu/test/test_helper.rb Wed Dec 10 17:34:18 2008
@@ -87,6 +87,14 @@
end
end
+ def upload_merb_file(options = {})
+ use_temp_file options[:filename] do |file|
+ att = attachment_model.create :uploaded_data => {"size" => file.size, "content_type" => options[:content_type] || 'image/png', "filename" => file, 'tempfile' => fixture_file_upload(file, options[:content_type] || 'image/png')}
+ att.reload unless att.new_record?
+ return att
+ end
+ end
+
def use_temp_file(fixture_filename)
temp_path = File.join('/tmp', File.basename(fixture_filename))
FileUtils.mkdir_p File.join(fixture_path, 'tmp')
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/History.txt
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/History.txt?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/History.txt (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/History.txt Wed Dec 10 17:34:18 2008
@@ -0,0 +1,110 @@
+=== Maintenance
+
+* 2 major enhancements
+
+ * support controller and action path params in view specs (Mike Vincent).
+ * use ActiveSupport::TestCase when available, else Test::Unit::TestCase - supports Rails 1.2.6 (Brandon Keepers). Closes #620.
+
+* 2 minor enhancements
+
+ * improve rdoc for render_template (Patch from Andrew Premdas). Fixes #571.
+ * use more liberal globs to allow for specs in symlinked dirs (Martin Luder). Closes #361.
+
+* 2 bug fixex
+
+ * Attempt to load application_controller before falling back to application (Geoff Garside). Closes #626.
+ * Include _id and reduce quoting of default values in view specs (Steen Lehmann). Closes #598.
+
+=== Version 1.1.11 / 2008-10-24
+
+* No changes to rspec-rails - release to align with bug-fix release in rspec ... again :(
+
+=== Version 1.1.10 / 2008-10-24
+
+* No changes to rspec-rails - release to align with bug-fix release in rspec
+
+=== Version 1.1.9 / 2008-10-20
+
+* 4 bug fixes
+
+ * require 'rubygems' in script/spec
+ * fix failure message for error_on and errors_on (Patch from Mike Vincent). Fixes #566.
+ * fix issues that arise in view spec if passing actual template name to render (Patch from Mike Vincent). Fixes #551.
+ * fixed bug accessing assigns from helper examples
+
+=== Version 1.1.8 / 2008-10-03
+
+* 2 bug fixes
+
+ * correctly handle assigns that are false. Fixes #552.
+ * ensure that NotYetImplemented examples report as pending (fixed in rspec, not rspec-rails). Fixes #553.
+
+=== Version 1.1.7 / 2008-10-02
+
+* 1 bug fix
+
+ * depend on the correct version of rspec
+
+=== Version 1.1.6 / 2008-10-02
+
+* 1 bug fix
+
+ * fixed regression where values assigned to the assigns hash were not accessible from the example (#549)
+
+=== Version 1.1.5 / 2008-09-28
+
+IMPORTANT: use 'script/autospec' (or just 'autospec' if you have the rspec gem
+installed) instead of 'autotest'. We changed the way autotest discovers rspec
+so the autotest executable won't automatically load rspec anymore. This allows
+rspec to live side by side other spec frameworks without always co-opting
+autotest through autotest's discovery mechanism.
+
+ALSO IMPORTANT: Rails v2.1.1 changed assert_select_rjs such that it doesn't
+always fail when it should. Please see
+http://rails.lighthouseapp.com/projects/8994/tickets/982.
+
+* Generated route specs have shorter names, making it less painful to modify their implementation
+* Add conditional so Rails 2.1.0 doesn't warn about cache_template_extensions (patch from James Herdman)
+* Fixed stub_model examples to work with Rails 2.1.0 (the code was fine, just the examples needed patching)
+* use hoe for build/release
+* reworked generated examples for rspec_scaffold - thanks to Mikel Lindsaar and Dan Manges for their feedback
+* bye, bye translator
+* Added proxy to cookies so you can set them in examples the same way you set them in controllers
+* Added script/autospec so you can run autospec without installing the gem
+* Support --skip-fixture in the rspec_model generator (patches from Alex Tomlins and Niels Ganser)
+* Add mock_model#as_new_record (patch from Zach Dennis)
+* mock(:null_object=>true) plays nice with HTML (patch from Gerrit Kaiser)
+* Suppress a deprecation notice in Rails 2.1 (James Herdman)
+* quiet deprecation warning on inflector (RSL)
+* rspec-rails gem (Ben Mabey)
+* updated generated code examples
+* Make rspec_model generator honour --skip-fixtures tag (Niels Ganser, Alex Tomlins)
+* Fix to create new models with attributes in command line (Nicolas)
+* fix to_param in mock_model with stubbed id incorrectly returning autogenerated id (Adam Meehan)
+* Call Rail's TestCase setup/teardown callbacks (Jonathan del Strother)
+* Only run TestUnitTesting once (Jonathan del Strother)
+* use require_dependency instead of require (Brandon Keepers)
+* Fixed a problem caused by controller action names getting out of sync between rspec-dev and rspec-rails for speccing (Matt Patterson)
+* don't mutate hash passed to mock_model (Reg Vos)
+
+=== Version 1.1.4
+
+Maintenance release.
+
+* Moved mock_model and stub_model to their own module: Spec::Rails::Mocks
+* Setting mock_model object id with stubs hash - patch from Adam Meehan
+* Added as_new_record to stub_model e.g. stub_model(Foo).as_new_record
+* Improved stub_model such that new_record? does "the right thing"
+* Patch from Pat Maddox to get integrate_views to work in nested example groups.
+* Patch from Pat Maddox to get controller_name to work in nested example groups.
+* Patch from Corey Haines to add include_text matcher
+* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited.
+* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320.
+* Added #helper and #assigns to helper specs.
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
+* Tweaked list of exceptions (ignores) for autotest
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
+* Allow any type of render in view specs. Closes #57.
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+* Applied patch from Jon Strother to have spec_server reload fixtures. Closes #344.
\ No newline at end of file
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/License.txt
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/License.txt?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/License.txt (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/License.txt Wed Dec 10 17:34:18 2008
@@ -0,0 +1,33 @@
+(The MIT License)
+
+====================================================================
+==== RSpec, RSpec-Rails
+Copyright (c) 2005-2008 The RSpec Development Team
+====================================================================
+==== ARTS
+Copyright (c) 2006 Kevin Clark, Jake Howerton
+====================================================================
+==== ZenTest
+Copyright (c) 2001-2006 Ryan Davis, Eric Hodel, Zen Spider Software
+====================================================================
+==== AssertSelect
+Copyright (c) 2006 Assaf Arkin
+====================================================================
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Manifest.txt
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Manifest.txt?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Manifest.txt (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Manifest.txt Wed Dec 10 17:34:18 2008
@@ -0,0 +1,161 @@
+History.txt
+License.txt
+Manifest.txt
+README.txt
+Rakefile
+UPGRADE
+generators/rspec/CHANGES
+generators/rspec/rspec_generator.rb
+generators/rspec/templates/all_stories.rb
+generators/rspec/templates/previous_failures.txt
+generators/rspec/templates/rcov.opts
+generators/rspec/templates/rspec.rake
+generators/rspec/templates/script/autospec
+generators/rspec/templates/script/spec
+generators/rspec/templates/script/spec_server
+generators/rspec/templates/spec.opts
+generators/rspec/templates/spec_helper.rb
+generators/rspec/templates/stories_helper.rb
+generators/rspec_controller/USAGE
+generators/rspec_controller/rspec_controller_generator.rb
+generators/rspec_controller/templates/controller_spec.rb
+generators/rspec_controller/templates/helper_spec.rb
+generators/rspec_controller/templates/view_spec.rb
+generators/rspec_default_values.rb
+generators/rspec_model/USAGE
+generators/rspec_model/rspec_model_generator.rb
+generators/rspec_model/templates/model_spec.rb
+generators/rspec_scaffold/rspec_scaffold_generator.rb
+generators/rspec_scaffold/templates/controller_spec.rb
+generators/rspec_scaffold/templates/edit_erb_spec.rb
+generators/rspec_scaffold/templates/helper_spec.rb
+generators/rspec_scaffold/templates/index_erb_spec.rb
+generators/rspec_scaffold/templates/new_erb_spec.rb
+generators/rspec_scaffold/templates/routing_spec.rb
+generators/rspec_scaffold/templates/show_erb_spec.rb
+init.rb
+lib/autotest/discover.rb
+lib/autotest/rails_rspec.rb
+lib/spec/rails.rb
+lib/spec/rails/example.rb
+lib/spec/rails/example/assigns_hash_proxy.rb
+lib/spec/rails/example/controller_example_group.rb
+lib/spec/rails/example/cookies_proxy.rb
+lib/spec/rails/example/functional_example_group.rb
+lib/spec/rails/example/helper_example_group.rb
+lib/spec/rails/example/model_example_group.rb
+lib/spec/rails/example/rails_example_group.rb
+lib/spec/rails/example/render_observer.rb
+lib/spec/rails/example/view_example_group.rb
+lib/spec/rails/extensions.rb
+lib/spec/rails/extensions/action_controller/base.rb
+lib/spec/rails/extensions/action_controller/rescue.rb
+lib/spec/rails/extensions/action_controller/test_response.rb
+lib/spec/rails/extensions/action_view/base.rb
+lib/spec/rails/extensions/active_record/base.rb
+lib/spec/rails/extensions/object.rb
+lib/spec/rails/extensions/spec/example/configuration.rb
+lib/spec/rails/extensions/spec/matchers/have.rb
+lib/spec/rails/interop/testcase.rb
+lib/spec/rails/matchers.rb
+lib/spec/rails/matchers/assert_select.rb
+lib/spec/rails/matchers/change.rb
+lib/spec/rails/matchers/have_text.rb
+lib/spec/rails/matchers/include_text.rb
+lib/spec/rails/matchers/redirect_to.rb
+lib/spec/rails/matchers/render_template.rb
+lib/spec/rails/mocks.rb
+lib/spec/rails/story_adapter.rb
+lib/spec/rails/version.rb
+rspec-rails.gemspec
+spec/rails/autotest/mappings_spec.rb
+spec/rails/example/assigns_hash_proxy_spec.rb
+spec/rails/example/configuration_spec.rb
+spec/rails/example/controller_isolation_spec.rb
+spec/rails/example/controller_spec_spec.rb
+spec/rails/example/cookies_proxy_spec.rb
+spec/rails/example/example_group_factory_spec.rb
+spec/rails/example/helper_spec_spec.rb
+spec/rails/example/model_spec_spec.rb
+spec/rails/example/shared_behaviour_spec.rb
+spec/rails/example/test_unit_assertion_accessibility_spec.rb
+spec/rails/example/view_spec_spec.rb
+spec/rails/extensions/action_controller_rescue_action_spec.rb
+spec/rails/extensions/action_view_base_spec.rb
+spec/rails/extensions/active_record_spec.rb
+spec/rails/interop/testcase_spec.rb
+spec/rails/matchers/assert_select_spec.rb
+spec/rails/matchers/description_generation_spec.rb
+spec/rails/matchers/errors_on_spec.rb
+spec/rails/matchers/have_text_spec.rb
+spec/rails/matchers/include_text_spec.rb
+spec/rails/matchers/redirect_to_spec.rb
+spec/rails/matchers/render_template_spec.rb
+spec/rails/matchers/should_change_spec.rb
+spec/rails/mocks/ar_classes.rb
+spec/rails/mocks/mock_model_spec.rb
+spec/rails/mocks/stub_model_spec.rb
+spec/rails/sample_modified_fixture.rb
+spec/rails/sample_spec.rb
+spec/rails/spec_server_spec.rb
+spec/rails/spec_spec.rb
+spec/rails_suite.rb
+spec/resources/controllers/action_view_base_spec_controller.rb
+spec/resources/controllers/controller_spec_controller.rb
+spec/resources/controllers/redirect_spec_controller.rb
+spec/resources/controllers/render_spec_controller.rb
+spec/resources/controllers/rjs_spec_controller.rb
+spec/resources/helpers/addition_helper.rb
+spec/resources/helpers/explicit_helper.rb
+spec/resources/helpers/more_explicit_helper.rb
+spec/resources/helpers/plugin_application_helper.rb
+spec/resources/helpers/view_spec_helper.rb
+spec/resources/views/controller_spec/_partial.rhtml
+spec/resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml
+spec/resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml
+spec/resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
+spec/resources/views/controller_spec/action_with_errors_in_template.rhtml
+spec/resources/views/controller_spec/action_with_template.rhtml
+spec/resources/views/layouts/application.rhtml
+spec/resources/views/layouts/simple.rhtml
+spec/resources/views/objects/_object.html.erb
+spec/resources/views/render_spec/_a_partial.rhtml
+spec/resources/views/render_spec/action_with_alternate_layout.rhtml
+spec/resources/views/render_spec/some_action.js.rjs
+spec/resources/views/render_spec/some_action.rhtml
+spec/resources/views/render_spec/some_action.rjs
+spec/resources/views/rjs_spec/_replacement_partial.rhtml
+spec/resources/views/rjs_spec/hide_div.rjs
+spec/resources/views/rjs_spec/hide_page_element.rjs
+spec/resources/views/rjs_spec/insert_html.rjs
+spec/resources/views/rjs_spec/replace.rjs
+spec/resources/views/rjs_spec/replace_html.rjs
+spec/resources/views/rjs_spec/replace_html_with_partial.rjs
+spec/resources/views/rjs_spec/visual_effect.rjs
+spec/resources/views/rjs_spec/visual_toggle_effect.rjs
+spec/resources/views/tag_spec/no_tags.rhtml
+spec/resources/views/tag_spec/single_div_with_no_attributes.rhtml
+spec/resources/views/tag_spec/single_div_with_one_attribute.rhtml
+spec/resources/views/view_spec/_partial.rhtml
+spec/resources/views/view_spec/_partial_used_twice.rhtml
+spec/resources/views/view_spec/_partial_with_local_variable.rhtml
+spec/resources/views/view_spec/_partial_with_sub_partial.rhtml
+spec/resources/views/view_spec/_spacer.rhtml
+spec/resources/views/view_spec/accessor.rhtml
+spec/resources/views/view_spec/block_helper.rhtml
+spec/resources/views/view_spec/entry_form.rhtml
+spec/resources/views/view_spec/explicit_helper.rhtml
+spec/resources/views/view_spec/foo/show.rhtml
+spec/resources/views/view_spec/implicit_helper.rhtml
+spec/resources/views/view_spec/multiple_helpers.rhtml
+spec/resources/views/view_spec/should_not_receive.rhtml
+spec/resources/views/view_spec/template_with_partial.rhtml
+spec/resources/views/view_spec/template_with_partial_using_collection.rhtml
+spec/resources/views/view_spec/template_with_partial_with_array.rhtml
+spec/spec_helper.rb
+stories/all.rb
+stories/configuration/stories.rb
+stories/helper.rb
+stories/steps/people.rb
+stories/transactions_should_rollback
+stories/transactions_should_rollback.rb
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/README.txt
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/README.txt?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/README.txt (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/README.txt Wed Dec 10 17:34:18 2008
@@ -0,0 +1,46 @@
+= Spec::Rails
+
+* http://rspec.info
+* http://rspec.info/rdoc-rails/
+* http://rubyforge.org/projects/rspec
+* http://github.com/dchelimsky/rspec-rails/wikis
+* mailto:rspec-devel@rubyforge.org
+
+== DESCRIPTION:
+
+Behaviour Driven Development for Ruby on Rails.
+
+Spec::Rails (a.k.a. RSpec on Rails) is a Ruby on Rails plugin that allows you
+to drive the development of your RoR application using RSpec, a framework that
+aims to enable Example Driven Development in Ruby.
+
+== FEATURES:
+
+* Use RSpec to independently specify Rails Models, Views, Controllers and Helpers
+* Integrated fixture loading
+* Special generators for Resources, Models, Views and Controllers that generate Specs instead of Tests.
+
+== VISION:
+
+For people for whom TDD is a brand new concept, the testing support built into
+Ruby on Rails is a huge leap forward. The fact that it is built right in is
+fantastic, and Ruby on Rails apps are generally much easier to maintain than
+they might have been without such support.
+
+For those of us coming from a history with TDD, and now BDD, the existing
+support presents some problems related to dependencies across examples. To
+that end, RSpec on Rails supports 4 types of examples. Weâve also built in
+first class mocking and stubbing support in order to break dependencies across
+these different concerns.
+
+== MORE INFORMATION:
+
+See Spec::Rails::Runner for information about the different kinds of example
+groups you can use to spec the different Rails components
+
+See Spec::Rails::Expectations for information about Rails-specific
+expectations you can set on responses and models, etc.
+
+== INSTALL
+
+* Visit http://github.com/dchelimsky/rspec-rails/wikis for installation instructions.
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Rakefile
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Rakefile?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Rakefile (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/Rakefile Wed Dec 10 17:34:18 2008
@@ -1,9 +1,39 @@
-require 'rake'
-require 'rake/rdoctask'
+require 'rubygems'
+require 'hoe'
+require './lib/spec/rails/version'
-desc 'Generate RDoc'
-rd = Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = '../doc/output/rdoc-rails'
- rdoc.options << '--title' << 'Spec::Rails' << '--line-numbers' << '--inline-source' << '--main' << 'Spec::Rails'
- rdoc.rdoc_files.include('MIT-LICENSE', 'lib/**/*.rb')
+class Hoe
+ def extra_deps
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
+ @extra_deps
+ end
end
+
+Hoe.new('rspec-rails', Spec::Rails::VERSION::STRING) do |p|
+ p.summary = Spec::Rails::VERSION::SUMMARY
+ p.url = 'http://rspec.info/'
+ p.description = "Behaviour Driven Development for Ruby on Rails."
+ p.rubyforge_name = 'rspec'
+ p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
+ p.extra_deps = [["rspec","1.1.11.1"]]
+ p.remote_rdoc_dir = "rspec-rails/#{Spec::Rails::VERSION::STRING}"
+end
+
+['audit','test','test_deps','default','post_blog', 'release'].each do |task|
+ Rake.application.instance_variable_get('@tasks').delete(task)
+end
+
+task :release => [:clean, :package] do |t|
+ version = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
+ abort "Versions don't match #{version} vs #{Spec::Rails::VERSION::STRING}" unless version == Spec::Rails::VERSION::STRING
+ pkg = "pkg/rspec-rails-#{version}"
+
+ rubyforge = RubyForge.new.configure
+ puts "Logging in to rubyforge ..."
+ rubyforge.login
+
+ puts "Releasing rspec-rails version #{version} ..."
+ ["#{pkg}.gem", "#{pkg}.tgz"].each do |file|
+ rubyforge.add_file('rspec', 'rspec', Spec::Rails::VERSION::STRING, file)
+ end
+end
\ No newline at end of file
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb Wed Dec 10 17:34:18 2008
@@ -6,6 +6,7 @@
Config::CONFIG['ruby_install_name'])
def initialize(runtime_args, runtime_options = {})
+ Dir.mkdir('lib/tasks') unless File.directory?('lib/tasks')
super
end
@@ -13,12 +14,16 @@
record do |m|
script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
+ m.file 'rspec.rake', 'lib/tasks/rspec.rake'
+
+ m.file 'script/autospec', 'script/autospec', script_options
+ m.file 'script/spec', 'script/spec', script_options
+ m.file 'script/spec_server', 'script/spec_server', script_options
+
m.directory 'spec'
- m.template 'spec_helper.rb', 'spec/spec_helper.rb'
- m.file 'spec.opts', 'spec/spec.opts'
m.file 'rcov.opts', 'spec/rcov.opts'
- m.file 'script/spec_server', 'script/spec_server', script_options
- m.file 'script/spec', 'script/spec', script_options
+ m.file 'spec.opts', 'spec/spec.opts'
+ m.template 'spec_helper.rb', 'spec/spec_helper.rb'
m.directory 'stories'
m.file 'all_stories.rb', 'stories/all.rb'
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/rspec.rake Wed Dec 10 17:34:18 2008
@@ -0,0 +1,153 @@
+raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec pkg]))
+raise "To avoid rake task loading problems: run 'rake clobber' in vendor/plugins/rspec-rails" if File.directory?(File.join(File.dirname(__FILE__), *%w[.. .. vendor plugins rspec-rails pkg]))
+
+# In rails 1.2, plugins aren't available in the path until they're loaded.
+# Check to see if the rspec plugin is installed first and require
+# it if it is. If not, use the gem version.
+rspec_base = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec/lib')
+$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
+
+begin
+ require 'spec/rake/spectask'
+ Rake.application.instance_variable_get('@tasks').delete('default')
+
+ spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
+ task :noop do
+ end
+
+ task :default => :spec
+ task :stats => "spec:statsetup"
+
+ desc "Run all specs in spec directory (excluding plugin specs)"
+ Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
+ end
+
+ namespace :spec do
+ desc "Run all specs in spec directory with RCov (excluding plugin specs)"
+ Spec::Rake::SpecTask.new(:rcov) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
+ t.rcov = true
+ t.rcov_opts = lambda do
+ IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
+ end
+ end
+
+ desc "Print Specdoc for all specs (excluding plugin specs)"
+ Spec::Rake::SpecTask.new(:doc) do |t|
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
+ t.spec_files = FileList['spec/**/*/*_spec.rb']
+ end
+
+ desc "Print Specdoc for all plugin examples"
+ Spec::Rake::SpecTask.new(:plugin_doc) do |t|
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
+ end
+
+ [:models, :controllers, :views, :helpers, :lib].each do |sub|
+ desc "Run the code examples in spec/#{sub}"
+ Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
+ end
+ end
+
+ desc "Run the code examples in vendor/plugins (except RSpec's own)"
+ Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
+ end
+
+ namespace :plugins do
+ desc "Runs the examples for rspec_on_rails"
+ Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
+ t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
+ t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
+ end
+ end
+
+ # Setup specs for stats
+ task :statsetup do
+ require 'code_statistics'
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
+ ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
+ ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
+ ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
+ ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
+ ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
+ ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
+ end
+
+ namespace :db do
+ namespace :fixtures do
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
+ task :load => :environment do
+ require 'active_record/fixtures'
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
+ end
+ end
+ end
+ end
+
+ namespace :server do
+ daemonized_server_pid = File.expand_path("spec_server.pid", RAILS_ROOT + "/tmp")
+
+ desc "start spec_server."
+ task :start do
+ if File.exist?(daemonized_server_pid)
+ $stderr.puts "spec_server is already running."
+ else
+ $stderr.puts "Starting up spec server."
+ system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
+ end
+ end
+
+ desc "stop spec_server."
+ task :stop do
+ unless File.exist?(daemonized_server_pid)
+ $stderr.puts "No server running."
+ else
+ $stderr.puts "Shutting down spec_server."
+ system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
+ File.delete(daemonized_server_pid)
+ end
+ end
+
+ desc "reload spec_server."
+ task :restart do
+ unless File.exist?(daemonized_server_pid)
+ $stderr.puts "No server running."
+ else
+ $stderr.puts "Reloading down spec_server."
+ system("kill", "-s", "USR2", File.read(daemonized_server_pid).strip)
+ end
+ end
+ end
+ end
+rescue MissingSourceFile
+ # if rspec-rails is a configured gem, this will output helpful material and exit ...
+ require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
+
+ # ... otherwise, do this:
+ raise <<-MSG
+
+ You have rspec-rails rake tasks installed in
+ #{__FILE__},
+ but rspec-rails is not configured as a gem in
+ config/environment.rb
+
+ Either remove #{__FILE__}
+ or configure the rspec-rails gem in config/environment.rb.
+
+MSG
+end
+
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec Wed Dec 10 17:34:18 2008
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+ENV['RSPEC'] = 'true' # allows autotest to discover rspec
+ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
+system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
+ $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec/templates/script/spec Wed Dec 10 17:34:18 2008
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
+require 'rubygems'
require 'spec'
exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_default_values.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_default_values.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_default_values.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,19 @@
+module Rails
+ module Generator
+ class GeneratedAttribute
+ def default_value
+ @default_value ||= case type
+ when :int, :integer then "1"
+ when :float then "1.5"
+ when :decimal then "9.99"
+ when :datetime, :timestamp, :time then "Time.now"
+ when :date then "Date.today"
+ when :string, :text then "\"value for #{@name}\""
+ when :boolean then "false"
+ else
+ ""
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb Wed Dec 10 17:34:18 2008
@@ -1,4 +1,5 @@
require 'rails_generator/generators/components/model/model_generator'
+require File.dirname(__FILE__) + '/../rspec_default_values'
class RspecModelGenerator < ModelGenerator
@@ -11,12 +12,16 @@
# Model, spec, and fixture directories.
m.directory File.join('app/models', class_path)
m.directory File.join('spec/models', class_path)
- m.directory File.join('spec/fixtures', class_path)
+ unless options[:skip_fixture]
+ m.directory File.join('spec/fixtures', class_path)
+ end
# Model class, spec and fixtures.
m.template 'model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
- m.template 'model:fixtures.yml', File.join('spec/fixtures', class_path, "#{table_name}.yml")
m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
+ unless options[:skip_fixture]
+ m.template 'model:fixtures.yml', File.join('spec/fixtures', "#{table_name}.yml")
+ end
unless options[:skip_migration]
m.migration_template 'model:migration.rb', 'db/migrate', :assigns => {
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_model/templates/model_spec.rb Wed Dec 10 17:34:18 2008
@@ -2,10 +2,14 @@
describe <%= class_name %> do
before(:each) do
- @<%= file_name %> = <%= class_name %>.new
+ @valid_attributes = {
+<% attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == attributes.length - 1 ? '' : ','%>
+<% end -%>
+ }
end
- it "should be valid" do
- @<%= file_name %>.should be_valid
+ it "should create a new instance given valid attributes" do
+ <%= class_name %>.create!(@valid_attributes)
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb Wed Dec 10 17:34:18 2008
@@ -1,3 +1,5 @@
+require File.dirname(__FILE__) + '/../rspec_default_values'
+
class RspecScaffoldGenerator < Rails::Generator::NamedBase
default_options :skip_migration => false
@@ -140,21 +142,6 @@
module Rails
module Generator
class GeneratedAttribute
- def default_value
- @default_value ||= case type
- when :int, :integer then "\"1\""
- when :float then "\"1.5\""
- when :decimal then "\"9.99\""
- when :datetime, :timestamp, :time then "Time.now"
- when :date then "Date.today"
- when :string then "\"MyString\""
- when :text then "\"MyText\""
- when :boolean then "false"
- else
- ""
- end
- end
-
def input_type
@input_type ||= case type
when :text then "textarea"
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb Wed Dec 10 17:34:18 2008
@@ -1,313 +1,173 @@
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
- describe "handling GET /<%= table_name %>" do
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
- <%= class_name %>.stub!(:find).and_return([@<%= file_name %>])
- end
-
- def do_get
- get :index
- end
-
- it "should be successful" do
- do_get
- response.should be_success
- end
-
- it "should render index template" do
- do_get
- response.should render_template('index')
- end
-
- it "should find all <%= table_name %>" do
- <%= class_name %>.should_receive(:find).with(:all).and_return([@<%= file_name %>])
- do_get
- end
-
- it "should assign the found <%= table_name %> for the view" do
- do_get
- assigns[:<%= table_name %>].should == [@<%= file_name %>]
- end
+ def mock_<%= file_name %>(stubs={})
+ @mock_<%= file_name %> ||= mock_model(<%= class_name %>, stubs)
end
-
- describe "handling GET /<%= table_name %>.xml" do
-
- before(:each) do
- @<%= file_name.pluralize %> = mock("Array of <%= class_name.pluralize %>", :to_xml => "XML")
- <%= class_name %>.stub!(:find).and_return(@<%= file_name.pluralize %>)
- end
-
- def do_get
- @request.env["HTTP_ACCEPT"] = "application/xml"
- get :index
- end
- it "should be successful" do
- do_get
- response.should be_success
- end
+ describe "responding to GET index" do
- it "should find all <%= table_name %>" do
- <%= class_name %>.should_receive(:find).with(:all).and_return(@<%= file_name.pluralize %>)
- do_get
- end
-
- it "should render the found <%= table_name %> as xml" do
- @<%= file_name.pluralize %>.should_receive(:to_xml).and_return("XML")
- do_get
- response.body.should == "XML"
+ it "should expose all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
+ <%= class_name %>.should_receive(:find).with(:all).and_return([mock_<%= file_name %>])
+ get :index
+ assigns[:<%= table_name %>].should == [mock_<%= file_name %>]
end
- end
-
- describe "handling GET /<%= table_name %>/1" do
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
- end
+ describe "with mime type of xml" do
- def do_get
- get :show, :id => "1"
+ it "should render all <%= table_name.pluralize %> as xml" do
+ request.env["HTTP_ACCEPT"] = "application/xml"
+ <%= class_name %>.should_receive(:find).with(:all).and_return(<%= file_name.pluralize %> = mock("Array of <%= class_name.pluralize %>"))
+ <%= file_name.pluralize %>.should_receive(:to_xml).and_return("generated XML")
+ get :index
+ response.body.should == "generated XML"
+ end
+
end
- it "should be successful" do
- do_get
- response.should be_success
- end
-
- it "should render show template" do
- do_get
- response.should render_template('show')
- end
-
- it "should find the <%= file_name %> requested" do
- <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
- do_get
- end
-
- it "should assign the found <%= file_name %> for the view" do
- do_get
- assigns[:<%= file_name %>].should equal(@<%= file_name %>)
- end
end
- describe "handling GET /<%= table_name %>/1.xml" do
+ describe "responding to GET show" do
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :to_xml => "XML")
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
- end
-
- def do_get
- @request.env["HTTP_ACCEPT"] = "application/xml"
- get :show, :id => "1"
+ it "should expose the requested <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ get :show, :id => "37"
+ assigns[:<%= file_name %>].should equal(mock_<%= file_name %>)
end
+
+ describe "with mime type of xml" do
+
+ it "should render the requested <%= file_name %> as xml" do
+ request.env["HTTP_ACCEPT"] = "application/xml"
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ mock_<%= file_name %>.should_receive(:to_xml).and_return("generated XML")
+ get :show, :id => "37"
+ response.body.should == "generated XML"
+ end
- it "should be successful" do
- do_get
- response.should be_success
- end
-
- it "should find the <%= file_name %> requested" do
- <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
- do_get
- end
-
- it "should render the found <%= file_name %> as xml" do
- @<%= file_name %>.should_receive(:to_xml).and_return("XML")
- do_get
- response.body.should == "XML"
end
+
end
- describe "handling GET /<%= table_name %>/new" do
-
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
- <%= class_name %>.stub!(:new).and_return(@<%= file_name %>)
- end
+ describe "responding to GET new" do
- def do_get
+ it "should expose a new <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.should_receive(:new).and_return(mock_<%= file_name %>)
get :new
+ assigns[:<%= file_name %>].should equal(mock_<%= file_name %>)
end
- it "should be successful" do
- do_get
- response.should be_success
- end
-
- it "should render new template" do
- do_get
- response.should render_template('new')
- end
-
- it "should create an new <%= file_name %>" do
- <%= class_name %>.should_receive(:new).and_return(@<%= file_name %>)
- do_get
- end
-
- it "should not save the new <%= file_name %>" do
- @<%= file_name %>.should_not_receive(:save)
- do_get
- end
-
- it "should assign the new <%= file_name %> for the view" do
- do_get
- assigns[:<%= file_name %>].should equal(@<%= file_name %>)
- end
end
- describe "handling GET /<%= table_name %>/1/edit" do
-
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
- end
+ describe "responding to GET edit" do
- def do_get
- get :edit, :id => "1"
+ it "should expose the requested <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ get :edit, :id => "37"
+ assigns[:<%= file_name %>].should equal(mock_<%= file_name %>)
end
- it "should be successful" do
- do_get
- response.should be_success
- end
-
- it "should render edit template" do
- do_get
- response.should render_template('edit')
- end
-
- it "should find the <%= file_name %> requested" do
- <%= class_name %>.should_receive(:find).and_return(@<%= file_name %>)
- do_get
- end
-
- it "should assign the found <%= class_name %> for the view" do
- do_get
- assigns[:<%= file_name %>].should equal(@<%= file_name %>)
- end
end
- describe "handling POST /<%= table_name %>" do
+ describe "responding to POST create" do
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :to_param => "1")
- <%= class_name %>.stub!(:new).and_return(@<%= file_name %>)
- end
-
- describe "with successful save" do
-
- def do_post
- @<%= file_name %>.should_receive(:save).and_return(true)
- post :create, :<%= file_name %> => {}
- end
-
- it "should create a new <%= file_name %>" do
- <%= class_name %>.should_receive(:new).with({}).and_return(@<%= file_name %>)
- do_post
+ describe "with valid params" do
+
+ it "should expose a newly created <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.should_receive(:new).with({'these' => 'params'}).and_return(mock_<%= file_name %>(:save => true))
+ post :create, :<%= file_name %> => {:these => 'params'}
+ assigns(:<%= file_name %>).should equal(mock_<%= file_name %>)
end
- it "should redirect to the new <%= file_name %>" do
- do_post
- response.should redirect_to(<%= table_name.singularize %>_url("1"))
+ it "should redirect to the created <%= file_name %>" do
+ <%= class_name %>.stub!(:new).and_return(mock_<%= file_name %>(:save => true))
+ post :create, :<%= file_name %> => {}
+ response.should redirect_to(<%= table_name.singularize %>_url(mock_<%= file_name %>))
end
end
- describe "with failed save" do
+ describe "with invalid params" do
- def do_post
- @<%= file_name %>.should_receive(:save).and_return(false)
- post :create, :<%= file_name %> => {}
+ it "should expose a newly created but unsaved <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.stub!(:new).with({'these' => 'params'}).and_return(mock_<%= file_name %>(:save => false))
+ post :create, :<%= file_name %> => {:these => 'params'}
+ assigns(:<%= file_name %>).should equal(mock_<%= file_name %>)
end
-
- it "should re-render 'new'" do
- do_post
+
+ it "should re-render the 'new' template" do
+ <%= class_name %>.stub!(:new).and_return(mock_<%= file_name %>(:save => false))
+ post :create, :<%= file_name %> => {}
response.should render_template('new')
end
end
+
end
- describe "handling PUT /<%= table_name %>/1" do
+ describe "responding to PUT udpate" do
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :to_param => "1")
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
- end
-
- describe "with successful update" do
-
- def do_put
- @<%= file_name %>.should_receive(:update_attributes).and_return(true)
- put :update, :id => "1"
- end
+ describe "with valid params" do
- it "should find the <%= file_name %> requested" do
- <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
- do_put
+ it "should update the requested <%= file_name %>" do
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ mock_<%= file_name %>.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, :id => "37", :<%= file_name %> => {:these => 'params'}
end
- it "should update the found <%= file_name %>" do
- do_put
- assigns(:<%= file_name %>).should equal(@<%= file_name %>)
- end
-
- it "should assign the found <%= file_name %> for the view" do
- do_put
- assigns(:<%= file_name %>).should equal(@<%= file_name %>)
+ it "should expose the requested <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => true))
+ put :update, :id => "1"
+ assigns(:<%= file_name %>).should equal(mock_<%= file_name %>)
end
it "should redirect to the <%= file_name %>" do
- do_put
- response.should redirect_to(<%= table_name.singularize %>_url("1"))
+ <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => true))
+ put :update, :id => "1"
+ response.should redirect_to(<%= table_name.singularize %>_url(mock_<%= file_name %>))
end
end
- describe "with failed update" do
+ describe "with invalid params" do
+
+ it "should update the requested <%= file_name %>" do
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ mock_<%= file_name %>.should_receive(:update_attributes).with({'these' => 'params'})
+ put :update, :id => "37", :<%= file_name %> => {:these => 'params'}
+ end
- def do_put
- @<%= file_name %>.should_receive(:update_attributes).and_return(false)
+ it "should expose the <%= file_name %> as @<%= file_name %>" do
+ <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => false))
put :update, :id => "1"
+ assigns(:<%= file_name %>).should equal(mock_<%= file_name %>)
end
- it "should re-render 'edit'" do
- do_put
+ it "should re-render the 'edit' template" do
+ <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:update_attributes => false))
+ put :update, :id => "1"
response.should render_template('edit')
end
end
- end
- describe "handling DELETE /<%= table_name %>/1" do
+ end
- before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :destroy => true)
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
- end
-
- def do_delete
- delete :destroy, :id => "1"
- end
+ describe "responding to DELETE destroy" do
- it "should find the <%= file_name %> requested" do
- <%= class_name %>.should_receive(:find).with("1").and_return(@<%= file_name %>)
- do_delete
- end
-
- it "should call destroy on the found <%= file_name %>" do
- @<%= file_name %>.should_receive(:destroy)
- do_delete
+ it "should destroy the requested <%= file_name %>" do
+ <%= class_name %>.should_receive(:find).with("37").and_return(mock_<%= file_name %>)
+ mock_<%= file_name %>.should_receive(:destroy)
+ delete :destroy, :id => "37"
end
it "should redirect to the <%= table_name %> list" do
- do_delete
+ <%= class_name %>.stub!(:find).and_return(mock_<%= file_name %>(:destroy => true))
+ delete :destroy, :id => "1"
response.should redirect_to(<%= table_name %>_url)
end
+
end
+
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb Wed Dec 10 17:34:18 2008
@@ -1,23 +1,25 @@
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
- before do
- @<%= file_name %> = mock_model(<%= class_name %>)
-<% for attribute in attributes -%>
- @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+ before(:each) do
+ assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %>,
+ :new_record? => false<%= output_attributes.empty? ? '' : ',' %>
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
- assigns[:<%= file_name %>] = @<%= file_name %>
+ )
end
it "should render edit form" do
render "/<%= table_name %>/edit.<%= default_file_extension %>"
response.should have_tag("form[action=#{<%= file_name %>_path(@<%= file_name %>)}][method=post]") do
-<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+<% for attribute in output_attributes -%>
with_tag('<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]', "<%= file_name %>[<%= attribute.name %>]")
-<% end -%><% end -%>
+<% end -%>
end
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb Wed Dec 10 17:34:18 2008
@@ -1,22 +1,28 @@
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before(:each) do
-<% [98,99].each do |id| -%>
- <%= file_name %>_<%= id %> = mock_model(<%= class_name %>)
-<% for attribute in attributes -%>
- <%= file_name %>_<%= id %>.should_receive(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
-<% end -%><% end %>
- assigns[:<%= table_name %>] = [<%= file_name %>_98, <%= file_name %>_99]
+ assigns[:<%= table_name %>] = [
+<% [1,2].each_with_index do |id, model_index| -%>
+ stub_model(<%= class_name %><%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : ',' %>
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
+<% end -%>
+<% if !output_attributes.empty? -%>
+ <%= model_index == 1 ? ')' : '),' %>
+<% end -%>
+<% end -%>
+ ]
end
it "should render list of <%= table_name %>" do
render "/<%= table_name %>/index.<%= default_file_extension %>"
-<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
- response.should have_tag("tr>td", <%= attribute.default_value %>, 2)
-<% end -%><% end -%>
+<% for attribute in output_attributes -%>
+ response.should have_tag("tr>td", <%= attribute.default_value %>.to_s, 2)
+<% end -%>
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb Wed Dec 10 17:34:18 2008
@@ -1,24 +1,25 @@
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
- @<%= file_name %>.stub!(:new_record?).and_return(true)
-<% for attribute in attributes -%>
- @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+ assigns[:<%= file_name %>] = stub_model(<%= class_name %>,
+ :new_record? => true<%= output_attributes.empty? ? '' : ',' %>
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
- assigns[:<%= file_name %>] = @<%= file_name %>
+ )
end
it "should render new form" do
render "/<%= table_name %>/new.<%= default_file_extension %>"
response.should have_tag("form[action=?][method=post]", <%= table_name %>_path) do
-<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
+<% for attribute in output_attributes -%>
with_tag("<%= attribute.input_type -%>#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
-<% end -%><% end -%>
+<% end -%>
end
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb Wed Dec 10 17:34:18 2008
@@ -2,59 +2,57 @@
describe <%= controller_class_name %>Controller do
describe "route generation" do
-
- it "should map { :controller => '<%= table_name %>', :action => 'index' } to /<%= table_name %>" do
+ it "should map #index" do
route_for(:controller => "<%= table_name %>", :action => "index").should == "/<%= table_name %>"
end
- it "should map { :controller => '<%= table_name %>', :action => 'new' } to /<%= table_name %>/new" do
+ it "should map #new" do
route_for(:controller => "<%= table_name %>", :action => "new").should == "/<%= table_name %>/new"
end
- it "should map { :controller => '<%= table_name %>', :action => 'show', :id => 1 } to /<%= table_name %>/1" do
+ it "should map #show" do
route_for(:controller => "<%= table_name %>", :action => "show", :id => 1).should == "/<%= table_name %>/1"
end
- it "should map { :controller => '<%= table_name %>', :action => 'edit', :id => 1 } to /<%= table_name %>/1<%= resource_edit_path %>" do
+ it "should map #edit" do
route_for(:controller => "<%= table_name %>", :action => "edit", :id => 1).should == "/<%= table_name %>/1<%= resource_edit_path %>"
end
- it "should map { :controller => '<%= table_name %>', :action => 'update', :id => 1} to /<%= table_name %>/1" do
+ it "should map #update" do
route_for(:controller => "<%= table_name %>", :action => "update", :id => 1).should == "/<%= table_name %>/1"
end
- it "should map { :controller => '<%= table_name %>', :action => 'destroy', :id => 1} to /<%= table_name %>/1" do
+ it "should map #destroy" do
route_for(:controller => "<%= table_name %>", :action => "destroy", :id => 1).should == "/<%= table_name %>/1"
end
end
describe "route recognition" do
-
- it "should generate params { :controller => '<%= table_name %>', action => 'index' } from GET /<%= table_name %>" do
+ it "should generate params for #index" do
params_from(:get, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "index"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'new' } from GET /<%= table_name %>/new" do
+ it "should generate params for #new" do
params_from(:get, "/<%= table_name %>/new").should == {:controller => "<%= table_name %>", :action => "new"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'create' } from POST /<%= table_name %>" do
+ it "should generate params for #create" do
params_from(:post, "/<%= table_name %>").should == {:controller => "<%= table_name %>", :action => "create"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'show', id => '1' } from GET /<%= table_name %>/1" do
+ it "should generate params for #show" do
params_from(:get, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "show", :id => "1"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'edit', id => '1' } from GET /<%= table_name %>/1;edit" do
+ it "should generate params for #edit" do
params_from(:get, "/<%= table_name %>/1<%= resource_edit_path %>").should == {:controller => "<%= table_name %>", :action => "edit", :id => "1"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'update', id => '1' } from PUT /<%= table_name %>/1" do
+ it "should generate params for #update" do
params_from(:put, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "update", :id => "1"}
end
- it "should generate params { :controller => '<%= table_name %>', action => 'destroy', id => '1' } from DELETE /<%= table_name %>/1" do
+ it "should generate params for #destroy" do
params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb Wed Dec 10 17:34:18 2008
@@ -1,22 +1,23 @@
require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
-
before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>)
-<% for attribute in attributes -%>
- @<%= file_name %>.stub!(:<%= attribute.name %>).and_return(<%= attribute.default_value %>)
+ assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %>
+<% output_attributes.each_with_index do |attribute, attribute_index| -%>
+ :<%= attribute.name %> => <%= attribute.default_value %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
+<% end -%>
+<% if !output_attributes.empty? -%>
+ )
<% end -%>
-
- assigns[:<%= file_name %>] = @<%= file_name %>
end
it "should render attributes in <p>" do
render "/<%= table_name %>/show.<%= default_file_extension %>"
-<% for attribute in attributes -%><% unless attribute.name =~ /_id/ || [:datetime, :timestamp, :time, :date].index(attribute.type) -%>
- response.should have_text(/<%= Regexp.escape(attribute.default_value)[1..-2]%>/)
-<% end -%><% end -%>
+<% for attribute in output_attributes -%>
+ response.should have_text(/<%= Regexp.escape(attribute.default_value).gsub(/^"|"$/, '')%>/)
+<% end -%>
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb Wed Dec 10 17:34:18 2008
@@ -73,9 +73,4 @@
end
class Autotest::RailsRspec < Autotest::Rspec
-
- def spec_command
- "script/spec"
- end
-
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails.rb Wed Dec 10 17:34:18 2008
@@ -1,6 +1,11 @@
silence_warnings { RAILS_ENV = "test" }
-require 'application'
+begin
+ require_dependency 'application_controller'
+rescue MissingSourceFile
+ require_dependency 'application'
+end
+
require 'action_controller/test_process'
require 'action_controller/integration'
require 'active_record/fixtures' if defined?(ActiveRecord::Base)
@@ -12,41 +17,4 @@
require 'spec/rails/mocks'
require 'spec/rails/example'
require 'spec/rails/extensions'
-require 'spec/rails/version'
-
-module Spec
- # = Spec::Rails
- #
- # Spec::Rails (a.k.a. RSpec on Rails) is a Ruby on Rails plugin that allows you to drive the development
- # of your RoR application using RSpec, a framework that aims to enable Example Driven Development
- # in Ruby.
- #
- # == Features
- #
- # * Use RSpec to independently specify Rails Models, Views, Controllers and Helpers
- # * Integrated fixture loading
- # * Special generators for Resources, Models, Views and Controllers that generate Specs instead of Tests.
- #
- # == Vision
- #
- # For people for whom TDD is a brand new concept, the testing support built into Ruby on Rails
- # is a huge leap forward. The fact that it is built right in is fantastic, and Ruby on Rails
- # apps are generally much easier to maintain than they might have been without such support.
- #
- # For those of us coming from a history with TDD, and now BDD, the existing support presents some problems related to dependencies across specs. To that end, RSpec on Rails supports 4 types of specs. Weâve also built in first class mocking and stubbing support in order to break dependencies across these different concerns.
- #
- # == More Information
- #
- # See Spec::Rails::Runner for information about the different kinds of contexts
- # you can use to spec the different Rails components
- #
- # See Spec::Rails::Expectations for information about Rails-specific expectations
- # you can set on responses and models, etc.
- #
- # == License
- #
- # RSpec on Rails is licensed under the same license as RSpec itself,
- # the MIT-LICENSE.
- module Rails
- end
-end
+require 'spec/rails/interop/testcase'
\ No newline at end of file
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example.rb Wed Dec 10 17:34:18 2008
@@ -9,6 +9,7 @@
require "spec/rails/example/controller_example_group"
require "spec/rails/example/helper_example_group"
require "spec/rails/example/view_example_group"
+require "spec/rails/example/cookies_proxy"
module Spec
module Rails
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb Wed Dec 10 17:34:18 2008
@@ -2,27 +2,24 @@
module Rails
module Example
class AssignsHashProxy #:nodoc:
- def initialize(object)
- @object = object
+ def initialize(example_group, &block)
+ @target = block.call
+ @example_group = example_group
end
- def [](ivar)
- if assigns.include?(ivar.to_s)
- assigns[ivar.to_s]
- elsif assigns.include?(ivar)
- assigns[ivar]
- else
- nil
- end
+ def [](key)
+ return false if assigns[key] == false
+ return false if assigns[key.to_s] == false
+ assigns[key] || assigns[key.to_s] || @target.instance_variable_get("@#{key}")
end
- def []=(ivar, val)
- @object.instance_variable_set "@#{ivar}", val
- assigns[ivar.to_s] = val
+ def []=(key, val)
+ @target.instance_variable_set("@#{key}", val)
end
- def delete(name)
- assigns.delete(name.to_s)
+ def delete(key)
+ assigns.delete(key.to_s)
+ @target.instance_variable_set("@#{key}", nil)
end
def each(&block)
@@ -35,7 +32,7 @@
protected
def assigns
- @object.assigns
+ @example_group.orig_assigns
end
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb Wed Dec 10 17:34:18 2008
@@ -125,7 +125,7 @@
attr_reader :response, :request, :controller
- def initialize(defined_description, &implementation) #:nodoc:
+ def initialize(defined_description, options={}, &implementation) #:nodoc:
super
controller_class_name = self.class.controller_class_name
if controller_class_name
@@ -158,7 +158,9 @@
protected
def _assigns_hash_proxy
- @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
+ @_assigns_hash_proxy ||= AssignsHashProxy.new self do
+ @response.template
+ end
end
private
@@ -183,61 +185,39 @@
unless integrate_views?
if @template.respond_to?(:finder)
(class << @template.finder; self; end).class_eval do
- define_method :file_exists? do
- true
- end
+ define_method :file_exists? do; true; end
end
else
(class << @template; self; end).class_eval do
- define_method :file_exists? do
- true
- end
+ define_method :file_exists? do; true; end
end
end
(class << @template; self; end).class_eval do
define_method :render_file do |*args|
- @first_render ||= args[0]
+ @first_render ||= args[0] unless args[0] =~ /^layouts/
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
+ end
+
+ define_method :_pick_template do |*args|
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
+ PickedTemplate.new
end
end
end
end
if matching_message_expectation_exists(options)
- expect_render_mock_proxy.render(options, &block)
+ render_proxy.render(options, &block)
@performed_render = true
else
- unless matching_stub_exists(options)
+ if matching_stub_exists(options)
+ @performed_render = true
+ else
super(options, deprecated_status_or_extra_options, &block)
end
end
end
- def raise_with_disable_message(old_method, new_method)
- raise %Q|
- controller.#{old_method}(:render) has been disabled because it
- can often produce unexpected results. Instead, you should
- use the following (before the action):
-
- controller.#{new_method}(*args)
-
- See the rdoc for #{new_method} for more information.
- |
- end
- def should_receive(*args)
- if args[0] == :render
- raise_with_disable_message("should_receive", "expect_render")
- else
- super
- end
- end
- def stub!(*args)
- if args[0] == :render
- raise_with_disable_message("stub!", "stub_render")
- else
- super
- end
- end
-
def response(&block)
# NOTE - we're setting @update for the assert_select_spec - kinda weird, huh?
@update = block
@@ -255,17 +235,25 @@
end
def matching_message_expectation_exists(options)
- expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
+ render_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
end
def matching_stub_exists(options)
- expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
+ render_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
end
end
Spec::Example::ExampleGroupFactory.register(:controller, self)
end
+
+ # Returned by _pick_template when running controller examples in isolation mode.
+ class PickedTemplate
+ # Do nothing when running controller examples in isolation mode.
+ def render_template(*ignore_args); end
+ # Do nothing when running controller examples in isolation mode.
+ def render_partial(*ignore_args); end
+ end
end
end
end
Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,25 @@
+require 'action_controller/cookies'
+
+module Spec
+ module Rails
+ module Example
+ class CookiesProxy
+ def initialize(example)
+ @example = example
+ end
+
+ def[]=(name, value)
+ @example.request.cookies[name.to_s] = CGI::Cookie.new(name.to_s, value)
+ end
+
+ def [](name)
+ @example.response.cookies[name.to_s]
+ end
+
+ def delete(name)
+ @example.response.cookies.delete(name.to_s)
+ end
+ end
+ end
+ end
+end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb Wed Dec 10 17:34:18 2008
@@ -27,6 +27,33 @@
def session
response.session
end
+
+ # Overrides the <tt>cookies()</tt> method in
+ # ActionController::TestResponseBehaviour, returning a proxy that
+ # accesses the requests cookies when setting a cookie and the
+ # responses cookies when reading one. This allows you to set and read
+ # cookies in examples using the same API with which you set and read
+ # them in controllers.
+ #
+ # == Examples (Rails >= 1.2.6)
+ #
+ # cookies[:user_id] = '1234'
+ # get :index
+ # assigns[:user].id.should == '1234'
+ #
+ # post :login
+ # cookies[:login].expires.should == 1.week.from_now
+ #
+ # == Examples (Rails >= 2.0.0 only)
+ #
+ # cookies[:user_id] = {:value => '1234', :expires => 1.minute.ago}
+ # get :index
+ # response.should be_redirect
+ def cookies
+ @cookies ||= Spec::Rails::Example::CookiesProxy.new(self)
+ end
+
+ alias_method :orig_assigns, :assigns
# :call-seq:
# assigns()
@@ -53,6 +80,7 @@
_assigns_hash_proxy[key]
end
end
+
end
end
end
Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb Wed Dec 10 17:34:18 2008
@@ -96,7 +96,11 @@
def helper
self.class.helper
end
-
+
+ def orig_assigns
+ helper.assigns
+ end
+
# Reverse the load order so that custom helpers which are defined last
# are also loaded last.
ActionView::Base.included_modules.reverse.each do |mod|
@@ -148,7 +152,9 @@
protected
def _assigns_hash_proxy
- @_assigns_hash_proxy ||= AssignsHashProxy.new helper
+ @_assigns_hash_proxy ||= AssignsHashProxy.new self do
+ helper
+ end
end
end