Sha256: 3bc676ed5dd16d456fce678985f8cd3871b3cf247a0752fe5aed5bc55caebd36
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") module BangBang describe Views do describe "#[]" do it "returns an object with a render method, which invokes the given method name" do view = BangBang::Views.new(Object.new) mock(view, "true_car_makes") view["true_car_makes"].render end describe "lazily created method" do context "when the presenter file exists" do it "evals the presenter file (which is responsible for adding the method)" do authentication_path = "#{FixtureApp.root_dir}/services/authentication" service = Service.new(authentication_path).init app_instance = Object.new stub(app_instance).services {[service]} stub(app_instance).config {FixtureApp} views = Class.new(BangBang::Views).new(app_instance) html = views["/authentication/index.html.ms"].call("param1 value") html.should include("param1 value") doc = Nokogiri::HTML(html) doc.at(".child-div").should be_present end end context "when the presenter file does not exist" do it "lazily creates a method that render the mustache template for the given path" do app_instance = Object.new app_instance.class.send(:define_method, :config) do FixtureApp end views = Class.new(BangBang::Views).new(app_instance) views.respond_to?("/user/pagelets/i-dont-exist").should be_false views["/user/pagelets/i-dont-exist"] views.respond_to?("/user/pagelets/i-dont-exist").should be_true end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bang-bang-0.2.0 | spec/bang-bang/views_spec.rb |
bang-bang-0.1.6 | spec/bang-bang/views_spec.rb |