draper/spec/integration/integration_spec.rb

51 lines
1.3 KiB
Ruby
Raw Normal View History

require 'spec_helper'
require 'support/dummy_app'
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_css "#environment", text: environment
# it can use path helpers with a model
page.should have_css "#path_with_model", text: "/en/posts/1"
# it can use path helpers with an id
page.should have_css "#path_with_id", text: "/en/posts/1"
# it can use url helpers with a model
page.should have_css "#url_with_model", text: "http://www.example.com/en/posts/1"
# it can use url helpers with an id
page.should have_css "#url_with_id", text: "http://www.example.com/en/posts/1"
end
end
describe "integration" do
include Capybara::DSL
2012-11-13 15:28:15 -05:00
rails_env = ENV["RAILS_ENV"].to_s
raise ArgumentError, "RAILS_ENV must be development or production" unless ["development", "production"].include?(rails_env)
2012-11-13 15:28:15 -05:00
app = DummyApp.new(rails_env)
app.start_server do
2012-11-13 15:28:15 -05:00
describe "in #{rails_env}" do
let(:environment) { rails_env }
before { Capybara.app_host = app.url }
2012-11-13 15:28:15 -05:00
context "in a view" do
before { visit("/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
before { visit("/posts/1/mail") }
2012-11-13 15:28:15 -05:00
it_behaves_like "a decorator in a view"
end
end
end
end