spec/spec_helper.rb in formal-0.0.3 vs spec/spec_helper.rb in formal-1.0.1
- old
+ new
@@ -1,12 +1,11 @@
require 'action_view'
require 'active_model'
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/formal'))
-require 'formal'
-class Post < Struct.new(:body, :published)
+class TestValid < Struct.new(:body)
extend ActiveModel::Naming
include ActiveModel::Conversion
def persisted?
false
@@ -15,42 +14,43 @@
def errors
{}
end
end
-class InvalidPost < Struct.new(:body, :title)
+class TestInvalid < Struct.new(:body)
extend ActiveModel::Naming
include ActiveModel::Conversion
def persisted?
false
end
def errors
- { :body => ["can't be blank"] }
+ { :body => ["ERROR"] }
end
end
+def fixture_locale(local_name)
+ File.expand_path("../fixtures/locales/#{local_name}.yml", __FILE__)
+end
+
module FormalSpecHelper
include ActionView::Context if defined?(ActionView::Context)
include ActionController::RecordIdentifier
include ActionView::Helpers::FormHelper
- def posts_path(*args)
- "/posts"
+ def path(*args)
+ "/test_path"
end
- alias :invalid_posts_path :posts_path
+ alias :test_invalids_path :path
+ alias :test_valids_path :path
def protect_against_forgery?
false
end
def with_builder(model = Post.new)
- @output = form_for(model, builder: Formal::Builder) do |f|
+ @output = form_for(model, builder: Formal::FormBuilder) do |f|
yield f
end
- end
-
- def output
- @output
end
end