fixes
This commit is contained in:
parent
7b6368be02
commit
9fd95b611c
28
README.md
28
README.md
|
@ -2,6 +2,13 @@ Make your Rails Capybara testing even faster and more accurate! Looking for text
|
|||
|
||||
## Your Views
|
||||
|
||||
It's easier to find things in Capybara tests if you add extra `data` attributes to fields and such.
|
||||
This gem does that for you if you link to and refer to things in a certain way. If you do, your
|
||||
tests turn from text blob and CSS selector messes to nice, clean, simple references to objects
|
||||
and attributes.
|
||||
|
||||
### Attributes
|
||||
|
||||
Write out attributes using `attributes_for`:
|
||||
|
||||
``` haml
|
||||
|
@ -22,3 +29,24 @@ visit object_path(@object)
|
|||
find_attribute(:name, @object.name)
|
||||
find_attribute(:description, @object.description)
|
||||
```
|
||||
|
||||
You can even make simple tables, a la Active Admin:
|
||||
|
||||
``` haml
|
||||
#object
|
||||
= attributes_table_for object do |f|
|
||||
= f.field :name
|
||||
= f.field :description
|
||||
```
|
||||
|
||||
## Not Finding Things
|
||||
|
||||
Sometimes the absence of a thing is just as important as the presence of a thing. Make it easy on yourself:
|
||||
|
||||
``` ruby
|
||||
# selector's not there
|
||||
|
||||
dont_find('#user')
|
||||
|
||||
# object's not there
|
||||
```
|
||||
|
|
|
@ -2,10 +2,10 @@ require 'semantic_rails_view_helpers/view_helpers'
|
|||
|
||||
module SemanticRailsViewHelpers
|
||||
class Engine < ::Rails::Engine
|
||||
initializer 'semantic_rails_view_helpers.initialize' do |app|
|
||||
initializer 'semantic_rails_view_helpers.initialize', :before => :load_config_initializers do |app|
|
||||
ActionView::Base.send :include, SemanticRailsViewHelpers::ViewHelpers
|
||||
|
||||
app.config.add_semantic_data = false
|
||||
app.config.add_semantic_data = false if app.config.add_semantic_data.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,7 +71,7 @@ module SemanticRailsViewHelpers
|
|||
|
||||
def semantic_action_data(action)
|
||||
SemanticRailsViewHelpers.with_semantic_data do
|
||||
{ "data-action" => target_action }
|
||||
{ "data-action" => action }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,4 +14,7 @@ Gem::Specification.new do |gem|
|
|||
gem.name = "semantic_rails_view_helpers"
|
||||
gem.require_paths = ["lib"]
|
||||
gem.version = SemanticRailsViewHelpers::VERSION
|
||||
|
||||
gem.add_dependency 'capybara'
|
||||
gem.add_dependency 'rspec'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue