liquid_stream-matchers 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3026441a01f9ded7ec6ebcf4f2bd274dfc87390d
4
+ data.tar.gz: 5cd3885a3a6659be43afc5214df7fe8785223cd5
5
+ SHA512:
6
+ metadata.gz: 1767f5299917048e12885aa912aee7ff9d5564d2edc519892bec3b32a5bb70a0e9c028d746aba338d9b2b5e8bf68eee3c5a3d9588a3800e3275bf8b9ac8eb9ef
7
+ data.tar.gz: 6e9da840f2e8870da774d946c9617cebe264355606ebe121c4ca9e6d13cdd20d8e506b6d080286b83ec6e9951797df9cc6b7caf105dc69e8f74875c334945aef
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1 @@
1
+ ruby-2.1.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in liquid_stream-matchers.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # LiquidStream::Matchers
2
+
3
+ Add should-style matchers to test your [liquid streams](https://github.com/ramontayag/liquid_stream).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'liquid_stream-matchers'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install liquid_stream-matchers
18
+
19
+ ## Usage
20
+
21
+ Add this to your `spec_helper.rb`:
22
+
23
+ require "liquid_stream/matchers"
24
+
25
+ Then use it:
26
+
27
+ class BlogStream
28
+
29
+ stream :posts
30
+ stream :popular_posts, as: PopularPosts
31
+
32
+ end
33
+
34
+
35
+ describe BlogStream
36
+
37
+ it { should stream(:posts) }
38
+ it { should stream(:posts).as(PopularPosts) }
39
+
40
+ end
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require "liquid_stream/matchers/version"
2
+ require "liquid_stream/matchers/stream"
3
+ require "liquid_stream/matchers/rspec"
4
+
5
+ module LiquidStream
6
+ module Matchers
7
+ def stream(expected)
8
+ Stream.new(expected)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec/core'
2
+
3
+ RSpec.configure do |config|
4
+ require 'liquid_stream/matchers'
5
+ config.include LiquidStream::Matchers
6
+ end
@@ -0,0 +1,49 @@
1
+ module LiquidStream
2
+ module Matchers
3
+ class Stream
4
+ def initialize(attr_name)
5
+ @attr_name = attr_name
6
+ end
7
+
8
+ def matches?(klass)
9
+ @klass = klass
10
+ key_exists? && options_correct?
11
+ end
12
+
13
+ def as(as)
14
+ @as = as
15
+ self
16
+ end
17
+
18
+ def failure_message
19
+ base_message = %Q(expected #{@klass} to stream `#{@attr_name}`)
20
+ if defined? @as
21
+ base_message += " as `#{@as}`"
22
+ end
23
+ base_message
24
+ end
25
+
26
+ def description
27
+ "Ensures that #{@klass} streams #{@attr_name}."
28
+ end
29
+
30
+ private
31
+
32
+ def key_exists?
33
+ @klass.liquid_streams.has_key?(@attr_name)
34
+ end
35
+
36
+ def options_correct?
37
+ if defined? @as
38
+ as = @klass.liquid_streams.fetch(@attr_name).
39
+ fetch(:options)[:as]
40
+ as = as.constantize if as.respond_to?(:constantize)
41
+ as == @as
42
+ else
43
+ true
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ module LiquidStream
2
+ module Matchers
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'liquid_stream/matchers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "liquid_stream-matchers"
8
+ spec.version = LiquidStream::Matchers::VERSION
9
+ spec.authors = ["Ramon Tayag"]
10
+ spec.email = ["ramon.tayag@gmail.com"]
11
+ spec.description = %q{Provides shoulda style matchers for liquid_stream}
12
+ spec.summary = %q{Provides shoulda style matchers for liquid_stream}
13
+ spec.homepage = "https://github.com/ramontayag/liquid_stream-matchers"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_dependency "liquid_stream"
26
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ class Blog; end
4
+
5
+ class Post; end
6
+
7
+ class PostsStream < LiquidStream::Streams; end
8
+
9
+ class BlogStream < LiquidStream::Stream
10
+ stream :posts
11
+ stream :blog_posts, as: PostsStream
12
+ end
13
+
14
+ describe BlogStream do
15
+
16
+ it { should stream(:posts) }
17
+ it { should stream(:blog_posts).as(PostsStream) }
18
+
19
+ end
@@ -0,0 +1,10 @@
1
+ require "liquid_stream"
2
+ require "liquid_stream/matchers/rspec"
3
+ require "pry"
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ config.order = 'random'
10
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liquid_stream-matchers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ramon Tayag
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: liquid_stream
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides shoulda style matchers for liquid_stream
70
+ email:
71
+ - ramon.tayag@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - .ruby-version.sample
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/liquid_stream/matchers.rb
84
+ - lib/liquid_stream/matchers/rspec.rb
85
+ - lib/liquid_stream/matchers/stream.rb
86
+ - lib/liquid_stream/matchers/version.rb
87
+ - liquid_stream-matchers.gemspec
88
+ - spec/liquid_stream/matchers_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: https://github.com/ramontayag/liquid_stream-matchers
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Provides shoulda style matchers for liquid_stream
114
+ test_files:
115
+ - spec/liquid_stream/matchers_spec.rb
116
+ - spec/spec_helper.rb