Module: Saki::AcceptanceHelpers::ClassMethods
- Defined in:
- lib/saki.rb
Instance Method Summary collapse
- #add_opts(link, opts, context) ⇒ Object
- #create_path_for(resource, opts = {}) ⇒ Object
- #edit_path_for(resource, opts = {}) ⇒ Object
- #index_path_for(resource, opts = {}) ⇒ Object
- #on_following_link_to(path, &block) ⇒ Object
- #on_visiting(path, &block) ⇒ Object
- #show_path_for(resource, opts = {}) ⇒ Object
- #visiting_path(path, &block) ⇒ Object
Instance Method Details
#add_opts(link, opts, context) ⇒ Object
234 235 236 237 238 239 240 |
# File 'lib/saki.rb', line 234 def add_opts(link, opts, context) if opts[:parent] "/#{opts[:parent].to_s.pluralize}/#{(context.instance_variable_get('@' + opts[:parent].to_s)).id}" + link else link end end |
#create_path_for(resource, opts = {}) ⇒ Object
254 255 256 257 258 |
# File 'lib/saki.rb', line 254 def create_path_for(resource, opts = {}) lambda do |context| add_opts "/#{resource.to_s.pluralize}/new", opts, context end end |
#edit_path_for(resource, opts = {}) ⇒ Object
242 243 244 245 246 |
# File 'lib/saki.rb', line 242 def edit_path_for(resource, opts = {}) lambda do |context| add_opts "/#{resource.to_s.pluralize}/#{(context.instance_variable_get('@' + resource.to_s)).id}/edit", opts, context end end |
#index_path_for(resource, opts = {}) ⇒ Object
260 261 262 263 264 |
# File 'lib/saki.rb', line 260 def index_path_for(resource, opts = {}) lambda do |context| add_opts "/#{resource.to_s.pluralize}", opts, context end end |
#on_following_link_to(path, &block) ⇒ Object
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/saki.rb', line 204 def on_following_link_to path, &block context "on following link" do before do path = get_path(path) has_link(path) visit path end module_eval &block end end |
#on_visiting(path, &block) ⇒ Object
215 216 217 218 219 220 221 222 |
# File 'lib/saki.rb', line 215 def on_visiting path, &block context "on visiting" do before do visit get_path(path) end module_eval &block end end |
#show_path_for(resource, opts = {}) ⇒ Object
248 249 250 251 252 |
# File 'lib/saki.rb', line 248 def show_path_for(resource, opts = {}) lambda do |context| add_opts "/#{resource.to_s.pluralize}/#{(context.instance_variable_get('@' + resource.to_s)).id}", opts, context end end |
#visiting_path(path, &block) ⇒ Object
224 225 226 227 228 229 230 231 |
# File 'lib/saki.rb', line 224 def visiting_path path, &block context "on visiting" do before do visit (instance_eval &path) end module_eval &block end end |