File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def url_parameters
2525 end
2626
2727 def request_parameters
28- fail ( "Missing pattern" ) unless pattern
28+ fail ( "Missing pattern" ) if pattern . to_s . empty?
2929
3030 {
3131 :key => client . api_key ,
Original file line number Diff line number Diff line change 1111
1212 context "without client" do
1313 subject { Query . new }
14+
1415 it "should not work" do
1516 expect { subject } . to raise_error ( ArgumentError )
1617 end
3435 let ( :query ) { Query . new ( @client ) }
3536
3637 context "with valid pattern" do
37- before { allow_any_instance_of ( Query ) . to receive ( : pattern) . and_return ( '' ) }
38+ before { query . pattern = "christmas" }
3839 subject { query . url }
40+
3941 it { should include ( "xmloutputversion=2" ) }
4042 end
4143
4446 expect { query . url } . to raise_error ( RuntimeError , "Missing pattern" )
4547 end
4648 end
49+
50+ context "with empty pattern" do
51+ before { query . pattern = "" }
52+
53+ it "raises an error" do
54+ expect { query . url } . to raise_error ( RuntimeError , "Missing pattern" )
55+ end
56+ end
4757 end
4858
4959 context "with valid pattern" do
50- before { allow_any_instance_of ( Query ) . to receive ( :pattern ) . and_return ( '' ) }
60+ before { subject . pattern = "christmas" }
61+
5162 it "should add language" do
5263 subject . language = "en"
5364 expect ( subject . request_parameters ) . to include ( documentlang : 'en' )
7081 end
7182
7283 describe "#pattern" do
84+ before { subject . pattern = "spotify" }
85+
7386 it "should add searchpattern" do
74- subject . pattern = 'spotify'
7587 expect ( subject . url_parameters ) . to include ( "searchpattern=spotify" )
7688 end
7789 end
You can’t perform that action at this time.
0 commit comments