make jasmine view tests work, load templates, party
This commit is contained in:
parent
4883c70ae2
commit
8e3db3aebe
10 changed files with 57 additions and 43 deletions
|
|
@ -74,7 +74,6 @@
|
|||
%header{:class=>('landing' unless current_user)}
|
||||
= render 'layouts/header'
|
||||
|
||||
- if @backbone
|
||||
= render 'templates/templates'
|
||||
|
||||
.container{:style=> "#{yield(:break_the_mold)}"}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@
|
|||
<time class="timeago" datetime="<%= created_at %>"/>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<p class="post-text">
|
||||
<%= text %>
|
||||
</p>
|
||||
|
||||
|
|
@ -70,5 +71,4 @@
|
|||
<div class="comments"> </div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ describe MultisController do
|
|||
|
||||
describe 'jasmine fixtures' do
|
||||
it 'generate' do
|
||||
status_message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
|
||||
status_message = alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id)
|
||||
get :index, :format => :json
|
||||
save_fixture(response.body, "multi_stream_json")
|
||||
end
|
||||
|
|
|
|||
9
spec/jasmine_fixtures/template_spec.rb
Normal file
9
spec/jasmine_fixtures/template_spec.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe "template generation" do
|
||||
it "generates templates" do
|
||||
extend JasmineFixtureGeneration
|
||||
templates = Haml::Engine.new(Rails.root.join("app", "views", "templates", "_templates.haml").read).render
|
||||
save_fixture(templates, "underscore_templates")
|
||||
end
|
||||
end
|
||||
|
|
@ -2,14 +2,18 @@ describe("App.views.Stream", function(){
|
|||
|
||||
describe("#render", function(){
|
||||
beforeEach(function(){
|
||||
//hella hax
|
||||
spec.loadFixture("multi_stream_json")
|
||||
var fixtureStream = $.parseJSON($("#jasmine_content").html())
|
||||
// should be jasmine helper
|
||||
window.current_user = App.user({name: "alice", avatar : {small : "http://avatar.com"}});
|
||||
|
||||
this.statusMessage = new App.Models.Post(fixtureStream["posts"][0] );
|
||||
//hella hax
|
||||
spec.loadFixture("multi_stream_json");
|
||||
var posts = $.parseJSON($("#jasmine_content").html())["posts"]
|
||||
spec.loadFixture("underscore_templates");
|
||||
|
||||
this.collection = new App.Collections.Stream(posts)
|
||||
this.statusMessage = this.collection.models[0];
|
||||
// this.picture = new App.Models.Post({post_type : "ActivityStreams::Photo", image_url : "http://amazonks.com/pretty_picture_lol.gif"});
|
||||
|
||||
this.collection = new App.Collections.Stream([this.statusMessage]);
|
||||
this.view = new App.Views.Stream({collection : this.collection});
|
||||
this.view.render();
|
||||
this.statusElement = $(this.view.$("#" + this.statusMessage.get("guid")));
|
||||
|
|
@ -18,8 +22,7 @@ describe("App.views.Stream", function(){
|
|||
|
||||
context("when rendering a Status Mesasage", function(){
|
||||
it("shows the status message in the content area", function(){
|
||||
// we need to load the underscore templates here, otherwise our views won't render!
|
||||
expect(this.statusElement.find(".post-content p")).toBe("hella infos yo!")
|
||||
expect($.trim(this.statusElement.find(".content p.post-text").text())).toBe("hella infos yo!")
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
RSpec::Rails::ControllerExampleGroup.class_eval do
|
||||
|
||||
module JasmineFixtureGeneration
|
||||
# Saves the markup to a fixture file using the given name
|
||||
def save_fixture(markup, name, fixture_path=nil )
|
||||
fixture_path = File.join(Rails.root, 'tmp', 'js_dom_fixtures') unless fixture_path
|
||||
|
|
@ -41,3 +40,7 @@ RSpec::Rails::ControllerExampleGroup.class_eval do
|
|||
end
|
||||
end
|
||||
|
||||
RSpec::Rails::ControllerExampleGroup.class_eval do
|
||||
include JasmineFixtureGeneration
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue