Module: Vanilla::TestHelper
- Includes:
- Rack::Test::Methods, Soup::TestHelper
- Defined in:
- lib/vanilla/test_helper.rb
Instance Method Summary collapse
- #app(klass = Vanilla.apps.first) ⇒ Object
- #assert_response_body(expected, uri) ⇒ Object
- #assert_response_status(expected, uri) ⇒ Object
- #create_snip(params) ⇒ Object
- #set_main_template(template_content) ⇒ Object
- #stub_app_soup(*snips) ⇒ Object
- #temp_soup_path ⇒ Object
- #vanilla_reset ⇒ Object
- #vanilla_setup ⇒ Object
- #vanilla_teardown ⇒ Object
Instance Method Details
#app(klass = Vanilla.apps.first) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vanilla/test_helper.rb', line 12 def app(klass=Vanilla.apps.first) unless @__app klass.configure do |config| # inject a sandbox soup path first. This ensures we can write # to the application's soup without actually affecting the # app's content. config.soups ||= [] config.soups.unshift temp_soup_path end @__app = klass.new end @__app end |
#assert_response_body(expected, uri) ⇒ Object
39 40 41 42 |
# File 'lib/vanilla/test_helper.rb', line 39 def assert_response_body(expected, uri) get uri assert_equal expected.strip, last_response.body.strip end |
#assert_response_status(expected, uri) ⇒ Object
34 35 36 37 |
# File 'lib/vanilla/test_helper.rb', line 34 def assert_response_status(expected, uri) get uri assert_equal expected, last_response.status end |
#create_snip(params) ⇒ Object
48 49 50 |
# File 'lib/vanilla/test_helper.rb', line 48 def create_snip(params) app.soup << params end |
#set_main_template(template_content) ⇒ Object
44 45 46 |
# File 'lib/vanilla/test_helper.rb', line 44 def set_main_template(template_content) app.soup << {:name => "layout", :content => template_content} end |
#stub_app_soup(*snips) ⇒ Object
60 61 62 |
# File 'lib/vanilla/test_helper.rb', line 60 def stub_app_soup(*snips) app.stubs(:soup).returns(stub_soup(*snips)) end |
#temp_soup_path ⇒ Object
52 53 54 |
# File 'lib/vanilla/test_helper.rb', line 52 def temp_soup_path File.(File.join(Dir.tmpdir, "soup")) end |
#vanilla_reset ⇒ Object
30 31 32 |
# File 'lib/vanilla/test_helper.rb', line 30 def vanilla_reset Vanilla.apps.each { |a| a.reset! } end |
#vanilla_setup ⇒ Object
26 27 28 |
# File 'lib/vanilla/test_helper.rb', line 26 def vanilla_setup FileUtils.mkdir_p(temp_soup_path) end |
#vanilla_teardown ⇒ Object
56 57 58 |
# File 'lib/vanilla/test_helper.rb', line 56 def vanilla_teardown FileUtils.rm_rf(temp_soup_path) end |