require File.dirname(__FILE__) + '/spec_helper.rb' require "rack" require 'rack/test' require_fixtures 'component_spec_components' describe Trellis::Component, " in an application" do include Rack::Test::Methods def app TestComponents::ApplicationWithComponents.new end it "should return its intended content" do get '/' last_response.body.should include("hello from simple component") end it "should render each instance of a component in the template" do get '/counters' counter_one_markup = %[
0++--
] counter_two_markup = %[
0++--
] counter_three_markup = %[
0++--1] counter_two_markup = %[
0] counter_three_markup = %[
0] last_response.body.should include(counter_one_markup) last_response.body.should include(counter_two_markup) last_response.body.should include(counter_three_markup) end it "should be able to provide a style link contribution to the page" do get '/page_with_contributions' last_response.body.should include(%[]) end it "should be able to provide a script link contribution to the page" do get '/page_with_contributions' last_response.body.should include(%[]) last_response.body.should include(%[]) end it "should be able to provide a script contribution per class" do get '/page_with_contributions' last_response.body.should include(%[alert('hello just once');]) end it "should be able to provide a dom modification block" do get '/page_with_contributions' last_response.body.scan(%[]).should have_exactly(1).match end end