code-spec 0.1.2 → 0.1.3
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/VERSION +1 -1
 - data/code-spec.gemspec +10 -2
 - data/lib/code-spec.rb +28 -1
 - data/lib/code_spec/erb/code-stripper.rb +2 -2
 - data/lib/code_spec/erb/matchers/rails_view/have_form.rb +16 -87
 - data/lib/code_spec/erb/matchers/rails_view/helpers/links.rb +21 -0
 - data/lib/code_spec/erb/matchers/rails_view/helpers/options.rb +30 -0
 - data/lib/code_spec/erb/matchers/rails_view/helpers/tags.rb +30 -0
 - data/lib/code_spec/erb/matchers/simpleform/have_simpleform.rb +1 -1
 - data/spec/code-spec/erb/code-stripper_spec.rb +1 -1
 - data/spec/code-spec/erb/matchers/formtastic/have_formtastic_spec.rb +21 -0
 - data/spec/code-spec/erb/matchers/rails_view/have_form_spec.rb +22 -0
 - data/spec/code-spec/erb/matchers/simpleform/have_simpleform_spec.rb +22 -0
 - data/spec/code-spec/fixtures/erb/formtastic-ex1.erb +28 -0
 - data/spec/code-spec/fixtures/erb/railsform-ex1.erb +19 -0
 - data/spec/code-spec/fixtures/erb/simpleform-ex1.erb +17 -0
 - data/spec/code-spec/fixtures/{view-file.erb → erb/view-file.erb} +0 -0
 - data/spec/code-spec/fixtures/logfile.log +3 -0
 - data/spec/spec_helper.rb +4 -0
 - metadata +11 -3
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.1. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.1.3
         
     | 
    
        data/code-spec.gemspec
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{code-spec}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.1. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.1.3"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Kristian Mandrup"]
         
     | 
| 
         @@ -32,6 +32,9 @@ Gem::Specification.new do |s| 
     | 
|
| 
       32 
32 
     | 
    
         
             
                 "lib/code_spec/erb/code-stripper.rb",
         
     | 
| 
       33 
33 
     | 
    
         
             
                 "lib/code_spec/erb/matchers/formtastic/have_formtastic.rb",
         
     | 
| 
       34 
34 
     | 
    
         
             
                 "lib/code_spec/erb/matchers/rails_view/have_form.rb",
         
     | 
| 
      
 35 
     | 
    
         
            +
                 "lib/code_spec/erb/matchers/rails_view/helpers/links.rb",
         
     | 
| 
      
 36 
     | 
    
         
            +
                 "lib/code_spec/erb/matchers/rails_view/helpers/options.rb",
         
     | 
| 
      
 37 
     | 
    
         
            +
                 "lib/code_spec/erb/matchers/rails_view/helpers/tags.rb",
         
     | 
| 
       35 
38 
     | 
    
         
             
                 "lib/code_spec/erb/matchers/simpleform/have_simpleform.rb",
         
     | 
| 
       36 
39 
     | 
    
         
             
                 "lib/code_spec/matchers/content_matcher.rb",
         
     | 
| 
       37 
40 
     | 
    
         
             
                 "lib/code_spec/matchers/have_block.rb",
         
     | 
| 
         @@ -50,8 +53,12 @@ Gem::Specification.new do |s| 
     | 
|
| 
       50 
53 
     | 
    
         
             
                 "spec/code-spec/erb/code-stripper_spec.rb",
         
     | 
| 
       51 
54 
     | 
    
         
             
                 "spec/code-spec/erb/matchers/formtastic/have_formtastic_spec.rb",
         
     | 
| 
       52 
55 
     | 
    
         
             
                 "spec/code-spec/erb/matchers/rails_view/have_form_spec.rb",
         
     | 
| 
      
 56 
     | 
    
         
            +
                 "spec/code-spec/erb/matchers/simpleform/have_simpleform_spec.rb",
         
     | 
| 
      
 57 
     | 
    
         
            +
                 "spec/code-spec/fixtures/erb/formtastic-ex1.erb",
         
     | 
| 
      
 58 
     | 
    
         
            +
                 "spec/code-spec/fixtures/erb/railsform-ex1.erb",
         
     | 
| 
      
 59 
     | 
    
         
            +
                 "spec/code-spec/fixtures/erb/simpleform-ex1.erb",
         
     | 
| 
      
 60 
     | 
    
         
            +
                 "spec/code-spec/fixtures/erb/view-file.erb",
         
     | 
| 
       53 
61 
     | 
    
         
             
                 "spec/code-spec/fixtures/logfile.log",
         
     | 
| 
       54 
     | 
    
         
            -
                 "spec/code-spec/fixtures/view-file.erb",
         
     | 
| 
       55 
62 
     | 
    
         
             
                 "spec/code-spec/matchers/class_self_spec.rb",
         
     | 
| 
       56 
63 
     | 
    
         
             
                 "spec/code-spec/matchers/have_block_spec.rb",
         
     | 
| 
       57 
64 
     | 
    
         
             
                 "spec/code-spec/matchers/have_call_spec.rb",
         
     | 
| 
         @@ -75,6 +82,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       75 
82 
     | 
    
         
             
                "spec/code-spec/erb/code-stripper_spec.rb",
         
     | 
| 
       76 
83 
     | 
    
         
             
                 "spec/code-spec/erb/matchers/formtastic/have_formtastic_spec.rb",
         
     | 
| 
       77 
84 
     | 
    
         
             
                 "spec/code-spec/erb/matchers/rails_view/have_form_spec.rb",
         
     | 
| 
      
 85 
     | 
    
         
            +
                 "spec/code-spec/erb/matchers/simpleform/have_simpleform_spec.rb",
         
     | 
| 
       78 
86 
     | 
    
         
             
                 "spec/code-spec/matchers/class_self_spec.rb",
         
     | 
| 
       79 
87 
     | 
    
         
             
                 "spec/code-spec/matchers/have_block_spec.rb",
         
     | 
| 
       80 
88 
     | 
    
         
             
                 "spec/code-spec/matchers/have_call_spec.rb",
         
     | 
    
        data/lib/code-spec.rb
    CHANGED
    
    | 
         @@ -15,6 +15,33 @@ require_all File.dirname(__FILE__) + '/code_spec/erb' 
     | 
|
| 
       15 
15 
     | 
    
         
             
            require 'code_spec/content_helpers'
         
     | 
| 
       16 
16 
     | 
    
         
             
            require 'code_spec/core_ext'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            module FormHelperMacro  
         
     | 
| 
      
 19 
     | 
    
         
            +
              def with_form_helper name
         
     | 
| 
      
 20 
     | 
    
         
            +
                class_eval do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  include get_form_matcher(name)
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              protected
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def get_form_matcher name
         
     | 
| 
      
 28 
     | 
    
         
            +
                case name
         
     | 
| 
      
 29 
     | 
    
         
            +
                when :formtastic
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Erb::Formtastic::ContentMatchers
         
     | 
| 
      
 31 
     | 
    
         
            +
                when :simpleform
         
     | 
| 
      
 32 
     | 
    
         
            +
                  Erb::SimpleForm::ContentMatchers
         
     | 
| 
      
 33 
     | 
    
         
            +
                else
         
     | 
| 
      
 34 
     | 
    
         
            +
                  Erb::RailsForm::ContentMatchers
         
     | 
| 
      
 35 
     | 
    
         
            +
                end    
         
     | 
| 
      
 36 
     | 
    
         
            +
              end  
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
       18 
40 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
       19 
     | 
    
         
            -
              config.include 
     | 
| 
      
 41 
     | 
    
         
            +
              config.include RSpec::RubyContentMatchers 
         
     | 
| 
      
 42 
     | 
    
         
            +
              config.extend(FormHelperMacro) 
         
     | 
| 
       20 
43 
     | 
    
         
             
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                                                   
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
         @@ -1,97 +1,26 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
              module Base
         
     | 
| 
       3 
     | 
    
         
            -
                module ContentMatchers
         
     | 
| 
       4 
     | 
    
         
            -
                  def have_form_block name
         
     | 
| 
       5 
     | 
    
         
            -
                    have_block :form_for, :args => name
         
     | 
| 
       6 
     | 
    
         
            -
                  end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                  def self.form_helpers
         
     | 
| 
       9 
     | 
    
         
            -
                    [:check_box, :file_field, :hidden_field, :label, :password_field, :radio_button, :text_area]
         
     | 
| 
       10 
     | 
    
         
            -
                  end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  form_helpers.each do |name|
         
     | 
| 
       13 
     | 
    
         
            -
                    class_eval %{
         
     | 
| 
       14 
     | 
    
         
            -
                      def have_#{name} obj_name, args=nil  
         
     | 
| 
       15 
     | 
    
         
            -
                        args = args ? ":name => \#{obj_name}, \#{args}" : ":name => \#{obj_name}"
         
     | 
| 
       16 
     | 
    
         
            -
                        have_form_call :#{name}, :args => args
         
     | 
| 
       17 
     | 
    
         
            -
                      end        
         
     | 
| 
       18 
     | 
    
         
            -
                    }
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
              end
         
     | 
| 
       22 
     | 
    
         
            -
              
         
     | 
| 
       23 
     | 
    
         
            -
              module Tags
         
     | 
| 
       24 
     | 
    
         
            -
                
         
     | 
| 
       25 
     | 
    
         
            -
                def have_field_set_tag legend
         
     | 
| 
       26 
     | 
    
         
            -
                  have_form_call :field_set_tag, :args => "'#{legend}'"
         
     | 
| 
       27 
     | 
    
         
            -
                end
         
     | 
| 
       28 
     | 
    
         
            -
                    
         
     | 
| 
       29 
     | 
    
         
            -
                def have_form_tag url
         
     | 
| 
       30 
     | 
    
         
            -
                  have_form_call :form_tag, :args => "'#{url}'"
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
                    
         
     | 
| 
       33 
     | 
    
         
            -
                def have_password_field_tag name = "password"
         
     | 
| 
       34 
     | 
    
         
            -
                  have_form_call :password_field_tag, :args => "'#{name}'"
         
     | 
| 
       35 
     | 
    
         
            -
                end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                def self.tags_list
         
     | 
| 
       38 
     | 
    
         
            -
                  [ :check_box_tag, :file_field_tag, :text_field_tag, :hidden_field_tag, :image_submit_tag, 
         
     | 
| 
       39 
     | 
    
         
            -
                    :radio_button_tag, :select_tag, :label_tag, :submit_tag, :text_area_tag ]
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                tags_list.each do |name|
         
     | 
| 
       43 
     | 
    
         
            -
                  class_eval %{
         
     | 
| 
       44 
     | 
    
         
            -
                    def have_#{name} name
         
     | 
| 
       45 
     | 
    
         
            -
                      have_form_call :#{name}, :args => "'\#{name}'"
         
     | 
| 
       46 
     | 
    
         
            -
                    end
         
     | 
| 
       47 
     | 
    
         
            -
                  }
         
     | 
| 
       48 
     | 
    
         
            -
                end
         
     | 
| 
       49 
     | 
    
         
            -
                
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
              
         
     | 
| 
       52 
     | 
    
         
            -
              module Options
         
     | 
| 
       53 
     | 
    
         
            -
                def self.options_methods
         
     | 
| 
       54 
     | 
    
         
            -
                  [ :grouped_collection_select, :option_groups_from_collection_for_select, :option_groups_from_collection_for_select, 
         
     | 
| 
       55 
     | 
    
         
            -
                    :options_from_collection_for_select, :time_zone_options_for_select ]
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                options_methods.each do |name|
         
     | 
| 
       58 
     | 
    
         
            -
                  class_eval %{
         
     | 
| 
       59 
     | 
    
         
            -
                    def have_#{name} name
         
     | 
| 
       60 
     | 
    
         
            -
                      have_form_call :#{name}
         
     | 
| 
       61 
     | 
    
         
            -
                    end
         
     | 
| 
       62 
     | 
    
         
            -
                  }
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                def self.name_options_methods       
         
     | 
| 
       66 
     | 
    
         
            -
                  [ :collection_select, :grouped_collection_select, :select, :time_zone_select ]
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require_all File.dirname(__FILE__) + '/helpers'
         
     | 
| 
       68 
2 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                    end
         
     | 
| 
       74 
     | 
    
         
            -
                  }
         
     | 
| 
      
 3 
     | 
    
         
            +
            module Erb::RailsForm
         
     | 
| 
      
 4 
     | 
    
         
            +
              module ContentMatchers
         
     | 
| 
      
 5 
     | 
    
         
            +
                def have_form_for name
         
     | 
| 
      
 6 
     | 
    
         
            +
                  have_block :form_for, :args => name
         
     | 
| 
       75 
7 
     | 
    
         
             
                end
         
     | 
| 
       76 
     | 
    
         
            -
              end
         
     | 
| 
       77 
8 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                  [ :button_to, :link_to, :mail_to ]
         
     | 
| 
      
 9 
     | 
    
         
            +
                def self.form_helpers
         
     | 
| 
      
 10 
     | 
    
         
            +
                  [:check_box, :file_field, :hidden_field, :label, :password_field, :radio_button, :text_area]
         
     | 
| 
       81 
11 
     | 
    
         
             
                end
         
     | 
| 
       82 
12 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                form_helpers.each do |name|
         
     | 
| 
       84 
14 
     | 
    
         
             
                  class_eval %{
         
     | 
| 
       85 
     | 
    
         
            -
                    def have_#{name} args
         
     | 
| 
       86 
     | 
    
         
            -
                       
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 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        
         
     | 
| 
       88 
19 
     | 
    
         
             
                  }
         
     | 
| 
       89 
20 
     | 
    
         
             
                end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
                 
     | 
| 
       94 
     | 
    
         
            -
              end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
                  
         
     | 
| 
      
 22 
     | 
    
         
            +
                include LinkHelpers
         
     | 
| 
      
 23 
     | 
    
         
            +
                include OptionHelpers
         
     | 
| 
      
 24 
     | 
    
         
            +
                include TagHelpers
         
     | 
| 
       96 
25 
     | 
    
         
             
              end
         
     | 
| 
       97 
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
         
     | 
| 
         @@ -6,7 +6,7 @@ module Erb 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  context "valid ERB file" do
         
     | 
| 
       7 
7 
     | 
    
         
             
                    it "should get only the ERB code from a valid ERB file" do
         
     | 
| 
       8 
8 
     | 
    
         
             
                      debug = false # true
         
     | 
| 
       9 
     | 
    
         
            -
                      erb_file = File.join( 
     | 
| 
      
 9 
     | 
    
         
            +
                      erb_file = File.join(erb_fixtures_dir, 'view-file.erb')
         
     | 
| 
       10 
10 
     | 
    
         
             
                      File.new(erb_file).erb_code.should match_lines %{for @item in @items\nhello :you\nhello :me}
         
     | 
| 
       11 
11 
     | 
    
         
             
                    end        
         
     | 
| 
       12 
12 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
                form_file = File.join(erb_fixtures_dir, 'formtastic-ex1.erb')
         
     | 
| 
      
 8 
     | 
    
         
            +
                it "content should match form expectations" do      
         
     | 
| 
      
 9 
     | 
    
         
            +
                  form_file.should have_content do |content|
         
     | 
| 
      
 10 
     | 
    
         
            +
                    content.erb_code.should have_semantic_form_for '@article' do |form|
         
     | 
| 
      
 11 
     | 
    
         
            +
                      form.should have_inputs "Basic"
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'Rails 3 form matcher' do    
         
     | 
| 
      
 4 
     | 
    
         
            +
              with_form_helper :rails_form
         
     | 
| 
      
 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 %>
         
     | 
| 
         
            File without changes
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - Kristian Mandrup
         
     | 
| 
         @@ -90,6 +90,9 @@ files: 
     | 
|
| 
       90 
90 
     | 
    
         
             
            - lib/code_spec/erb/code-stripper.rb
         
     | 
| 
       91 
91 
     | 
    
         
             
            - lib/code_spec/erb/matchers/formtastic/have_formtastic.rb
         
     | 
| 
       92 
92 
     | 
    
         
             
            - lib/code_spec/erb/matchers/rails_view/have_form.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - lib/code_spec/erb/matchers/rails_view/helpers/links.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib/code_spec/erb/matchers/rails_view/helpers/options.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - lib/code_spec/erb/matchers/rails_view/helpers/tags.rb
         
     | 
| 
       93 
96 
     | 
    
         
             
            - lib/code_spec/erb/matchers/simpleform/have_simpleform.rb
         
     | 
| 
       94 
97 
     | 
    
         
             
            - lib/code_spec/matchers/content_matcher.rb
         
     | 
| 
       95 
98 
     | 
    
         
             
            - lib/code_spec/matchers/have_block.rb
         
     | 
| 
         @@ -108,8 +111,12 @@ files: 
     | 
|
| 
       108 
111 
     | 
    
         
             
            - spec/code-spec/erb/code-stripper_spec.rb
         
     | 
| 
       109 
112 
     | 
    
         
             
            - spec/code-spec/erb/matchers/formtastic/have_formtastic_spec.rb
         
     | 
| 
       110 
113 
     | 
    
         
             
            - spec/code-spec/erb/matchers/rails_view/have_form_spec.rb
         
     | 
| 
      
 114 
     | 
    
         
            +
            - spec/code-spec/erb/matchers/simpleform/have_simpleform_spec.rb
         
     | 
| 
      
 115 
     | 
    
         
            +
            - spec/code-spec/fixtures/erb/formtastic-ex1.erb
         
     | 
| 
      
 116 
     | 
    
         
            +
            - spec/code-spec/fixtures/erb/railsform-ex1.erb
         
     | 
| 
      
 117 
     | 
    
         
            +
            - spec/code-spec/fixtures/erb/simpleform-ex1.erb
         
     | 
| 
      
 118 
     | 
    
         
            +
            - spec/code-spec/fixtures/erb/view-file.erb
         
     | 
| 
       111 
119 
     | 
    
         
             
            - spec/code-spec/fixtures/logfile.log
         
     | 
| 
       112 
     | 
    
         
            -
            - spec/code-spec/fixtures/view-file.erb
         
     | 
| 
       113 
120 
     | 
    
         
             
            - spec/code-spec/matchers/class_self_spec.rb
         
     | 
| 
       114 
121 
     | 
    
         
             
            - spec/code-spec/matchers/have_block_spec.rb
         
     | 
| 
       115 
122 
     | 
    
         
             
            - spec/code-spec/matchers/have_call_spec.rb
         
     | 
| 
         @@ -159,6 +166,7 @@ test_files: 
     | 
|
| 
       159 
166 
     | 
    
         
             
            - spec/code-spec/erb/code-stripper_spec.rb
         
     | 
| 
       160 
167 
     | 
    
         
             
            - spec/code-spec/erb/matchers/formtastic/have_formtastic_spec.rb
         
     | 
| 
       161 
168 
     | 
    
         
             
            - spec/code-spec/erb/matchers/rails_view/have_form_spec.rb
         
     | 
| 
      
 169 
     | 
    
         
            +
            - spec/code-spec/erb/matchers/simpleform/have_simpleform_spec.rb
         
     | 
| 
       162 
170 
     | 
    
         
             
            - spec/code-spec/matchers/class_self_spec.rb
         
     | 
| 
       163 
171 
     | 
    
         
             
            - spec/code-spec/matchers/have_block_spec.rb
         
     | 
| 
       164 
172 
     | 
    
         
             
            - spec/code-spec/matchers/have_call_spec.rb
         
     |