rspec-image 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b02d9c42686cac2cf8b201fd725ebd4fefd40719
4
+ data.tar.gz: 9a517427bf1ab98076aae7ca65cc15d91f746267
5
+ SHA512:
6
+ metadata.gz: 5a35f293a3acadca25b18c326b525f083c983aee785edaf154a26ffab87dd42e8e45e14fe92bfcf245f4f57278d644b2d66c16f438f8e16bf91cefbdd7ea6da6
7
+ data.tar.gz: a0620b4d8f959e84ab70e71d5db6dc0337dbc2c54cdaed51b2b74d42e5f014fe48ea40b082d9466f344d5638a50acb5ba6c8a8c2b701da3e121f957c18222179
@@ -0,0 +1,23 @@
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
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-image.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 namusyaka
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,63 @@
1
+ # RSpec::Image
2
+
3
+ Provides some matchers for testing your image file.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rspec-image'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rspec-image
18
+
19
+ ## Usage
20
+
21
+ ### `be_identical_with`
22
+
23
+ ```ruby
24
+ describe "thumbnail file" do
25
+ subject { "/path/to/something.jpg" }
26
+ it { should be_identical_with("/path/to/something.jpg") }
27
+ end
28
+ ```
29
+
30
+ ### `have_width`
31
+
32
+ ```ruby
33
+ describe "thumbnail file" do
34
+ subject { "/path/to/something.jpg" }
35
+ it { should have_width(400) }
36
+ end
37
+ ```
38
+
39
+ ### `have_height`
40
+
41
+ ```ruby
42
+ describe "thumbnail file" do
43
+ subject { "/path/to/something.jpg" }
44
+ it { should have_height(300) }
45
+ end
46
+ ```
47
+
48
+ ### `have_dimensions`
49
+
50
+ ```ruby
51
+ describe "thumbnail file" do
52
+ subject { "/path/to/something.jpg" }
53
+ it { should have_dimensions(400, 300) }
54
+ end
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it ( https://github.com/namusyaka/rspec-image/fork )
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run all specs."
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = 'spec/**/*_spec.rb'
7
+ spec.rspec_opts = "--color"
8
+ end
9
+ task default: :spec
@@ -0,0 +1 @@
1
+ require 'rspec/image'
@@ -0,0 +1,11 @@
1
+ require 'RMagick'
2
+ require 'rspec/image/version'
3
+ require 'rspec/image/matchers'
4
+
5
+ module RSpec
6
+ module Image
7
+ def self.included(base)
8
+ base.send :include, RSpec::Image::Matchers
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module RSpec::Image
2
+ module Matchers
3
+ require 'rspec/image/matchers/identical_with'
4
+ require 'rspec/image/matchers/have_width'
5
+ require 'rspec/image/matchers/have_height'
6
+ require 'rspec/image/matchers/have_dimensions'
7
+
8
+ def self.included(base)
9
+ base.send :include, IdenticalWith
10
+ base.send :include, HaveWidth
11
+ base.send :include, HaveHeight
12
+ base.send :include, HaveDimensions
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module RSpec::Image::Matchers
2
+ module HaveDimensions
3
+ extend RSpec::Matchers::DSL
4
+
5
+ matcher :have_dimensions do |*expected|
6
+ match do |path|
7
+ image = Magick::Image.read(path).first
8
+ @expected_size = expected
9
+ @actual_size = [image.columns, image.rows]
10
+ @expected_size == @actual_size
11
+ end
12
+
13
+ failure_message do |actual|
14
+ "expected #{actual} to have an size (width: #{@expected_size[0]}, height: #{@expected_size[1]})"\
15
+ ", got (width: #{@actual_size[0]}, height: #{@actual_size[1]})"
16
+ end
17
+
18
+ failure_message_when_negated do |actual|
19
+ "expected #{actual} not to have an size (width: #{@expected_size[0]}, height: #{@expected_size[1]})"\
20
+ ", got (width: #{@actual_size[0]}, height: #{@actual_size[1]})"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module RSpec::Image::Matchers
2
+ module HaveHeight
3
+ extend RSpec::Matchers::DSL
4
+
5
+ matcher :have_height do |height|
6
+ match do |path|
7
+ image = Magick::Image.read(path).first
8
+ @expected_height = height
9
+ @actual_height = image.rows
10
+ @expected_height == @actual_height
11
+ end
12
+
13
+ failure_message do |actual|
14
+ "expected #{actual} to have height(#{@expected_height}), got (height: #{@actual_height})"
15
+ end
16
+
17
+ failure_message_when_negated do |actual|
18
+ "expected #{actual} not to have height(#{@expected_height}), got (height: #{@actual_height})"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module RSpec::Image::Matchers
2
+ module HaveWidth
3
+ extend RSpec::Matchers::DSL
4
+
5
+ matcher :have_width do |width|
6
+ match do |path|
7
+ image = Magick::Image.read(path).first
8
+ @expected_width = width
9
+ @actual_width = image.columns
10
+ @expected_width == @actual_width
11
+ end
12
+
13
+ failure_message do |actual|
14
+ "expected #{actual} to have width(#{@expected_width}), got (width: #{@actual_width})"
15
+ end
16
+
17
+ failure_message_when_negated do |actual|
18
+ "expected #{actual} not to have width(#{@expected_width}), got (width: #{@actual_width})"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'fileutils'
2
+
3
+ module RSpec::Image::Matchers
4
+ module IdenticalWith
5
+ extend RSpec::Matchers::DSL
6
+
7
+ matcher :be_identical_with do |expected_path|
8
+ match do |actual_path|
9
+ @actual_path = actual_path
10
+ @expected_path = expected_path
11
+ FileUtils.identical?(@actual_path, @expected_path)
12
+ end
13
+
14
+ failure_message do
15
+ "expected #{@actual_path} to be identical with #{@expected_path}"
16
+ end
17
+
18
+ failure_message_when_negated do
19
+ "expected #{@actual_path} not to be identical with #{@expected_path}"
20
+ end
21
+ end
22
+
23
+ alias be_identical_to be_identical_with
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Image
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/image/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-image"
8
+ spec.version = RSpec::Image::VERSION
9
+ spec.authors = ["namusyaka"]
10
+ spec.email = ["namusyaka@gmail.com"]
11
+ spec.summary = %q{Provides some matchers for testing your image file.}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/namusyaka/rspec-image"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_runtime_dependency "rmagick"
22
+ spec.add_runtime_dependency "rspec"
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ end
Binary file
@@ -0,0 +1,12 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+
3
+ RSpec.describe RSpec::Image do
4
+ it "can be included" do
5
+ expect { include RSpec::Image }.not_to raise_error
6
+ end
7
+
8
+ it "should include child modules automatically" do
9
+ module Foo; include RSpec::Image; end
10
+ expect(Foo).to include(RSpec::Image::Matchers::IdenticalWith)
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ RSpec.describe RSpec::Image::Matchers::HaveDimensions do
4
+ describe "#have_dimensions" do
5
+ context "with valid arguments" do
6
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
7
+ it { should have_dimensions(400, 300) }
8
+ end
9
+
10
+ context "with invalid arguments" do
11
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
12
+ it { should_not have_dimensions(300, 300) }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ RSpec.describe RSpec::Image::Matchers::HaveHeight do
4
+ describe "#have_height" do
5
+ context "with valid arguments" do
6
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
7
+ it { should have_height(300) }
8
+ end
9
+
10
+ context "with invalid arguments" do
11
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
12
+ it { should_not have_height(400) }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ RSpec.describe RSpec::Image::Matchers::HaveWidth do
4
+ describe "#have_width" do
5
+ context "with valid arguments" do
6
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
7
+ it { should have_width(400) }
8
+ end
9
+
10
+ context "with invalid arguments" do
11
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
12
+ it { should_not have_width(300) }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ RSpec.describe RSpec::Image::Matchers::IdenticalWith do
4
+ describe "#be_identical_with" do
5
+ subject { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
6
+ context "with valid arguments" do
7
+ let(:target) { File.expand_path("../../../fixtures/sample.jpg", __FILE__) }
8
+ it { should be_identical_with(target) }
9
+ it { should be_identical_to(target) }
10
+ end
11
+
12
+ context "with invalid arguments" do
13
+ let(:target) { File.expand_path("../../../fixtures/black_sample.jpg", __FILE__) }
14
+ it { should_not be_identical_with(target) }
15
+ it { should_not be_identical_to(target) }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path("../../lib/rspec/image", __FILE__)
2
+ require 'rspec'
3
+ require 'rspec-image'
4
+
5
+ RSpec.configure do |config|
6
+ config.include RSpec::Image
7
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-image
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - namusyaka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides some matchers for testing your image file.
70
+ email:
71
+ - namusyaka@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/rspec-image.rb
82
+ - lib/rspec/image.rb
83
+ - lib/rspec/image/matchers.rb
84
+ - lib/rspec/image/matchers/have_dimensions.rb
85
+ - lib/rspec/image/matchers/have_height.rb
86
+ - lib/rspec/image/matchers/have_width.rb
87
+ - lib/rspec/image/matchers/identical_with.rb
88
+ - lib/rspec/image/version.rb
89
+ - rspec-image.gemspec
90
+ - spec/fixtures/black_sample.jpg
91
+ - spec/fixtures/sample.jpg
92
+ - spec/rspec/image_spec.rb
93
+ - spec/rspec/matchers/have_dimensions_spec.rb
94
+ - spec/rspec/matchers/have_height_spec.rb
95
+ - spec/rspec/matchers/have_width_spec.rb
96
+ - spec/rspec/matchers/identical_with_spec.rb
97
+ - spec/spec_helper.rb
98
+ homepage: https://github.com/namusyaka/rspec-image
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Provides some matchers for testing your image file.
122
+ test_files:
123
+ - spec/fixtures/black_sample.jpg
124
+ - spec/fixtures/sample.jpg
125
+ - spec/rspec/image_spec.rb
126
+ - spec/rspec/matchers/have_dimensions_spec.rb
127
+ - spec/rspec/matchers/have_height_spec.rb
128
+ - spec/rspec/matchers/have_width_spec.rb
129
+ - spec/rspec/matchers/identical_with_spec.rb
130
+ - spec/spec_helper.rb
131
+ has_rdoc: