Jeroen van Dijk
2010-Feb-27 19:49 UTC
How to write tests for missing ''require'' in the Rails core?
When hacking on rails 3 I have discovered some missing requires. For example, when I wanted to use ActionDispatch::Integration::Session, it get an error because Test::Unit::Assertions is used but ''test/unit/ assertions'' is not required. So I have tried to build a patch for this situation. Well actually, the creation of the patch is simple, but how do you test (with test/ unit) that we can use this class without requiring its dependency ''test/unit/assertions''? To have a real test case I would need an isolated environment which would require the class, but would not require any other dependency. One thing that is hard, is that the rails test suite itself already loads a lot of necessary dependencies which would make it hard to write a failing test for these cases (see ''abstract_unit'' in actionpack/lib/test). Anyhow, when I wrote a first test case I got a chain of dependency issues so I think it is worth to investigate this, but I can''t really think of a way to include it in the current test suite. Any suggestions? Jeroen -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Yehuda Katz
2010-Feb-27 19:52 UTC
Re: How to write tests for missing ''require'' in the Rails core?
This is actually what the Isolated test case is for. You''ll see that we use it extensively in Railties specifically to isolate tests from added dependencies. Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 On Sat, Feb 27, 2010 at 11:49 AM, Jeroen van Dijk < jeroentjevandijk@gmail.com> wrote:> When hacking on rails 3 I have discovered some missing requires. For > example, when I wanted to use ActionDispatch::Integration::Session, it > get an error because Test::Unit::Assertions is used but ''test/unit/ > assertions'' is not required. > > So I have tried to build a patch for this situation. Well actually, > the creation of the patch is simple, but how do you test (with test/ > unit) that we can use this class without requiring its dependency > ''test/unit/assertions''? To have a real test case I would need an > isolated environment which would require the class, but would not > require any other dependency. One thing that is hard, is that the > rails test suite itself already loads a lot of necessary dependencies > which would make it hard to write a failing test for these cases (see > ''abstract_unit'' in actionpack/lib/test). > > Anyhow, when I wrote a first test case I got a chain of dependency > issues so I think it is worth to investigate this, but I can''t really > think of a way to include it in the current test suite. > > Any suggestions? > > Jeroen > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jeroen van Dijk
2010-Feb-27 20:48 UTC
Re: How to write tests for missing ''require'' in the Rails core?
Thanks for pointing me to that file. I guess I should use require "activesupport/lib/active_support/testing/isolation" and use railties/ test/isolation/abstract_unit.rb as an example. I was thinking of creating the file actionpack/test/dependency_test.rb that will test all dependencies for actionpack. This file would have tests like: test "require ActionDispatch::Integration::Session" do require ''action_dispatch/testing/integration'' ActionDispatch::Integration::Session end Do you think that''s the way to go? Jeroen On Feb 27, 8:52 pm, Yehuda Katz <wyc...@gmail.com> wrote:> This is actually what the Isolated test case is for. You''ll see that we use > it extensively in Railties specifically to isolate tests from added > dependencies. > > Yehuda Katz > Developer | Engine Yard > (ph) 718.877.1325 > > On Sat, Feb 27, 2010 at 11:49 AM, Jeroen van Dijk < > > jeroentjevand...@gmail.com> wrote: > > When hacking on rails 3 I have discovered some missing requires. For > > example, when I wanted to use ActionDispatch::Integration::Session, it > > get an error because Test::Unit::Assertions is used but ''test/unit/ > > assertions'' is not required. > > > So I have tried to build a patch for this situation. Well actually, > > the creation of the patch is simple, but how do you test (with test/ > > unit) that we can use this class without requiring its dependency > > ''test/unit/assertions''? To have a real test case I would need an > > isolated environment which would require the class, but would not > > require any other dependency. One thing that is hard, is that the > > rails test suite itself already loads a lot of necessary dependencies > > which would make it hard to write a failing test for these cases (see > > ''abstract_unit'' in actionpack/lib/test). > > > Anyhow, when I wrote a first test case I got a chain of dependency > > issues so I think it is worth to investigate this, but I can''t really > > think of a way to include it in the current test suite. > > > Any suggestions? > > > Jeroen > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Yehuda Katz
2010-Feb-27 22:28 UTC
Re: Re: How to write tests for missing ''require'' in the Rails core?
I think a better approach would be testing each module in isolation for its intended purpose. So in other words, try JUST pulling in Rendering into a Metal and see that it actually can support all the rendering cases in the Rendering module. Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 On Sat, Feb 27, 2010 at 12:48 PM, Jeroen van Dijk < jeroentjevandijk@gmail.com> wrote:> Thanks for pointing me to that file. I guess I should use require > "activesupport/lib/active_support/testing/isolation" and use railties/ > test/isolation/abstract_unit.rb as an example. > > I was thinking of creating the file actionpack/test/dependency_test.rb > that will test all dependencies for actionpack. This file would have > tests like: > > test "require ActionDispatch::Integration::Session" do > require ''action_dispatch/testing/integration'' > ActionDispatch::Integration::Session > end > > Do you think that''s the way to go? > > Jeroen > > On Feb 27, 8:52 pm, Yehuda Katz <wyc...@gmail.com> wrote: > > This is actually what the Isolated test case is for. You''ll see that we > use > > it extensively in Railties specifically to isolate tests from added > > dependencies. > > > > Yehuda Katz > > Developer | Engine Yard > > (ph) 718.877.1325 > > > > On Sat, Feb 27, 2010 at 11:49 AM, Jeroen van Dijk < > > > > jeroentjevand...@gmail.com> wrote: > > > When hacking on rails 3 I have discovered some missing requires. For > > > example, when I wanted to use ActionDispatch::Integration::Session, it > > > get an error because Test::Unit::Assertions is used but ''test/unit/ > > > assertions'' is not required. > > > > > So I have tried to build a patch for this situation. Well actually, > > > the creation of the patch is simple, but how do you test (with test/ > > > unit) that we can use this class without requiring its dependency > > > ''test/unit/assertions''? To have a real test case I would need an > > > isolated environment which would require the class, but would not > > > require any other dependency. One thing that is hard, is that the > > > rails test suite itself already loads a lot of necessary dependencies > > > which would make it hard to write a failing test for these cases (see > > > ''abstract_unit'' in actionpack/lib/test). > > > > > Anyhow, when I wrote a first test case I got a chain of dependency > > > issues so I think it is worth to investigate this, but I can''t really > > > think of a way to include it in the current test suite. > > > > > Any suggestions? > > > > > Jeroen > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Core" group. > > > To post to this group, send email to rubyonrails-core@googlegroups.com > . > > > To unsubscribe from this group, send email to > > > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > <rubyonrails-core%2Bunsubscribe@googlegroups.com<rubyonrails-core%252Bunsubscribe@googlegroups.com> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com<rubyonrails-core%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Gregory Dickson
2010-Feb-27 23:19 UTC
Re: Re: How to write tests for missing ''require'' in the Rails core?
I was starting on a fix to https://rails.lighthouseapp.com/projects/8994/tickets/3193-rails-234-json-gem-to_json-issue and had looked at the to_json code in 2.3.3, 2.3.4, 2.3.5 and 3.0.0beta1. It seems that the json functionality is migrating from ActiveRecord to ActiveModel in rails 3 and I am having a hard time understanding how I should patch 2.3.5 to work when 3.0.0beta1 is changing the json functionality. I have code that works for my application locally but still need to find the right place to put this patch in 2.3.5. This will be my first contribution to rails and I need a little mentoring. Anyone out there been working on the json stuff? Thanks Gregg -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.