Open pabloh opened 11 years ago
Could you please give me some more information about what you mean. Link to a TestUnit or MiniTest example that shows what you'd like to do with Ammeter & RSpec would be great.
Thanks
There are many examples at https://github.com/rails/rails/blob/master/railties/test/generators
For example here: https://github.com/rails/rails/blob/master/railties/test/generators/model_generator_test.rb
You can see an assertion that tests file existence and its contents at the same time. Or another one that tests If a migration exists and if some method is defined inside it, also using a single assertion.
It would be nice if ammeter would allow to something like this:
file("file").should exist.and_contain(/some content/)
file("file").should be_a_migration do |contents|
contents.should have_method(:change) do |body|
body.should match(/t\.string :title/)
body.assert match(/t\.text :body/)
body.assert match(/t\.string :author/)
end
end
ok i see what you are talking about now. These would be nice to have but to be honest I'm not sure when I'll have time to get around to it.
I'd love to merge a pull request if you're inclined to add some of these :)
Something akin to assert_method was implemented in #32 but it accepts string as a second argument. I was thinking of implementing something more similar but that'd break the rspec 2.x compatibility for now.
@alexrothenberg you should think about separate branches for rspec 2.x and 3.x versions if you want this gem to keep evolving instead of just keeping it working with newer releases.
Rails provided assertions for generator tests aren't available, including them will make easier to add new matchers.