Permalink
Browse files

Update README.

  • Loading branch information...
1 parent 5e93406 commit 946fb539cc3977a356c01a6d84ece7a207f7f3fb Winston Teo committed Mar 21, 2012
Showing with 33 additions and 1 deletion.
  1. +33 −1 README.md
View
@@ -15,14 +15,18 @@ Install the Cactus gem manually or include it in your Rails Gemfile.
gem install cactus
+Add jQuery to application.js (or any manifest file)
+
+ //= require jquery
+
Add the Cactus helper in your application layout, just before the `body` closing tag.
<%= cactus %>
Finally, add some CSS specs (written in JavaScript) in `public/cactus_spec`. Files need to end with spec.js.
Cactus.expect(".header", "font-size").toEqual("24px");
- Cactus.expectEvery("p", "font-size").toEqual("12px");
+ Cactus.expect("p", "font-size").toEqual("12px");
## A Brief Explanation
@@ -66,6 +70,34 @@ This tests for partial equality, using a REGEX constructed from the pass in valu
This tests for total equality, by converting rgba values returned by browser into hex values.
+## Automating
+
+With RSpec and Capybara (Selenium webdriver), it's possible to automate the Cactus tests by writing request specs.
+
+Add the following RSpec matcher to `spec/spec_helper.rb`:
+
+ RSpec::Matchers.define :be_cactus do
+ match do |actual|
+ all(".cactus_fail").blank?
+ end
+
+ failure_message_for_should do |actual|
+ message = "Oei! Something is wrong with the CSS on '#{actual.current_url}' lah!\n"
+ all(".cactus_fail").each do |failure|
+ message += "- #{failure.text}\n"
+ end
+ message
+ end
+ end
+
+Write a request spec `spec/requests/cactus_spec.rb`
+
+ describe 'rspec and capybara integration with cactus', js: true do
+ it "is cactus-ready " do
+ page.should be_cactus
+ end
+ end
+
## Support
- Google Groups?
- CI?

0 comments on commit 946fb53

Please sign in to comment.