spec/firebrew/runner_spec.rb in firebrew-0.1.3 vs spec/firebrew/runner_spec.rb in firebrew-0.2.0

- old
+ new

@@ -148,18 +148,17 @@ let(:search_params){{term: 'hoge', version: '30.0', max: 1, os: Runner.default_config[:os]}} before do FileUtils.cp './spec/fixtures/firefox/profile/base.ini', './tmp/profiles.ini' response = File.read("./spec/fixtures/amo_api/search/base.xml") - ActiveResource::HttpMock.respond_to do |mock| - mock.get AmoApi::Search.path(self.search_params), {}, response - end + AmoApi::Search.connection = double(:connection) + allow(AmoApi::Search.connection).to receive(:get).and_return(OpenStruct.new body: response, status: 200) end after do FileUtils.rm_f './tmp/*' - ActiveResource::HttpMock.reset! + AmoApi::Search.connection = nil end describe '#install(params)' do subject do extensions_double = double('extensions', install: nil, find: nil) @@ -169,36 +168,42 @@ it { expect{subject}.to_not raise_error } context 'when the `params[:term]` existed' do subject do - extensions_double = double('extensions', install: nil, find: Firefox::BasicExtension.new) + extensions_double = double('extensions', install: nil, find: Firefox::BasicExtension.new(name: self.extension_name)) self.instance.profile = double('profile', extensions: extensions_double) self.instance.install(self.search_params) end - it { expect{subject}.to raise_error(Firebrew::OperationAlreadyCompletedError) } + let(:extension_name){'hoge'} + + it { expect{subject}.to raise_error(Firebrew::OperationAlreadyCompletedError, "Already installed: #{self.extension_name}") } end end describe '#uninstall(params)' do subject do extensions_double = double('extensions', find!: double('ext', delete: nil)) self.instance.profile = double('profile', extensions: extensions_double) - self.instance.uninstall(term: 'not-existed-extension') + self.instance.uninstall(term: self.extension_name) end + let(:extension_name){'existed-extension'} + it { expect{subject}.to_not raise_error } context 'when the `params[:term]` not existed' do subject do extensions_double = double('extensions') allow(extensions_double).to receive(:find!).and_raise(Firebrew::ExtensionNotFoundError) self.instance.profile = double('profile', extensions: extensions_double) - self.instance.uninstall(term: 'not-existed-extension') + self.instance.uninstall(term: self.extension_name) end - it { expect{subject}.to raise_error(Firebrew::OperationAlreadyCompletedError) } + let(:extension_name){'not-existed-extension'} + + it { expect{subject}.to raise_error(Firebrew::OperationAlreadyCompletedError, "Already uninstalled: #{self.extension_name}") } end end end end end