D
David Weldon
I'm just getting started with rspec. Two questions:
1) Should the rspec be in the same file as the production code? The
examples on the rspec site seem to indicate they should be in a separate
file but I wanted to double check.
2) If I use mocks, am I supposed to pass them as parameters to my
production code?
If my code looked like:
def read()
db = database.instance()
db.execute(....)
end
and I want to do a mock database connection do I have to write the
production code like:
def read(db=database.instance())
db.execute(....)
end
and then call it with read(my_mock) ?
1) Should the rspec be in the same file as the production code? The
examples on the rspec site seem to indicate they should be in a separate
file but I wanted to double check.
2) If I use mocks, am I supposed to pass them as parameters to my
production code?
If my code looked like:
def read()
db = database.instance()
db.execute(....)
end
and I want to do a mock database connection do I have to write the
production code like:
def read(db=database.instance())
db.execute(....)
end
and then call it with read(my_mock) ?