Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
caching the test results in memcache also - making for a more real-ti…
Browse files Browse the repository at this point in the history
…me interactive web app
  • Loading branch information
John Goodsen committed Nov 27, 2008
1 parent 4f76306 commit 684c82f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/rcumber.rb
Expand Up @@ -26,6 +26,14 @@ def state=(x)
Rails.cache.write("rcumber/#{uid}/state", x.to_s)
end

def last_results=(results)
@results = results
Rails.cache.write("RcumberResults_#{path}", results)
end

def last_results
@results ||= Rails.cache.read("RcumberResults_#{path}")
end

# For now, the UID is the basename w/o extension of the file: e.g. "../foo.feature" has uid =>"foo"
# TODO: FIXME: This has the limitation that you need unique cucumber filenames down the entire directory tree...
Expand Down Expand Up @@ -55,8 +63,9 @@ def run
end

def parse_test_results
return :failing if self.last_results.to_s =~/(\d+) steps failed/
return :failing if self.last_results.to_s =~/(\d+) (steps|scenarios) failed/
return :pending if self.last_results.to_s =~/(\d) (steps|scenarios) pending/
return :passing
end

def save
Expand Down
2 changes: 1 addition & 1 deletion ui/views/rcumbers/_stylesheet.html.erb
Expand Up @@ -45,7 +45,7 @@ span#state {
background: lightgreen;
}
.pending {
background: lightyellow;
background: orange;
}
.failing {
background: red;
Expand Down
2 changes: 1 addition & 1 deletion ui/views/rcumbers/index.html.erb
Expand Up @@ -20,7 +20,7 @@
<td class="<%= rcumber.state.to_s %>"><%= rcumber.state.to_s %></td>
<td>
<%= link_to 'Run', rcumber_run_path(rcumber.uid) + demo_parameters %>
<%= link_to 'View', rcumber_path(rcumber.uid) + demo_parameters %>
| <%= link_to 'View', rcumber_path(rcumber.uid) + demo_parameters %>
</td>
</tr>
<% end %>
Expand Down

0 comments on commit 684c82f

Please sign in to comment.