I have a unit test (example is modified Test::Unit documentation)
require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
def test_something
assert(true)
end
end
When I execute it, I get:
Loaded suite C:/test
Started
.
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
I would like to get something li...
I'm trying to set up Factory Girl with Test::Unit and Shoulda in Ruby on Rails. I have installed the gem, created my factory file under the test/factories directory, and created my spec file under the test/models directory. The current error I'm getting is 'ArgumentError: No such factory: test', which leads me to believe that the test_fa...
I'm trying to write code like this:
assert_throws(:ExtractionFailed) { unit.extract_from('5 x 2005')}
ExtractionFailed is a trivial subclass of Exception, and under test/unit, I'm trying to assert that it is thrown when I call unit.extract_from(... bad data...)
I've moved ExtractionFailed into the SemanticText module, so now test/un...
My gem semantictext has a bunch of test data that it reads for regression testing.
Here's the project: http://github.com/dafydd/semantictext
Here's an example test that I want to be able to run directly from the gem: http://github.com/dafydd/semantictext/blob/master/test/test%5Fdocument.rb (look for text "SANDBOX")
I normally develop...
Hi,
At the minute all my fixtures have the same name as the table that they are intended for, because of a recent issue with rails it doesn't seem possible to have a fixture beginning with the word 'test'
Does anyone know of a way to have a different fixture name and then map it to the correct table?
Thanks,
Andy
...
I have a shoulda macro/method that tests controller responses for XPath conditions like so:
def self.should_have_xpath(path, &block)
should "have an element matching the path: #{path}" do
xml = REXML::Document.new @response.body
match = XPath.match(xml, path)
if block_given?
yield match
else
assert match.si...
I'm using Test::Unit::TestCase to write some unit tests. Currently, I have a setup function that moves and modifies some fixture files and folders on disk. (This is a necessary evil at the moment.) If a test crashes, the teardown method doesn't get called, leaving files and folders in the way. The next time I run a test, it complains...
I have a route which I'm using constraints to check the host and then a route which is essentially the same but without the host restriction (these are really namespaces but to make things simple this example will do):
match "/(:page_key)" => "namespace_one/pages#show", :constraints => proc {|env| env['SERVER_NAME'] == 'test.mysite.loc...
What command line options are available if you're using the Test::Unit compatibility layer in ruby 1.9.1?
Background:
ruby test/test_all.rb --help
provides information on what command line options are available in ruby 1.8.7, but not in ruby 1.9.1 without the test-unit gem. Looking under Test and Test::Unit for ruby 1.9.1 rdoc doesn'...
I am using Clearance for authentication with my rails app which works. But now all my unit tests fail because they redirect to the sign in page, which makes sense. Clearance seems to have helper functions for fixing that but I can only find them for Shoulda. Are there equivalent helpers for Test::Unit?
...
With test/unit, and minitest, is it possible to fail any test that doesn't contain an assertion, or would monkey-patching be required (for example, checking if the assertion count increased after each test was executed)?
Background: I shouldn't write unit tests without assertions - at a minimum, I should use assert_nothing_raised if I'm...
I'm new to testing strategies and mocking, and I'm having a tough time figuring out how to mock a call to an external service. I'm sure it's something easy I'm missing, I just don't know what exactly.
I'm using the Braintree gem to charge for subscription services through the Braintree gateway, and I wanted to mock the Customer create ...
Has anyone seen this? Here's the error:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -rrubygems -e "require 'redgreen'" -I.:lib:test -rubygems -e "['test/unit', 'test/test_authentication.rb'].each { |f| require f }" | /Library/Ruby/Gems/1.8/gems/autotest-4.3.2/bin/unit_diff -u
Load/Library/Ruby/Gems/1.8/gems/moch...
I have some thinking-sphinx tests that I need to turn off transactions for to prevent mysql locks, but in doing so I break a lot of other tests previously written, so I need to be able to toggle the setting.
I have found similar questions regarding rspec, but none for Test::Unit.
I have tried self.use_transactional_fixtures = false whi...