draper/spec/integration/integration_spec.rb

51 lines
1.5 KiB
Ruby
Raw Normal View History

require 'spec_helper'
require 'support/dummy_app'
require 'support/matchers/have_text'
2012-11-16 11:55:34 +00:00
app = DummyApp.new(ENV["RAILS_ENV"])
2012-11-13 20:28:15 +00:00
2012-11-16 11:55:34 +00:00
app.start_server do
{view: "/posts/1", mailer: "/posts/1/mail"}.each do |type, path|
page = app.get(path)
2012-11-13 20:28:15 +00:00
2012-11-16 11:55:34 +00:00
describe "in a #{type}" do
it "runs in the correct environment" do
page.should have_text(app.environment).in("#environment")
end
2013-01-16 16:30:53 +00:00
it "can use built-in helpers" do
page.should have_text("Once upon a...").in("#truncated")
end
it "can use built-in private helpers" do
# Nokogiri unescapes text!
page.should have_text("<script>danger</script>").in("#html_escaped")
end
it "can use user-defined helpers from app/helpers" do
page.should have_text("Hello, world!").in("#hello_world")
end
it "can use user-defined helpers from the controller" do
page.should have_text("Goodnight, moon!").in("#goodnight_moon")
end
2012-11-16 11:55:34 +00:00
it "can use path helpers with a model" do
page.should have_text("/en/posts/1").in("#path_with_model")
end
2012-11-16 11:55:34 +00:00
it "can use path helpers with an id" do
page.should have_text("/en/posts/1").in("#path_with_id")
end
2012-11-16 11:55:34 +00:00
it "can use url helpers with a model" do
2013-01-12 11:37:28 +00:00
page.should have_text("http://www.example.com:12345/en/posts/1").in("#url_with_model")
2012-11-16 11:55:34 +00:00
end
2012-11-16 11:55:34 +00:00
it "can use url helpers with an id" do
2013-01-12 11:37:28 +00:00
page.should have_text("http://www.example.com:12345/en/posts/1").in("#url_with_id")
end
end
end
end