RUBYGEMS VERSION: 1.3.7
RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
I’m getting different results when running a Rails 3 scaffold generated
controller example depending on whether or not I run ‘rspec spec’ or
spec/controllers’. The difference occurs when evaluating the dynamic
methods with for ‘_url’, e.g. my_model_url I’m using Authlogic and
SslRequirement as well. The issue may be in either of those libraries,
only difference is how I run the spec suite. I disable the Ssl
check in the test.rb environment file.
Assume I generated the scaffold code with: “rails g scaffold scaffold”
create a “Scaffold” model.
See relevant code here: http://gist.github.com/581130
When I run ‘rspec spec/controllers’, the example in question passes. I
debug code in url_for.rb (bartt-ssl_requirement-1.2.3) to parse the
passed to url_for and they include the :host and :protocol parameters,
“test.host”, :protocol => “http://”.
When I run ‘rspec spec’, the example in question fails. The url_for
are missing both the :host and :protocol parameters. If I manully pass
into the my_model_url method, the example will pass. If I use the
version of the route method, the example passes.
The stack trace in the failing case is (path to gems directory omitted):
- ScaffoldsController POST create with valid params redirects to the
Missing host to link to! Please provide :host parameter or set
url_for_without_non_ssl_host' # .../bartt-ssl_requirement-1.2.3/lib/url_for.rb:44:inurl_for_without_secure_option’
url_for' # .../actionpack-3.0.0/lib/action_dispatch/routing/url_for.rb:132:inurl_for’
factor_library_url' # ./spec/controllers/scaffolds_controller_spec.rb:70 # .../activesupport-3.0.0/lib/active_support/dependencies.rb:239:ininject’
So, I’m stumped as to why ‘rspec spec’ is behaving differently from
spec/controllers’ with respect to generating the appropriate url_for