flockup /test/shoulda_macros/view_macros.rb

Language Ruby Lines 30
MD5 Hash f17a0778d6f877e7cb2c5d968329fd42
Repository https://github.com/technicalpickles/flockup.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Test::Unit::TestCase.class_eval do
  class << self
    def should_not_link_to(href_expression)
      should_link_to(href_expression, 0)
    end
    
    def should_link_to(href_expression, count = 1)
      should "display #{count} link#{'s' if count == 0 || count > 1} to #{href_expression.inspect}" do
        instantiate_variables_from_assigns do
          href =  eval(href_expression, self.send(:binding), __FILE__, __LINE__)
          assert_select "a[href=#{href}]", count
        end  
      end
    end

      def should_have_form_for(action_expression, &block)
      should "have form to #{action_expression}" do
        instantiate_variables_from_assigns do
          action =  eval(action_expression, self.send(:binding), __FILE__, __LINE__)

          assert_select "form[action=#{action}]" do
            block.bind(self).call if block
          end
        end
      end
    end
    
  end
end
Back to Top