lawrencepit-remarkable_paperclip 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/en.yml CHANGED
@@ -7,9 +7,12 @@ en:
7
7
  defined: "{{subject_name}} has {{attribute}} as an attached file"
8
8
  has_column: "table {{table_name}} to have column {{column_name}}, but it does not"
9
9
  styles_match: "{{subject_name}} to have attached file {{attribute}} with styles {{styles}}, got {{actual}}"
10
+ default_style_match: "{{subject_name}} to have attached file {{attribute}} with default style {{style}}, got {{actual}}"
10
11
  optionals:
11
12
  styles:
12
13
  positive: "with styles {{inspect}}"
14
+ default_style:
15
+ positive: "with default style {{value}}"
13
16
  validate_attachment_size:
14
17
  description: "validate size for attached file {{attribute}}"
15
18
  expectations:
@@ -4,9 +4,9 @@ module Remarkable
4
4
  class HaveAttachedFileMatcher < Remarkable::ActiveRecord::Base
5
5
  arguments :attribute
6
6
 
7
- optionals :styles
7
+ optionals :styles, :default_style
8
8
 
9
- assertions :defined?, :has_column?, :styles_match?
9
+ assertions :defined?, :has_column?, :styles_match?, :default_style_match?
10
10
 
11
11
  protected
12
12
  def defined?
@@ -24,12 +24,22 @@ module Remarkable
24
24
  actuals = attachment_definition[:styles].clone
25
25
  match = @options[:styles].all? do |key, value|
26
26
  actual = actuals.delete(key)
27
- (actual.instance_of?(Hash) ? actual[:geometry] : actual) == value
27
+ actual == value || case actual
28
+ when Hash then actual[:geometry]
29
+ when Array then actual[0]
30
+ else actual
31
+ end == value
28
32
  end
29
33
  return (match && actuals.size == 0),
30
34
  :styles => @options[:styles].inspect, :actual => attachment_definition[:styles].inspect
31
35
  end
32
36
 
37
+ def default_style_match?
38
+ return true unless @options.key?(:default_style)
39
+ return @options[:default_style] == attachment_definition[:default_style],
40
+ :style => @options[:default_style].inspect, :actual => attachment_definition[:default_style].inspect
41
+ end
42
+
33
43
  private
34
44
  def attachment_definition
35
45
  @subject.class.attachment_definitions[@attribute]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lawrencepit-remarkable_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lawrence Pit