Skip to content

Commit

Permalink
added integration spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ludicast committed Oct 14, 2010
1 parent 332517f commit 57fece6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/generators/saki/templates/full_integration_spec.rb
@@ -0,0 +1,48 @@
require File.dirname(__FILE__) + '/acceptance_helper'
<%-
extend SchemaUtil
for_base do
resource_class = resource_name.classify.constantize
@pairs = resource_class.columns_hash.map do |key, value|
[key.to_s, value.type.to_s]
end
end
%>
integrate "<%= resource_name %> resource" do
def fill_in_<%= resource_name %>_details<%-
@pairs.each do |pair|
unless ["id", "created_at", "updated_at"].include? pair[0]
%>
fill_in "<%= resource_name %>[<%= pair[0] %>]", :with => @<%= resource_name %>.<%= pair[0] %><%-
end
end
%>
end
def has_<%= resource_name %>_details<%-
@pairs.each do |pair|
unless ["id", "created_at", "updated_at"].include? pair[0]
%>
page.should have_content(@<%= resource_name %>.<%= pair[0] %>)<%-
end
end
%>
end
on_visiting new_<%= resource_name %>_path do
it { lets_me_create_the(:<%= resource_name %>) }
it { shows_failure_on_invalid_create }
end

with_existing :<%= resource_name %> do
it { shows_in_list(:<%= resource_name %>) }

on_visiting edit_<%= resource_name %>_path do
it { lets_me_edit_the(:<%= resource_name %>) }
it { shows_failure_on_invalid_update_of(:<%= resource_name %>) }
end
end

end
2 changes: 2 additions & 0 deletions lib/saki.rb
@@ -1,6 +1,8 @@
require 'rspec/core'
require 'saki/railtie'

module Saki

module GeneralHelpers
extend ActiveSupport::Concern
def default_factory(name, opts = {})
Expand Down

0 comments on commit 57fece6

Please sign in to comment.