resque_spec 0.3.1 → 0.4.0

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.
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem "jeweler", ">= 1.4.0"
4
- gem "resque", ">= 1.6.0"
5
- gem "rspec", ">= 2.0.0.beta.14"
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ resque_spec (0.3.1)
5
+ resque (>= 1.6.0)
6
+ rspec (>= 2.0.0.beta.12)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.1.2)
12
+ gemcutter (0.6.1)
13
+ git (1.2.5)
14
+ jeweler (1.4.0)
15
+ gemcutter (>= 0.1.0)
16
+ git (>= 1.2.5)
17
+ rubyforge (>= 2.0.0)
18
+ json (1.4.6)
19
+ json_pure (1.4.6)
20
+ rack (1.2.1)
21
+ redis (2.0.8)
22
+ redis-namespace (0.8.0)
23
+ redis (< 3.0.0)
24
+ resque (1.10.0)
25
+ json (~> 1.4.6)
26
+ redis-namespace (~> 0.8.0)
27
+ sinatra (>= 0.9.2)
28
+ vegas (~> 0.1.2)
29
+ rspec (2.0.0.beta.22)
30
+ rspec-core (= 2.0.0.beta.22)
31
+ rspec-expectations (= 2.0.0.beta.22)
32
+ rspec-mocks (= 2.0.0.beta.22)
33
+ rspec-core (2.0.0.beta.22)
34
+ rspec-expectations (2.0.0.beta.22)
35
+ diff-lcs (>= 1.1.2)
36
+ rspec-mocks (2.0.0.beta.22)
37
+ rspec-core (= 2.0.0.beta.22)
38
+ rspec-expectations (= 2.0.0.beta.22)
39
+ rubyforge (2.0.4)
40
+ json_pure (>= 1.1.7)
41
+ sinatra (1.0)
42
+ rack (>= 1.0)
43
+ vegas (0.1.7)
44
+ rack (>= 1.0.0)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ jeweler (>= 1.4.0)
51
+ resque (>= 1.6.0)
52
+ resque_spec!
53
+ rspec (>= 2.0.0.beta.12)
data/README.md CHANGED
@@ -104,6 +104,22 @@ Then I write some code to make it pass:
104
104
  end
105
105
  end
106
106
 
107
+ Queue Size Specs
108
+ ----------------
109
+
110
+ You can check the size of the queue in your specs too.
111
+
112
+ describe "#recalculate" do
113
+ before do
114
+ ResqueSpec.reset!
115
+ end
116
+
117
+ it "adds an entry to the Person queue" do
118
+ person.recalculate
119
+ Person.should have_queue_size_of(1)
120
+ end
121
+ end
122
+
107
123
  Note on Patches/Pull Requests
108
124
  =============================
109
125
 
data/Rakefile CHANGED
@@ -1,12 +1,9 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
1
  begin
5
2
  require 'jeweler'
6
3
  Jeweler::Tasks.new do |gem|
7
4
  gem.name = "resque_spec"
8
- gem.summary = %Q{RSpec matchers for Resque}
9
- gem.description = %Q{RSpec matchers for Resque}
5
+ gem.summary = %{RSpec matchers for Resque}
6
+ gem.description = %{RSpec matchers for Resque}
10
7
  gem.email = "leshill@gmail.com"
11
8
  gem.homepage = "http://github.com/leshill/resque_spec"
12
9
  gem.authors = ["Les Hill"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -18,6 +18,10 @@ module ResqueSpec
18
18
  raise ::Resque::NoQueueError.new("Jobs must be placed onto a queue.")
19
19
  end
20
20
 
21
+ def queue_size(klass)
22
+ queue_for(klass).size
23
+ end
24
+
21
25
  def queues
22
26
  @queues ||= Hash.new {|h,k| h[k] = []}
23
27
  end
@@ -59,7 +63,24 @@ RSpec::Matchers.define :have_queued do |*expected_args|
59
63
  end
60
64
 
61
65
  description do
62
- "have queued arguments"
66
+ "have queued arguments of [#{expected_args.join(', ')}]"
63
67
  end
64
68
  end
65
69
 
70
+ RSpec::Matchers.define :have_queue_size_of do |size|
71
+ match do |actual|
72
+ ResqueSpec.queue_size(actual) == size
73
+ end
74
+
75
+ failure_message_for_should do |actual|
76
+ "expected that #{actual} would have #{size} entries queued"
77
+ end
78
+
79
+ failure_message_for_should_not do |actual|
80
+ "expected that #{actual} would not have #{size} entries queued"
81
+ end
82
+
83
+ description do
84
+ "have a queue size of #{size}"
85
+ end
86
+ end
data/lib/resque_spec.rb CHANGED
@@ -2,5 +2,5 @@ require 'resque_spec/resque_spec'
2
2
  require 'resque_spec/resque_scheduler_spec'
3
3
 
4
4
  module ResqueSpec
5
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.4.0'.freeze
6
6
  end
data/resque_spec.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{resque_spec}
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Les Hill"]
12
- s.date = %q{2010-08-18}
12
+ s.date = %q{2010-09-16}
13
13
  s.description = %q{RSpec matchers for Resque}
14
14
  s.email = %q{leshill@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  ".rspec",
23
23
  ".rvmrc",
24
24
  "Gemfile",
25
+ "Gemfile.lock",
25
26
  "LICENSE",
26
27
  "README.md",
27
28
  "Rakefile",
@@ -53,6 +53,13 @@ describe "ResqueSpec" do
53
53
  end
54
54
  end
55
55
 
56
+ describe "#queue_size" do
57
+
58
+ before { 3.times { ResqueSpec.queue_for(Account) << 'queued' }}
59
+ subject { ResqueSpec.queue_size(Account) }
60
+ it { should == 3 }
61
+ end
62
+
56
63
  describe "#reset!" do
57
64
  it "clears the queues" do
58
65
  ResqueSpec.queue_for(Person) << 'queued'
@@ -101,14 +108,15 @@ describe "ResqueSpec" do
101
108
  Resque.enqueue(Person, first_name, last_name)
102
109
  end
103
110
 
111
+ subject { Person }
112
+
104
113
  describe "#have_queued" do
105
- it "returns true if the arguments are found in the queue" do
106
- Person.should have_queued(first_name, last_name)
107
- end
114
+ it { should have_queued(first_name, last_name) }
115
+ it { should_not have_queued(last_name, first_name) }
116
+ end
108
117
 
109
- it "returns false if the arguments are not found in the queue" do
110
- Person.should_not have_queued(last_name, first_name)
111
- end
118
+ describe "#have_queue_size_of" do
119
+ it { should have_queue_size_of(1) }
112
120
  end
113
121
  end
114
122
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'rspec'
4
- require 'rspec/autorun'
5
4
  require 'resque_spec'
6
5
 
7
6
  Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_spec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Les Hill
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-18 00:00:00 -04:00
18
+ date: 2010-09-16 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -83,6 +83,7 @@ files:
83
83
  - .rspec
84
84
  - .rvmrc
85
85
  - Gemfile
86
+ - Gemfile.lock
86
87
  - LICENSE
87
88
  - README.md
88
89
  - Rakefile