Permalink
Browse files

grabbing some schema metadata from rails and putting it in backbone

  • Loading branch information...
1 parent 95e425e commit b4d3212c5afb5516d869714e33e83e36346530f2 Chris Nelson committed Jun 6, 2012
View
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
# specify any dependencies here; for example:
- # s.add_development_dependency "rspec"
+ s.add_development_dependency "rspec"
s.add_runtime_dependency "haml_coffee_assets"
s.add_runtime_dependency "rails-backbone"
s.add_runtime_dependency "inflection-js-rails"
View
@@ -0,0 +1 @@
+--colour
View
@@ -18,7 +18,7 @@ group :assets do
gem "haml_coffee_assets"
gem "jasmine-ajax"
- gem "jasminerice-runner"
+ gem "jasminerice-runner"
gem "backtastic", :path => ".."
gem 'uglifier', '>= 1.0.3'
end
@@ -27,6 +27,9 @@ gem 'jquery-rails'
gem "jasminerice"
gem "capybara-webkit"
+gem "rspec-rails"
+gem "rspec-given"
+
gem "inherited_resources"
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
@@ -3,6 +3,7 @@
#= require_tree ./models
#= require_tree ./views
#= require_tree ./routers
+#= require ./rails_metadata
window.Example =
Models: {}
@@ -0,0 +1,6 @@
+<% ActiveRecord::Base.descendants.each do |model| %>
+ Example.Models["<%= model.to_s %>"].schema = <%= Backtastic.schema_for(model).to_json %>
+ <% model.columns.each do |col| %>
+ <%= col.name %>: "<%= col.type.to_s %>"
+ <% end %>
+<% end %>
@@ -0,0 +1,6 @@
+require 'spec_helper'
+
+describe "schema_for" do
+ Given(:person_schema) { Backtastic.schema_for(Person) }
+ Then { person_schema["first_name"]["type"].should == "string" }
+end
@@ -0,0 +1,33 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+require 'rspec/given'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+end
View
@@ -6,4 +6,7 @@
module Backtastic
class BacktasticEngine < Rails::Engine
end
+
+ def self.schema_for(model)
+ end
end

0 comments on commit b4d3212

Please sign in to comment.