Browse files

* initial commit

  • Loading branch information...
1 parent 849447c commit 37b914937f2e693967c197bee95620fa07573f8a @mtarnovan committed Jun 1, 2012
View
4 Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in sinon-rails.gemspec
+gemspec
View
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Mihai Tarnovan
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
10 README.md
@@ -1,4 +1,12 @@
jasmine-sinon-rails
===================
-jasmine-sinon.js matchers via Rails 3.1+ asset pipeline
+<<<<<<< HEAD
+jasmine-sinon.js matchers via Rails 3.1+ asset pipeline
+=======
+jasmine-sinon matchers via Rails 3.1+ asset pipeline
+
+See https://github.com/froots/jasmine-sinon
+
+In Gemfile... you know the drill.
+>>>>>>> * initial commit
View
2 Rakefile
@@ -0,0 +1,2 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
View
16 jasmine-sinon-rails.gemspec
@@ -0,0 +1,16 @@
+$:.push File.expand_path("../lib", __FILE__)
+require File.expand_path('../lib/jasmine-sinon-rails/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Mihai Tarnovan"]
+ gem.email = ["mihai.tarnovan@cubus.ro"]
+ gem.summary = %q{jasmine-sinon.js matchers via Rails 3.1+ asset pipeline}
+ gem.homepage = "https://github.com/mtarnovan/jasmine-sinon-rails"
+
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.name = "jasmine-sinon-rails"
+ gem.require_paths = ["lib"]
+ gem.version = JasmineSinon::Rails::VERSION
+end
View
7 lib/jasmine-sinon-rails/engine.rb
@@ -0,0 +1,7 @@
+module Sinon
+ module Rails
+ class Engine < ::Rails::Engine
+ # making class enables assets pipeline
+ end
+ end
+end
View
5 lib/jasmine-sinon-rails/version.rb
@@ -0,0 +1,5 @@
+module Sinon
+ module Rails
+ VERSION = "1.3.2.1"
+ end
+end
View
7 lib/sinon-rails.rb
@@ -0,0 +1,7 @@
+require "jasmine-sinon-rails/version"
+
+module JasmineSinon
+ module Rails
+ require 'jasmine-sinon-rails/engine' if defined?(Rails)
+ end
+end
View
43 vendor/assets/javascripts/jasmine-sinon.js
@@ -0,0 +1,43 @@
+(function(global) {
+
+ var spyMatchers = "called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly".split(" "),
+ i = spyMatchers.length,
+ spyMatcherHash = {},
+ unusualMatchers = {
+ "returned": "toHaveReturned",
+ "alwaysReturned": "toHaveAlwaysReturned",
+ "threw": "toHaveThrown",
+ "alwaysThrew": "toHaveAlwaysThrown"
+ },
+
+ getMatcherFunction = function(sinonName) {
+ return function() {
+ var sinonProperty = this.actual[sinonName];
+ return (typeof sinonProperty === 'function') ? sinonProperty.apply(this.actual, arguments) : sinonProperty;
+ };
+ };
+
+ while(i--) {
+ var sinonName = spyMatchers[i],
+ matcherName = "toHaveBeen" + sinonName.charAt(0).toUpperCase() + sinonName.slice(1);
+
+ spyMatcherHash[matcherName] = getMatcherFunction(sinonName);
+ };
+
+ for (var j in unusualMatchers) {
+ spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j);
+ }
+
+ global.sinonJasmine = {
+ getMatchers: function() {
+ return spyMatcherHash;
+ }
+ };
+
+})(window);
+
+beforeEach(function() {
+
+ this.addMatchers(sinonJasmine.getMatchers());
+
+});

0 comments on commit 37b9149

Please sign in to comment.