dupe 0.4.3 → 0.4.4

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/README.rdoc CHANGED
@@ -28,6 +28,16 @@ Lastly, from your rails project root, run:
28
28
 
29
29
  # script/generate dupe
30
30
 
31
+ That last command will create the following directories:
32
+
33
+ - RAILS_ROOT/features/dupe
34
+ - RAILS_ROOT/features/dupe/definitions
35
+ - RAILS_ROOT/features/dupe/custom_mocks
36
+
37
+ It will also place example Dupe definitions in RAILS_ROOT/features/dupe/definitions/definitions.rb as well as example custom mocks in RAILS_ROOT/features/dupe/custom_mocks/custom_mocks.rb
38
+
39
+ Lastly, it will add a load_dupe.rb file (that loads up the definitions and custom mocks) to RAILS_ROOT/features/support/load_dupe.rb
40
+
31
41
 
32
42
  = Features
33
43
 
data/lib/dupe/dupe.rb CHANGED
@@ -148,12 +148,12 @@ class Dupe
148
148
  mocks = %{
149
149
  network.define_service_mock(
150
150
  :get,
151
- %r{/#{model_name.to_s.pluralize}\\.xml$},
151
+ %r{^#{model_name.to_s.titleize.constantize.prefix rescue '/'}#{model_name.to_s.pluralize}\\.xml$},
152
152
  proc { Dupe.find(:#{model_name.to_s.pluralize}) }
153
153
  )
154
154
  network.define_service_mock(
155
155
  :get,
156
- %r{/#{model_name.to_s.pluralize}/(\\d+)\\.xml$},
156
+ %r{^#{model_name.to_s.titleize.constantize.prefix rescue '/'}#{model_name.to_s.pluralize}/(\\d+)\\.xml$},
157
157
  proc {|id| Dupe.find(:#{model_name}) {|resource| resource.id == id.to_i}}
158
158
  )
159
159
  }
@@ -113,7 +113,7 @@ describe Dupe do
113
113
  Dupe.database.tables[:book].should == []
114
114
  end
115
115
 
116
- it "should add find(:all) and find(<id>) mocks to the database" do
116
+ it "should add find(:all) and find(<id>) mocks to the network" do
117
117
  Dupe.network.mocks[:get].should be_empty
118
118
  Dupe.create :book
119
119
  Dupe.network.mocks[:get].should_not be_empty
@@ -121,15 +121,32 @@ describe Dupe do
121
121
 
122
122
  find_all_mock = Dupe.network.mocks[:get].first
123
123
  find_all_mock.verb.should == :get
124
- find_all_mock.url_pattern.should == %r{/books\.xml$}
124
+ find_all_mock.url_pattern.should == %r{^/books\.xml$}
125
125
  find_all_mock.mocked_response('/books.xml').should == Dupe.find(:books).to_xml(:root => 'books')
126
126
 
127
127
  find_one_mock = Dupe.network.mocks[:get].last
128
128
  find_one_mock.verb.should == :get
129
- find_one_mock.url_pattern.should == %r{/books/(\d+)\.xml$}
129
+ find_one_mock.url_pattern.should == %r{^/books/(\d+)\.xml$}
130
130
  find_one_mock.mocked_response('/books/1.xml').should == Dupe.find(:book).to_xml(:root => 'book')
131
131
  end
132
132
 
133
+ it "should honor ActiveResource site prefix's for the find(:all) and find(<id>) mocks" do
134
+ Dupe.network.mocks[:get].should be_empty
135
+ class Author < ActiveResource::Base; self.site='http://somewhere.com/book_services'; end
136
+ Dupe.create :author
137
+ Dupe.network.mocks[:get].should_not be_empty
138
+ Dupe.network.mocks[:get].length.should == 2
139
+
140
+ find_all_mock = Dupe.network.mocks[:get].first
141
+ find_all_mock.verb.should == :get
142
+ find_all_mock.url_pattern.should == %r{^/book_services/authors\.xml$}
143
+ find_all_mock.mocked_response('/book_services/authors.xml').should == Dupe.find(:authors).to_xml(:root => 'authors')
144
+
145
+ find_one_mock = Dupe.network.mocks[:get].last
146
+ find_one_mock.verb.should == :get
147
+ find_one_mock.url_pattern.should == %r{^/book_services/authors/(\d+)\.xml$}
148
+ find_one_mock.mocked_response('/book_services/authors/1.xml').should == Dupe.find(:author).to_xml(:root => 'author')
149
+ end
133
150
  end
134
151
 
135
152
  describe "create" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dupe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Parker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-01 00:00:00 -05:00
12
+ date: 2010-01-03 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency