Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Readme: Testing with rspec. #12

Closed
wants to merge 1 commit into from

2 participants

@sadfuzzy

No description provided.

@ledermann
Owner

Hm, thanks for your work, but I don't like the idea of testing gem features in the application. The gem already includes some tests, so there is no need to test it in the application again.

@ledermann ledermann closed this
@sadfuzzy

The idea is not to test the Gem, but to overcome the bug of not created/assumed read marks.
When you create factories with dependent model, that acts_as_unread, the read marks are not created if gap between created_at times is less than 0.002sec (if i'm not mistaken).

This fix helps to figure this out and make your test pass every time you run it.

@sadfuzzy

Do you agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2012
  1. @sadfuzzy

    Readme: Testing with rspec.

    sadfuzzy authored
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 0 deletions.
  1. +26 −0 README.md
View
26 README.md
@@ -138,6 +138,32 @@ AND messages.created_at > '2010-10-20 08:50:00'
Hint: You should add a database index on `messages.created_at`.
+## Testing
+
+### Rspec
+
+In your tests you will need unread_macros.rb file to fake wait a second after creating an instance, that acts_as_unread:
+
+```ruby
+module UnreadMacros
+ def wait
+ # Skip one second
+ now = Time.now + 1.second
+ Time.stubs(:now).returns(now)
+ end
+end
+```
+
+Place it in your spec/support directory and modify spec_helper.rb file:
+
+```ruby
+RSpec.configure do |config|
+ ...
+
+ config.include UnreadMacros
+end
+```
+
## Similar tools
There are two other gems/plugins doing a similar job:
Something went wrong with that request. Please try again.