Hi David,

You make a good point. I was talking with a coworker about this
problem, and he suggested a simpler format, that I think will coincide
some with Wincent's thoughts. Here is my next stab
(http://gist.github.com/466064):
describe "routing" do
  it "recognizes and generates #index" do
    get("/days").should have_routing('days#index')
  end

  it "generates #index" do
    get("/days").should generate('days#index')
  end

  it "recognizes #index" do
    ('days#index').should recognize get("/days")
  end

  describe "nested in students" do
    it "recognizes #index" do
      ('days#index').with(:student_id => "1").should recognize
get("/students/1/days")
    end
  end
end

Notes:
- I am using have_routing, recognize, and generate because those are
the verbs used in Rails for the functions we are wrapping.
- I like using the word "with" to represent "extras," in the Rails API
(see 
http://edgeapi.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html),
since I think it fits here, and we already use with in RSpec in other
places (like stubs, etc.).
- I like using get('path') since it is similar to the routing calls in
the Rails 3 route file, and I think it is easy to intuit.
- We can use the hash notation to conform to Rails 3, with an option
to provide a full hash as well (Rails 2 style).
- The format still reads like English, and using "have_routing"
instead of "routes_to" avoids the "_to" and "_from" problem that we
have been talking about, PLUS it makes it easier to draw a
relationship between the RSpec command and the Test::Unit command
(assert_routing).
- Using these verbs still allow "should_not" to make sense.

Thoughts,
Trevor

On Tue, Jul 6, 2010 at 9:14 AM, David Chelimsky <dchelim...@gmail.com> wrote:
> Hey Trevor,
>
> These are all great DSL ideas, but they strike me as being sufficiently 
> different from anything else in either RSpec or Rails that it would be for 
> confusing for users.
>
> Do you have any thoughts on the other proposals?
>
> Cheers,
> David

-- 
Trevor Lalish-Menagh
484.868.6150 mobile
t...@trevreport.org
http://www.trevmex.com/
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to