forms-spec 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
 - data/.gitignore +21 -0
 - data/.rspec +1 -0
 - data/LICENSE +20 -0
 - data/README.markdown +71 -0
 - data/Rakefile +17 -0
 - data/VERSION +1 -0
 - data/forms-spec.gemspec +76 -0
 - data/lib/forms-spec/erb/base.rb +4 -0
 - data/lib/forms-spec/erb/code-stripper.rb +31 -0
 - data/lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb +62 -0
 - data/lib/forms-spec/erb/matchers/rails_view/have_form.rb +26 -0
 - data/lib/forms-spec/erb/matchers/rails_view/helpers/links.rb +21 -0
 - data/lib/forms-spec/erb/matchers/rails_view/helpers/options.rb +30 -0
 - data/lib/forms-spec/erb/matchers/rails_view/helpers/tags.rb +30 -0
 - data/lib/forms-spec/erb/matchers/simpleform/have_simpleform.rb +47 -0
 - data/lib/forms-spec.rb +4 -0
 - data/spec/forms-spec/erb/code-stripper_spec.rb +15 -0
 - data/spec/forms-spec/erb/matchers/formtastic/have_formtastic_spec.rb +18 -0
 - data/spec/forms-spec/erb/matchers/rails_view/have_form_spec.rb +22 -0
 - data/spec/forms-spec/erb/matchers/simpleform/have_simpleform_spec.rb +22 -0
 - data/spec/forms-spec/fixtures/erb/formtastic-ex1.erb +28 -0
 - data/spec/forms-spec/fixtures/erb/railsform-ex1.erb +19 -0
 - data/spec/forms-spec/fixtures/erb/simpleform-ex1.erb +17 -0
 - data/spec/forms-spec/fixtures/erb/view-file.erb +14 -0
 - data/spec/spec_helper.rb +14 -0
 - metadata +125 -0
 
    
        data/.document
    ADDED
    
    
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --color
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2009 Kristian Mandrup
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README.markdown
    ADDED
    
    | 
         @@ -0,0 +1,71 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Forms spec
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Assists in writing RSpec 2 expectations for Rails view code that include web form logic. 
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Template languages
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Currently there is support for the following template languages:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            * erb
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ## Rails form helper DSLs
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Currently there is support for the following Rails form helper DSLs:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            * Standard Rails forms
         
     | 
| 
      
 16 
     | 
    
         
            +
            * Simpleform
         
     | 
| 
      
 17 
     | 
    
         
            +
            * Formtastic 
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Install
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            <code>gem install forms-spec</code>
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ### Main gem dependencies
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            * code-spec
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Use the method \#erb_code to extract only the ERB code from a view. 
         
     | 
| 
      
 30 
     | 
    
         
            +
            You want to ignore all the static in the view!
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            <pre>
         
     | 
| 
      
 33 
     | 
    
         
            +
            require 'forms-spec'
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            describe 'Formtastic form matcher' do      
         
     | 
| 
      
 36 
     | 
    
         
            +
              with_form_helper :formtastic
         
     | 
| 
      
 37 
     | 
    
         
            +
              
         
     | 
| 
      
 38 
     | 
    
         
            +
              context "Formtastic example 1 view file" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                let(:form_file) { File.join erb_fixtures_dir, 'formtastic-ex1.erb' }
         
     | 
| 
      
 40 
     | 
    
         
            +
                
         
     | 
| 
      
 41 
     | 
    
         
            +
                it "content should match form expectations" do      
         
     | 
| 
      
 42 
     | 
    
         
            +
                  form_file.should have_content do |content|
         
     | 
| 
      
 43 
     | 
    
         
            +
                    content.erb_code.should have_semantic_form_for '@article' do |form|
         
     | 
| 
      
 44 
     | 
    
         
            +
                      form.should have_inputs "Basic"
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            </pre>   
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            ## TODO
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            * Add support for HAML template language
         
     | 
| 
      
 57 
     | 
    
         
            +
            * Create more comprehensive test suite
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            == Note on Patches/Pull Requests
         
     | 
| 
      
 60 
     | 
    
         
            +
             
         
     | 
| 
      
 61 
     | 
    
         
            +
            * Fork the project.
         
     | 
| 
      
 62 
     | 
    
         
            +
            * Make your feature addition or bug fix.
         
     | 
| 
      
 63 
     | 
    
         
            +
            * Add tests for it. This is important so I don't break it in a
         
     | 
| 
      
 64 
     | 
    
         
            +
              future version unintentionally.
         
     | 
| 
      
 65 
     | 
    
         
            +
            * Commit, do not mess with rakefile, version, or history.
         
     | 
| 
      
 66 
     | 
    
         
            +
              (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
         
     | 
| 
      
 67 
     | 
    
         
            +
            * Send me a pull request. Bonus points for topic branches.
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            == Copyright
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'jeweler'
         
     | 
| 
      
 3 
     | 
    
         
            +
              Jeweler::Tasks.new do |gem|
         
     | 
| 
      
 4 
     | 
    
         
            +
                gem.name = "forms-spec"
         
     | 
| 
      
 5 
     | 
    
         
            +
                gem.summary = %Q{Assists in verifying your static web forms code structure}
         
     | 
| 
      
 6 
     | 
    
         
            +
                gem.description = %Q{Adds RSpec 2 matchers to make expectations about your view code containing form logic}
         
     | 
| 
      
 7 
     | 
    
         
            +
                gem.email = "kmandrup@gmail.com"
         
     | 
| 
      
 8 
     | 
    
         
            +
                gem.homepage = "http://github.com/kristianmandrup/forms-spec"
         
     | 
| 
      
 9 
     | 
    
         
            +
                gem.authors = ["Kristian Mandrup"]
         
     | 
| 
      
 10 
     | 
    
         
            +
                gem.add_development_dependency  "rspec",        ">= 2.0.0.beta.19"
         
     | 
| 
      
 11 
     | 
    
         
            +
                gem.add_dependency              "require_all",  ">= 1.1.0"    
         
     | 
| 
      
 12 
     | 
    
         
            +
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              Jeweler::GemcutterTasks.new
         
     | 
| 
      
 15 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 16 
     | 
    
         
            +
              puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/VERSION
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            0.1.0
         
     | 
    
        data/forms-spec.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Generated by jeweler
         
     | 
| 
      
 2 
     | 
    
         
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
         
     | 
| 
      
 4 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name = %q{forms-spec}
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.1.0"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors = ["Kristian Mandrup"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2010-08-18}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Adds RSpec 2 matchers to make expectations about your view code containing form logic}
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.email = %q{kmandrup@gmail.com}
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.extra_rdoc_files = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "LICENSE",
         
     | 
| 
      
 17 
     | 
    
         
            +
                 "README.markdown"
         
     | 
| 
      
 18 
     | 
    
         
            +
              ]
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.files = [
         
     | 
| 
      
 20 
     | 
    
         
            +
                ".document",
         
     | 
| 
      
 21 
     | 
    
         
            +
                 ".gitignore",
         
     | 
| 
      
 22 
     | 
    
         
            +
                 ".rspec",
         
     | 
| 
      
 23 
     | 
    
         
            +
                 "LICENSE",
         
     | 
| 
      
 24 
     | 
    
         
            +
                 "README.markdown",
         
     | 
| 
      
 25 
     | 
    
         
            +
                 "Rakefile",
         
     | 
| 
      
 26 
     | 
    
         
            +
                 "VERSION",
         
     | 
| 
      
 27 
     | 
    
         
            +
                 "forms-spec.gemspec",
         
     | 
| 
      
 28 
     | 
    
         
            +
                 "lib/forms-spec.rb",
         
     | 
| 
      
 29 
     | 
    
         
            +
                 "lib/forms-spec/erb/base.rb",
         
     | 
| 
      
 30 
     | 
    
         
            +
                 "lib/forms-spec/erb/code-stripper.rb",
         
     | 
| 
      
 31 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb",
         
     | 
| 
      
 32 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/rails_view/have_form.rb",
         
     | 
| 
      
 33 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/rails_view/helpers/links.rb",
         
     | 
| 
      
 34 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/rails_view/helpers/options.rb",
         
     | 
| 
      
 35 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/rails_view/helpers/tags.rb",
         
     | 
| 
      
 36 
     | 
    
         
            +
                 "lib/forms-spec/erb/matchers/simpleform/have_simpleform.rb",
         
     | 
| 
      
 37 
     | 
    
         
            +
                 "spec/forms-spec/erb/code-stripper_spec.rb",
         
     | 
| 
      
 38 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/formtastic/have_formtastic_spec.rb",
         
     | 
| 
      
 39 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/rails_view/have_form_spec.rb",
         
     | 
| 
      
 40 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/simpleform/have_simpleform_spec.rb",
         
     | 
| 
      
 41 
     | 
    
         
            +
                 "spec/forms-spec/fixtures/erb/formtastic-ex1.erb",
         
     | 
| 
      
 42 
     | 
    
         
            +
                 "spec/forms-spec/fixtures/erb/railsform-ex1.erb",
         
     | 
| 
      
 43 
     | 
    
         
            +
                 "spec/forms-spec/fixtures/erb/simpleform-ex1.erb",
         
     | 
| 
      
 44 
     | 
    
         
            +
                 "spec/forms-spec/fixtures/erb/view-file.erb",
         
     | 
| 
      
 45 
     | 
    
         
            +
                 "spec/spec_helper.rb"
         
     | 
| 
      
 46 
     | 
    
         
            +
              ]
         
     | 
| 
      
 47 
     | 
    
         
            +
              s.homepage = %q{http://github.com/kristianmandrup/forms-spec}
         
     | 
| 
      
 48 
     | 
    
         
            +
              s.rdoc_options = ["--charset=UTF-8"]
         
     | 
| 
      
 49 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 50 
     | 
    
         
            +
              s.rubygems_version = %q{1.3.7}
         
     | 
| 
      
 51 
     | 
    
         
            +
              s.summary = %q{Assists in verifying your static web forms code structure}
         
     | 
| 
      
 52 
     | 
    
         
            +
              s.test_files = [
         
     | 
| 
      
 53 
     | 
    
         
            +
                "spec/forms-spec/erb/code-stripper_spec.rb",
         
     | 
| 
      
 54 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/formtastic/have_formtastic_spec.rb",
         
     | 
| 
      
 55 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/rails_view/have_form_spec.rb",
         
     | 
| 
      
 56 
     | 
    
         
            +
                 "spec/forms-spec/erb/matchers/simpleform/have_simpleform_spec.rb",
         
     | 
| 
      
 57 
     | 
    
         
            +
                 "spec/spec_helper.rb"
         
     | 
| 
      
 58 
     | 
    
         
            +
              ]
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              if s.respond_to? :specification_version then
         
     | 
| 
      
 61 
     | 
    
         
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
      
 62 
     | 
    
         
            +
                s.specification_version = 3
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
      
 65 
     | 
    
         
            +
                  s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
         
     | 
| 
      
 66 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<require_all>, [">= 1.1.0"])
         
     | 
| 
      
 67 
     | 
    
         
            +
                else
         
     | 
| 
      
 68 
     | 
    
         
            +
                  s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
         
     | 
| 
      
 69 
     | 
    
         
            +
                  s.add_dependency(%q<require_all>, [">= 1.1.0"])
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
              else
         
     | 
| 
      
 72 
     | 
    
         
            +
                s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
         
     | 
| 
      
 73 
     | 
    
         
            +
                s.add_dependency(%q<require_all>, [">= 1.1.0"])
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Code
         
     | 
| 
      
 3 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_accessor :debug
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  def debug?
         
     | 
| 
      
 7 
     | 
    
         
            +
                    debug
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
                
         
     | 
| 
      
 11 
     | 
    
         
            +
                def self.get_code code
         
     | 
| 
      
 12 
     | 
    
         
            +
                  puts code if debug?
         
     | 
| 
      
 13 
     | 
    
         
            +
                  erb = code.scan(/<%-?=?\s*(.*?)\s*-?%>/).flatten.join "\n"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  puts erb if debug?
         
     | 
| 
      
 15 
     | 
    
         
            +
                  erb
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            class String
         
     | 
| 
      
 21 
     | 
    
         
            +
              def erb_code  
         
     | 
| 
      
 22 
     | 
    
         
            +
                Erb::Code.get_code self
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            class File
         
     | 
| 
      
 27 
     | 
    
         
            +
              def erb_code  
         
     | 
| 
      
 28 
     | 
    
         
            +
                Erb::Code.get_code File.read(self)
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
                
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb::Formtastic
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                def have_semantic_form_for name
         
     | 
| 
      
 4 
     | 
    
         
            +
                  have_form_call :semantic_form_for, :args => name
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def have_inputs name 
         
     | 
| 
      
 8 
     | 
    
         
            +
                  have_form_call :inputs, :args => ":name => #{name}"
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
                alias_method :have_input_field_set, :have_inputs
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def have_buttons name 
         
     | 
| 
      
 13 
     | 
    
         
            +
                  have_form_call :buttons
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
                alias_method :have_button_field_set, :have_buttons
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def have_label name 
         
     | 
| 
      
 18 
     | 
    
         
            +
                  have_form_call :label, :args => ":#{name}"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def self.inputs_list
         
     | 
| 
      
 22 
     | 
    
         
            +
                  [ :radio, :date, :text, :select, :checkboxes, :time_zone, :password, :date, :datetime, :time, :boolean, :string, :numeric, :country, :hidden ]
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                inputs_list.each do |name|
         
     | 
| 
      
 26 
     | 
    
         
            +
                  class_eval %{
         
     | 
| 
      
 27 
     | 
    
         
            +
                    def have_#{name} name
         
     | 
| 
      
 28 
     | 
    
         
            +
                      have_form_call :input, :args => ":\#{name}, :as => :#{name}"
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    def have_required_#{name} name
         
     | 
| 
      
 32 
     | 
    
         
            +
                      have_form_call :input, :args => ":\#{name}, :required => true, :as => :#{name}"
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  }
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def have_input name 
         
     | 
| 
      
 38 
     | 
    
         
            +
                  have_form_call :input, :args => ":#{name}"
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                def have_required_input name 
         
     | 
| 
      
 42 
     | 
    
         
            +
                  have_form_call :input, :args => ":#{name}, :required => true"
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                def have_errors_for name
         
     | 
| 
      
 46 
     | 
    
         
            +
                  have_form_call :input, :args => ":#{name}"
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
                alias_method :have_inline_errors_for, :have_errors_for
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                def have_semantic_errors
         
     | 
| 
      
 51 
     | 
    
         
            +
                  have_form_call :semantic_errors
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                def have_semantic_fields_for
         
     | 
| 
      
 55 
     | 
    
         
            +
                  have_form_call :semantic_fields_for
         
     | 
| 
      
 56 
     | 
    
         
            +
                end            
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def have_commit_button 
         
     | 
| 
      
 59 
     | 
    
         
            +
                  have_form_call :commit_button
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_all File.dirname(__FILE__) + '/helpers'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Erb::RailsForm
         
     | 
| 
      
 4 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 5 
     | 
    
         
            +
                def have_form_for name
         
     | 
| 
      
 6 
     | 
    
         
            +
                  have_block :form_for, :args => name
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def self.form_helpers
         
     | 
| 
      
 10 
     | 
    
         
            +
                  [:check_box, :file_field, :hidden_field, :label, :password_field, :radio_button, :text_area]
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                form_helpers.each do |name|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  class_eval %{
         
     | 
| 
      
 15 
     | 
    
         
            +
                    def have_#{name} obj_name, args=nil  
         
     | 
| 
      
 16 
     | 
    
         
            +
                      args = args ? ":\#{obj_name}, \#{args}" : ":\#{obj_name}"
         
     | 
| 
      
 17 
     | 
    
         
            +
                      have_form_call :#{name}, :args => args
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end        
         
     | 
| 
      
 19 
     | 
    
         
            +
                  }
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  
         
     | 
| 
      
 22 
     | 
    
         
            +
                include LinkHelpers
         
     | 
| 
      
 23 
     | 
    
         
            +
                include OptionHelpers
         
     | 
| 
      
 24 
     | 
    
         
            +
                include TagHelpers
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb::RailsForm
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module LinkHelpers
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.link_methods       
         
     | 
| 
      
 5 
     | 
    
         
            +
                    [ :button_to, :link_to, :mail_to ]
         
     | 
| 
      
 6 
     | 
    
         
            +
                  end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  link_methods.each do |name|
         
     | 
| 
      
 9 
     | 
    
         
            +
                    class_eval %{
         
     | 
| 
      
 10 
     | 
    
         
            +
                      def have_#{name} args
         
     | 
| 
      
 11 
     | 
    
         
            +
                        have_form_call :collection_select, :args => args
         
     | 
| 
      
 12 
     | 
    
         
            +
                      end
         
     | 
| 
      
 13 
     | 
    
         
            +
                    }
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def have_submit_button 
         
     | 
| 
      
 17 
     | 
    
         
            +
                    HaveDotCall.new(:submit)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb::RailsForm
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module OptionHelpers
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def self.options_methods
         
     | 
| 
      
 5 
     | 
    
         
            +
                    [ :grouped_collection_select, :option_groups_from_collection_for_select, :option_groups_from_collection_for_select, 
         
     | 
| 
      
 6 
     | 
    
         
            +
                      :options_from_collection_for_select, :time_zone_options_for_select ]
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  options_methods.each do |name|
         
     | 
| 
      
 10 
     | 
    
         
            +
                    class_eval %{
         
     | 
| 
      
 11 
     | 
    
         
            +
                      def have_#{name} name
         
     | 
| 
      
 12 
     | 
    
         
            +
                        have_form_call :#{name}
         
     | 
| 
      
 13 
     | 
    
         
            +
                      end
         
     | 
| 
      
 14 
     | 
    
         
            +
                    }
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  def self.name_options_methods       
         
     | 
| 
      
 18 
     | 
    
         
            +
                    [ :collection_select, :grouped_collection_select, :select, :time_zone_select ]
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  name_options_methods.each do |name|
         
     | 
| 
      
 22 
     | 
    
         
            +
                    class_eval %{
         
     | 
| 
      
 23 
     | 
    
         
            +
                      def have_#{name} name
         
     | 
| 
      
 24 
     | 
    
         
            +
                        have_form_call :collection_select, :args => ":#{name}"
         
     | 
| 
      
 25 
     | 
    
         
            +
                      end
         
     | 
| 
      
 26 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end 
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb::RailsForm
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                module TagHelpers
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def have_field_set_tag legend
         
     | 
| 
      
 5 
     | 
    
         
            +
                    have_form_call :field_set_tag, :args => "'#{legend}'"
         
     | 
| 
      
 6 
     | 
    
         
            +
                  end
         
     | 
| 
      
 7 
     | 
    
         
            +
                
         
     | 
| 
      
 8 
     | 
    
         
            +
                  def have_form_tag url
         
     | 
| 
      
 9 
     | 
    
         
            +
                    have_form_call :form_tag, :args => "'#{url}'"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def have_password_field_tag name = "password"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    have_form_call :password_field_tag, :args => "'#{name}'"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def self.tags_list
         
     | 
| 
      
 17 
     | 
    
         
            +
                    [ :check_box_tag, :file_field_tag, :text_field_tag, :hidden_field_tag, :image_submit_tag, 
         
     | 
| 
      
 18 
     | 
    
         
            +
                      :radio_button_tag, :select_tag, :label_tag, :submit_tag, :text_area_tag ]
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  tags_list.each do |name|
         
     | 
| 
      
 22 
     | 
    
         
            +
                    class_eval %{
         
     | 
| 
      
 23 
     | 
    
         
            +
                      def have_#{name} name
         
     | 
| 
      
 24 
     | 
    
         
            +
                        have_form_call :#{name}, :args => "'\#{name}'"
         
     | 
| 
      
 25 
     | 
    
         
            +
                      end
         
     | 
| 
      
 26 
     | 
    
         
            +
                    }
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end    
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Erb::SimpleForm
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 3 
     | 
    
         
            +
                def have_simple_form_for name
         
     | 
| 
      
 4 
     | 
    
         
            +
                  have_block :simple_form_for, :args => name
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def have_input name 
         
     | 
| 
      
 8 
     | 
    
         
            +
                  have_form_call :input, :args => ":#{name}"
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def have_button name 
         
     | 
| 
      
 12 
     | 
    
         
            +
                  have_form_call :button, :args => ":#{name}"
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def self.standard_inputs
         
     | 
| 
      
 16 
     | 
    
         
            +
                  [ :username, :email, :website, :age, :password, :remember_me]
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def self.association_types
         
     | 
| 
      
 20 
     | 
    
         
            +
                  [ :radio, :check_boxes]
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def have_association name
         
     | 
| 
      
 24 
     | 
    
         
            +
                  have_form_call :association, :args => ":#{name}"
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                association_types.each do |name|
         
     | 
| 
      
 28 
     | 
    
         
            +
                  class_eval %{
         
     | 
| 
      
 29 
     | 
    
         
            +
                    def have_#{name.to_s.pluralize} name
         
     | 
| 
      
 30 
     | 
    
         
            +
                      have_form_call :association, :args => ":\#{name}, :as => :#{name}"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end        
         
     | 
| 
      
 32 
     | 
    
         
            +
                  }
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                standard_inputs.each do |name|
         
     | 
| 
      
 36 
     | 
    
         
            +
                  class_eval %{
         
     | 
| 
      
 37 
     | 
    
         
            +
                    def have_#{name}
         
     | 
| 
      
 38 
     | 
    
         
            +
                      have_input :#{name}
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end 
         
     | 
| 
      
 40 
     | 
    
         
            +
                  }
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                def have_commit_button 
         
     | 
| 
      
 44 
     | 
    
         
            +
                  have_form_call :commit_button
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/forms-spec.rb
    ADDED
    
    
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Erb
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Code
         
     | 
| 
      
 5 
     | 
    
         
            +
                describe '#erb_code' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  context "valid ERB file" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                    it "should get only the ERB code from a valid ERB file" do
         
     | 
| 
      
 8 
     | 
    
         
            +
                      debug = false # true
         
     | 
| 
      
 9 
     | 
    
         
            +
                      erb_file = File.join(erb_fixtures_dir, 'view-file.erb')
         
     | 
| 
      
 10 
     | 
    
         
            +
                      File.new(erb_file).erb_code.should match_lines %{for @item in @items\nhello :you\nhello :me}
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end        
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'Formtastic form matcher' do      
         
     | 
| 
      
 4 
     | 
    
         
            +
              with_form_helper :formtastic
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              context "Formtastic example 1 view file" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                let(:form_file) { File.join erb_fixtures_dir, 'formtastic-ex1.erb' }
         
     | 
| 
      
 8 
     | 
    
         
            +
                
         
     | 
| 
      
 9 
     | 
    
         
            +
                it "content should match form expectations" do      
         
     | 
| 
      
 10 
     | 
    
         
            +
                  form_file.should have_content do |content|
         
     | 
| 
      
 11 
     | 
    
         
            +
                    content.erb_code.should have_semantic_form_for '@article' do |form|
         
     | 
| 
      
 12 
     | 
    
         
            +
                      form.should have_inputs "Basic"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'Rails 3 form matcher' do    
         
     | 
| 
      
 4 
     | 
    
         
            +
              with_form_helper :railsform
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              context "Rails 3 form example 1 view file" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                form_file = File.join(erb_fixtures_dir, 'railsform-ex1.erb')
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                it "content should match form expectations" do            
         
     | 
| 
      
 10 
     | 
    
         
            +
                  form_file.should have_content do |content|
         
     | 
| 
      
 11 
     | 
    
         
            +
                    content.erb_code.should have_form_for '@person' do |form|
         
     | 
| 
      
 12 
     | 
    
         
            +
                      form.should have_label :name
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'Simpleform form matcher' do    
         
     | 
| 
      
 4 
     | 
    
         
            +
              with_form_helper :simpleform
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              context "Simpleform example 1 view file" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                form_file = File.join(erb_fixtures_dir, 'simpleform-ex1.erb')
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                it "content should match form expectations" do            
         
     | 
| 
      
 10 
     | 
    
         
            +
                  form_file.should have_content do |content|
         
     | 
| 
      
 11 
     | 
    
         
            +
                    content.erb_code.should have_simple_form_for '@user' do |form|
         
     | 
| 
      
 12 
     | 
    
         
            +
                      form.should have_username
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% semantic_form_for @article do |form| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              <% form.inputs :name => "Basic" do %>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <%= form.input :title %>
         
     | 
| 
      
 5 
     | 
    
         
            +
                <%= form.input :body %>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <%= form.input :section %>
         
     | 
| 
      
 7 
     | 
    
         
            +
                <%= form.input :publication_state, :as => :radio %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                <%= form.input :category %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%= form.input :allow_comments, :label => "Allow commenting on this article" %>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              <% form.inputs :name => "Advanced" do %>
         
     | 
| 
      
 13 
     | 
    
         
            +
                <%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
         
     | 
| 
      
 14 
     | 
    
         
            +
                <%= form.input :extract, :required => false %>
         
     | 
| 
      
 15 
     | 
    
         
            +
                <%= form.input :description, :required => false %>
         
     | 
| 
      
 16 
     | 
    
         
            +
                <%= form.input :url_title, :required => false %>
         
     | 
| 
      
 17 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              <% form.inputs :name => "Author", :for => :author do |author_form| %>
         
     | 
| 
      
 20 
     | 
    
         
            +
                <%= author_form.input :first_name %>
         
     | 
| 
      
 21 
     | 
    
         
            +
                <%= author_form.input :last_name %>
         
     | 
| 
      
 22 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              <% form.buttons do %>
         
     | 
| 
      
 25 
     | 
    
         
            +
                <%= form.commit_button %>
         
     | 
| 
      
 26 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% form_for @person do |person_form| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              <%= person_form.label :name %>
         
     | 
| 
      
 4 
     | 
    
         
            +
              <%= person_form.text_field :name %>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              <% person_form.fields_for :children do |child_form| %>
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                <%= child_form.label :name %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%= child_form.text_field :name %>
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                <% unless child_form.object.new_record? %>
         
     | 
| 
      
 12 
     | 
    
         
            +
                  <%= child_form.check_box '_delete' %>
         
     | 
| 
      
 13 
     | 
    
         
            +
                  <%= child_form.label '_delete', 'Remove' %>
         
     | 
| 
      
 14 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              <% end %>
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              <%= submit_tag %>
         
     | 
| 
      
 19 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%= simple_form_for @user do |f| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <%= f.input :username, :label_html => { :class => 'my_class' } %>
         
     | 
| 
      
 3 
     | 
    
         
            +
              <%= f.input :password, :hint => false, :error_html => { :id => "password_error"} %>
         
     | 
| 
      
 4 
     | 
    
         
            +
              <%= f.input :password_confirmation, :label => false %>
         
     | 
| 
      
 5 
     | 
    
         
            +
              <%= f.input :time_zone, :priority => /US/%>
         
     | 
| 
      
 6 
     | 
    
         
            +
              <%= f.error :username, :id => 'user_name_error' %>
         
     | 
| 
      
 7 
     | 
    
         
            +
              <%= f.hint 'No special characters, please!' %>
         
     | 
| 
      
 8 
     | 
    
         
            +
              <%= f.association :company %>
         
     | 
| 
      
 9 
     | 
    
         
            +
              <%= f.association :role %>
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              <%= f.association :companies, :as => :radio %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              <%= f.association :roles,   :as => :check_boxes %>
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              <%= f.button :submit %>  
         
     | 
| 
      
 15 
     | 
    
         
            +
              <%= f.button :submit %>
         
     | 
| 
      
 16 
     | 
    
         
            +
              <%= f.submit 'Save' %>  
         
     | 
| 
      
 17 
     | 
    
         
            +
            <% end %>
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rspec/autorun'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'forms-spec'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            RSpec.configure do |config|  
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            def fixtures_dir
         
     | 
| 
      
 9 
     | 
    
         
            +
              File.expand_path(File.dirname(__FILE__) + '/forms-spec/fixtures')
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            def erb_fixtures_dir
         
     | 
| 
      
 13 
     | 
    
         
            +
              File.join(fixtures_dir, 'erb')
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,125 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: forms-spec
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 10 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 12 
     | 
    
         
            +
            - Kristian Mandrup
         
     | 
| 
      
 13 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 15 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-08-18 00:00:00 +02:00
         
     | 
| 
      
 18 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 21 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 22 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 23 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 24 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 25 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 26 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 28 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    - 2
         
     | 
| 
      
 30 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 31 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 32 
     | 
    
         
            +
                    - beta
         
     | 
| 
      
 33 
     | 
    
         
            +
                    - 19
         
     | 
| 
      
 34 
     | 
    
         
            +
                    version: 2.0.0.beta.19
         
     | 
| 
      
 35 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 37 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 38 
     | 
    
         
            +
              name: require_all
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 45 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 46 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 47 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 48 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 49 
     | 
    
         
            +
                    version: 1.1.0
         
     | 
| 
      
 50 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 51 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 52 
     | 
    
         
            +
            description: Adds RSpec 2 matchers to make expectations about your view code containing form logic
         
     | 
| 
      
 53 
     | 
    
         
            +
            email: kmandrup@gmail.com
         
     | 
| 
      
 54 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 60 
     | 
    
         
            +
            - README.markdown
         
     | 
| 
      
 61 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 62 
     | 
    
         
            +
            - .document
         
     | 
| 
      
 63 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 64 
     | 
    
         
            +
            - .rspec
         
     | 
| 
      
 65 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 66 
     | 
    
         
            +
            - README.markdown
         
     | 
| 
      
 67 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 68 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 69 
     | 
    
         
            +
            - forms-spec.gemspec
         
     | 
| 
      
 70 
     | 
    
         
            +
            - lib/forms-spec.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - lib/forms-spec/erb/base.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - lib/forms-spec/erb/code-stripper.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/formtastic/have_formtastic.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/rails_view/have_form.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/rails_view/helpers/links.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/rails_view/helpers/options.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/rails_view/helpers/tags.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - lib/forms-spec/erb/matchers/simpleform/have_simpleform.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            - spec/forms-spec/erb/code-stripper_spec.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/formtastic/have_formtastic_spec.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/rails_view/have_form_spec.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/simpleform/have_simpleform_spec.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - spec/forms-spec/fixtures/erb/formtastic-ex1.erb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - spec/forms-spec/fixtures/erb/railsform-ex1.erb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - spec/forms-spec/fixtures/erb/simpleform-ex1.erb
         
     | 
| 
      
 86 
     | 
    
         
            +
            - spec/forms-spec/fixtures/erb/view-file.erb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 89 
     | 
    
         
            +
            homepage: http://github.com/kristianmandrup/forms-spec
         
     | 
| 
      
 90 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 93 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 94 
     | 
    
         
            +
            - --charset=UTF-8
         
     | 
| 
      
 95 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 97 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 98 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 100 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 101 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 102 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 103 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 104 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 105 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 106 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 107 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 108 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 109 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 110 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 111 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 112 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 113 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 116 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 117 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 118 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 119 
     | 
    
         
            +
            summary: Assists in verifying your static web forms code structure
         
     | 
| 
      
 120 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 121 
     | 
    
         
            +
            - spec/forms-spec/erb/code-stripper_spec.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/formtastic/have_formtastic_spec.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/rails_view/have_form_spec.rb
         
     | 
| 
      
 124 
     | 
    
         
            +
            - spec/forms-spec/erb/matchers/simpleform/have_simpleform_spec.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     |