On Jun 24, 2010, at 3:05 AM, Ivo Wever wrote:
> Hey,
>
> I'm migrating an app to Rails 3 + RSpec 2 and, as expected, a number of
> specs broke. Unfortunately, I can't really find how to fix them. For
> instance, there is a spec:
>
> describe SessionsController do
> describe "route recognition" do
> it "should generate params from GET /login correctly" do
> params_from(:get, '/login').should ==
> {:controller => 'sessions', :action => 'new'}
> end
> end
Route specs work like this now:
{ :get => "/login" }.should route_to(:controller => 'sessions', :action =>
'new')
{ :put => "/widgets/1" }.should_not be_routable
This was introduced in 1.2.9, but, unfortunately, I never deprecated the way
you're doing it now. I'll do so in a 1.3.3 release, but that won't be for a
little bit, and I don't plan to forward port it to 2.x.
> This spec is located in Rails.root +
> /spec/controllers/sessions_controller_spec.rb
As of 2.0.0.beta.13, the route_to and be_routable matchers are only exposed to
routing specs (in spec/routing). I've added a github issue to add them to
controller specs as well. In the mean time, if you want to use them in your
controller specs, just do this in spec_helper.rb
RSpec.configure do |c|
c.include RSpec::Rails::RoutingSpecMatchers, :example_group => { :file_path
=> /\bspec\/controllers\// }
end
Note that the name RSpec::Rails::RoutingSpecMatchers might change in the next
beta, so this is not a formal API or anything - just a workaround for you to
get by until the next release.
HTH,
David
>
> The error is:
>
> SessionsController route recognition should generate params from POST
> /session correctly
> Failure/Error: params_from(:post, '/session').should == {:controller
> => 'sessions', :action => 'create'}
> undefined method `params_from' for
> #<RSpec::Core::ExampleGroup::Nested_15::Nested_2:0x458d348>
> #
> ./vendor/gems/actionpack-3.0.0.beta4/lib/action_dispatch/testing/assertions/routing.rb:175:in
> `method_missing'
> # ./spec/controllers/sessions_controller_spec.rb:121
>
>
> Also note the 'RSpec::Core::ExampleGroup': it seems like it doesn't
> correctly infer it should be RSpec::Rails::ControllerExampleGroup?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users