utensils 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +50 -4
- data/lib/utensils/custom_matchers.rb +0 -23
- data/lib/utensils/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -10,13 +10,59 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
1. Create
|
13
|
+
1. Create `spec/support/utensils.rb`
|
14
14
|
2. Add whichever bits you need:
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
require 'utensils/custom_matchers'
|
18
|
-
require 'utensils/upload_macros'
|
19
17
|
require 'utensils/capybara_extensions'
|
18
|
+
require 'utensils/custom_matchers'
|
20
19
|
require 'utensils/database_cleaner'
|
20
|
+
require 'utensils/upload_macros'
|
21
21
|
require 'utensils/vcr'
|
22
|
-
```
|
22
|
+
```
|
23
|
+
|
24
|
+
### capybara_extensions
|
25
|
+
|
26
|
+
Allows you to use active record objects with capybara finders
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
page.within(post) { click_link('Edit') }
|
30
|
+
page.find(book_2).drag_to(page.find(book_1))
|
31
|
+
```
|
32
|
+
|
33
|
+
### custom_matchers
|
34
|
+
|
35
|
+
A set of convenient matchers for rspec
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
page.should have_model(post) #looks for dom_id(post)
|
39
|
+
page.find(post).should have_class('current') #presence of html class
|
40
|
+
page.should have_image('banner.jpg') #presence of img
|
41
|
+
page.should have_image(recipe.photo) #presence of dragonfly photo
|
42
|
+
page.should have_order(recipe_3, recipe_1, recipe_2) #checks that objects are in a specific order
|
43
|
+
```
|
44
|
+
### database_cleaner
|
45
|
+
|
46
|
+
Sets up rspec to use database_cleaner instead of transactional fixtures
|
47
|
+
|
48
|
+
### upload_macros
|
49
|
+
|
50
|
+
Provides fixture_file helper pointing to spec/fixtures directory
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Photo.create(:file => 'dummy.jpg') #attaches spec/fixtures/dummy.jpg
|
54
|
+
```
|
55
|
+
|
56
|
+
### vcr
|
57
|
+
|
58
|
+
Disables all outgoing http requests except for examples marked with :allow_http, which will be cached with VCR
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
describe 'examples' do
|
62
|
+
it 'uses http cached with VCR', :allow_http do
|
63
|
+
...
|
64
|
+
end
|
65
|
+
it 'disables all outgoing http' do
|
66
|
+
...
|
67
|
+
end
|
68
|
+
end
|
@@ -23,29 +23,6 @@ module Utensils
|
|
23
23
|
HaveModel.new(model)
|
24
24
|
end
|
25
25
|
|
26
|
-
class HaveNoModel
|
27
|
-
def initialize(model)
|
28
|
-
@model_id = ApplicationController.helpers.dom_id(model)
|
29
|
-
end
|
30
|
-
|
31
|
-
def matches?(page)
|
32
|
-
@page = page
|
33
|
-
@page.has_no_css?("##{@model_id}")
|
34
|
-
end
|
35
|
-
|
36
|
-
def failure_message_for_should
|
37
|
-
"expected #{@page.body} to not contain element with id: #{@model_id}"
|
38
|
-
end
|
39
|
-
|
40
|
-
def failure_message_for_should_not
|
41
|
-
"expected #{@page.body} to contain element with id: #{@model_id}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def have_no_model(model)
|
46
|
-
HaveNoModel.new(model)
|
47
|
-
end
|
48
|
-
|
49
26
|
class HaveClass
|
50
27
|
def initialize(class_name)
|
51
28
|
@class_name = class_name
|
data/lib/utensils/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utensils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rspec stuff we use over and over again
|
15
15
|
email:
|