draper/spec/integration/integration_spec.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
require 'support/dummy_app'
require 'support/matchers/have_text'
2012-11-13 15:28:15 -05:00
shared_examples_for "a decorator in a view" do
it "works" do
# it runs in the correct environment
page.should have_text(environment).in("#environment")
2012-11-13 15:28:15 -05:00
# it can use path helpers with a model
page.should have_text("/en/posts/1").in("#path_with_model")
2012-11-13 15:28:15 -05:00
# it can use path helpers with an id
page.should have_text("/en/posts/1").in("#path_with_id")
2012-11-13 15:28:15 -05:00
# it can use url helpers with a model
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
2012-11-13 15:28:15 -05:00
# it can use url helpers with an id
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
2012-11-13 15:28:15 -05:00
end
end
describe "integration" do
2012-11-16 05:34:10 -05:00
app = DummyApp.new(ENV["RAILS_ENV"])
app.start_server do
2012-11-16 05:34:10 -05:00
describe "in #{app.environment}" do
let(:environment) { app.environment }
2012-11-13 15:28:15 -05:00
context "in a view" do
2012-11-16 05:34:10 -05:00
let(:page) { app.get("/posts/1") }
2012-11-13 15:28:15 -05:00
it_behaves_like "a decorator in a view"
end
2012-11-13 15:28:15 -05:00
context "in a mailer" do
2012-11-16 05:34:10 -05:00
let(:page) { app.get("/posts/1/mail") }
2012-11-13 15:28:15 -05:00
it_behaves_like "a decorator in a view"
end
end
end
end