ryana-plug_test 0.1.0 → 0.1.1

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/README.rdoc CHANGED
@@ -33,11 +33,14 @@ Bing bang boom.
33
33
 
34
34
  Whenever you want to test a helper just call:
35
35
 
36
- pt_helper(" [CODE YOU WANT TO TEST] ")
36
+ pt_helper { [CODE YOU WANT TO TEST] }
37
+
38
+ The only caveat, is that due to a few isms of Rails, you have to structure your blocks so that an argument is passed into the block,
39
+ and all your helper methods use that as a receiver.
37
40
 
38
41
  pt_helper will return the output of the call and setup your @response so you can do:
39
42
 
40
- res = pt_helper("link_to 'my link text', :action => 'test'")
43
+ res = pt_helper { |a| a.link_to 'my link text', :action => 'test' }
41
44
  assert_response :success
42
45
  assert_select 'a', 'my link text'
43
46
  assert(/my link text/.match(res))
@@ -1,7 +1,7 @@
1
1
  class PlugTestController < ApplicationController
2
2
  helper :all
3
3
 
4
- attr_accessor :plug_test_answer, :plug_test_block
4
+ attr_accessor :plug_test_answer, :plug_test_block, :plug_test_text
5
5
 
6
6
  def test_action
7
7
  overwrite_me
@@ -1,11 +1,19 @@
1
1
  module PlugTest
2
2
  module TestHelpers
3
- def pt_helper(block)
3
+ def pt_helper(text = nil, &block)
4
4
  @controller.plug_test_block = block
5
+ @controller.plug_test_text = text
5
6
 
6
7
  class <<@controller
7
8
  def overwrite_me
8
- @plug_test_answer = render_to_string(:inline => "<%=" + @plug_test_block + "%>")
9
+ if @plug_test_text
10
+ @plug_test_answer = render_to_string(:inline => "<%=" + @plug_test_text + "%>")
11
+ elsif @plug_test_block
12
+ @plug_test_answer = @plug_test_block.call(@template)
13
+ else
14
+ raise 'You win -- Did you call this method directly?'
15
+ end
16
+
9
17
  render :text => @plug_test_answer
10
18
  end
11
19
  end
data/plug_test.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{plug_test}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Angilly"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ryana-plug_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Angilly
File without changes